query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Build a Blocks::Container object and add it to an array of containers matching it's block name (used only for queuing a collection of before, after, and around blocks for a particular block name)
def add_block_container_to_list(*args, &block) block_container = self.build_block_container(*args, &block) if blocks[block_container.name].nil? blocks[block_container.name] = [block_container] else blocks[block_container.name] << block_container end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_contain...
[ "0.6950593", "0.67473036", "0.6323744", "0.60207164", "0.60203123", "0.5930976", "0.5840465", "0.5800918", "0.5718595", "0.5650957", "0.5618166", "0.5544193", "0.55418634", "0.5539292", "0.54656607", "0.5461262", "0.54523575", "0.5440888", "0.5409546", "0.5399009", "0.5316680...
0.66434777
2
Build a Blocks::Container object and add it to the global hash of blocks if a block by the same name is not already defined
def define_block_container(*args, &block) block_container = self.build_block_container(*args, &block) blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given? block_container end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n ...
[ "0.74327475", "0.6817441", "0.67584366", "0.6169531", "0.6115075", "0.6104901", "0.60795325", "0.6035718", "0.5856504", "0.58524126", "0.5851874", "0.58500856", "0.5845006", "0.5844824", "0.5768412", "0.57348526", "0.573268", "0.5695212", "0.5606382", "0.5598131", "0.55494285...
0.72267526
1
See create_for_resource for documentation on 'opts'
def create_for_user(name, opts = {}) unless valid? raise CertificateNoLongerValidException.new end email = opts[:email] || "#{name}@#{@@def_email_domain}" user_id = opts[:user_id] || UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, email) opts[:cn] = "#{user_id}/emailAddr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(resource, options = {}, format = nil)\n base_create(resource, options, format)\n end", "def create(opts)\n opts = check_params(opts,[:definitions,:wildmasks,:resources,:profiles])\n super(opts)\n end", "def create_resource_with_http_info(resource, opts = {})\n if @api_c...
[ "0.70495033", "0.6827332", "0.66715145", "0.6594961", "0.6561043", "0.6555644", "0.65167624", "0.645247", "0.644378", "0.63996917", "0.63683903", "0.6367619", "0.63568085", "0.6346443", "0.63420165", "0.63400555", "0.63391864", "0.6301981", "0.6297595", "0.6297426", "0.625925...
0.0
-1
Return the X509 certificate. If it hasn't been passed in, return a selfsigned one
def to_x509() @cert end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x509\n @x509 ||= OpenSSL::X509::Certificate.new(as_pem)\n end", "def certificate_get\n return @cert unless @cert.nil?\n cert_path = File.join(resource[:cert_dir], resource[:cert_name])\n @cert = if Pathname.new(cert_path).exist?\n file = File.read(cert_path)\n ...
[ "0.7381351", "0.73387355", "0.72972775", "0.72907573", "0.7288836", "0.7214728", "0.70404077", "0.6888398", "0.68689144", "0.6818264", "0.67947125", "0.6793299", "0.6769461", "0.6719156", "0.66315323", "0.6616392", "0.6553652", "0.6520329", "0.64659774", "0.64501065", "0.6432...
0.7512672
0
Return a hash of some of the key properties of this cert. To get the full monty, use 'openssl x509 in xxx.pem text'
def describe { subject: subject, issuer: @cert.issuer, addresses: addresses, can_sign: can_sign?, root_ca: root_ca?, valid: valid?, valid_period: [@cert.not_before, @cert.not_after] } #(@cert.methods - Object.new.methods).sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cert_digest\n Digest::SHA1.hexdigest(@cert.to_der)\n end", "def hash\n to_pem.hash\n end", "def hash\n to_pem.hash\n end", "def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end", "def public_key\n @cert.public_key\n end", "def cert_hash(cert)\n java_byt...
[ "0.67010516", "0.62815714", "0.62815714", "0.6218221", "0.61926126", "0.61859363", "0.61471754", "0.6146044", "0.6090871", "0.60827404", "0.6079351", "0.6044566", "0.60421455", "0.60371745", "0.59984607", "0.5975145", "0.5972542", "0.5964493", "0.5930349", "0.5926125", "0.591...
0.55746716
58
Will return one of the following :HS256, :HS384, :HS512, :RS256, :RS384, :RS512, :ES256, :ES384, :ES512 def key_algorithm end
def to_s "#<#{self.class} subj=#{@subject} can-sign=#{@key != nil}>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def algorithm\n \"HS256\"\n end", "def key_algorithm\n if self.rsa?\n :rsa\n elsif self.dsa?\n :dsa\n elsif self.ec?\n :ec\n end\n end", "def signing_algorithm\n signing_key.is_a?(String) ? \"HS256\" : \"RS256\"\n end", "def key_algorithm\n ...
[ "0.83565164", "0.83121043", "0.80309874", "0.7992818", "0.7698666", "0.7400133", "0.7297444", "0.7293272", "0.72826403", "0.6789599", "0.6434519", "0.6327955", "0.6200459", "0.6154615", "0.60763454", "0.604542", "0.60429096", "0.5964013", "0.59345907", "0.59345907", "0.593378...
0.0
-1
head and tail should never be reassigned
def initialize @sentinel_head = Node.new @sentinel_tail = Node.new @sentinel_head.next = @sentinel_tail @sentinel_tail.prev = @sentinel_head end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @head = nil\n @tail = nil\n end", "def initialize\n @head = nil\n @tail = nil\n end", "def initialize\r\n @head = nil\r\n @tail = nil\r\n end", "def tail=(_); end", "def tail\n curr = head\n curr = curr.next until curr.next.nil?\n curr\n end...
[ "0.78119224", "0.7686418", "0.75374013", "0.7498581", "0.7479428", "0.74303037", "0.72673434", "0.72660804", "0.72264796", "0.7130956", "0.7116236", "0.70601964", "0.7026725", "0.6991081", "0.69881386", "0.6981664", "0.69754046", "0.69499034", "0.6944459", "0.6937729", "0.689...
0.0
-1
by doing include Enumerable, the module gives us access to `map`, `each_with_index`, `select`, `any?`
def each(&prc) current_node = @sentinel_head.next until current_node == @sentinel_tail prc.call(current_node) current_node = current_node.next end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def any?(collection)\n collection.each do |element|\n return true if yield(element)\n end\n false\nend", "def any?(array)\n array.each do |el|\n return true if yield(el)\n end\n\n false\nend", "def any?(array)\n array.each do |element|\n return true if yield(element)\n end\n \n false\nend", ...
[ "0.61748475", "0.59547365", "0.5951201", "0.5865212", "0.5865212", "0.58536476", "0.58319026", "0.5823896", "0.5790847", "0.5785443", "0.57828426", "0.57708174", "0.57695097", "0.57491946", "0.57471097", "0.5736222", "0.5721745", "0.5688338", "0.56751984", "0.5668859", "0.566...
0.0
-1
uncomment when you have `each` working and `Enumerable` included
def to_s inject([]) { |acc, node| acc << "[#{node.key}, #{node.val}]" }.join(", ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(*) end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", ...
[ "0.729552", "0.729552", "0.729552", "0.729552", "0.729552", "0.729552", "0.7163506", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.70454085", "0.70422536", "0.6950336", "0.67...
0.0
-1
Getter and setter for virtual attribute "title"
def title @title ||= self.content.split(@@title_separator).first unless self.content.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title_attribute\n @title\n end", "def title \n @title \n # define title method which is a getter becuase it gets a property for us \n end", "def title=(some_title)\n @title = some_title\n end", "def title=(value)\n\t\t\t@title = value\n\t\tend", "def title=(title)\n @attribu...
[ "0.8268489", "0.8197291", "0.8035383", "0.8018694", "0.80116063", "0.7973254", "0.79184425", "0.7885641", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78751737", "0.7862451", "0.7851904", "0.7851904", "0.7792225", "0.778...
0.0
-1
Getter and setter for virtual attribute "body"
def body @body ||= self.content.split(@@title_separator,2).last unless self.content.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body=(value)\n @body = value\n end", "def body=(body)\n raise NotImplementedError, 'Subclasses must implement a body= method'\n end", "def body=(body); end", "def body=(value)\n @body = value\n end", "def body=(value)\n @body = value\n ...
[ "0.8161714", "0.81439316", "0.8064064", "0.7980845", "0.7980845", "0.7980845", "0.7980845", "0.7947753", "0.78952575", "0.78952575", "0.77250093", "0.7714708", "0.76984656", "0.76638705", "0.7612632", "0.7525027", "0.75182956", "0.75024235", "0.7443297", "0.7435918", "0.73539...
0.0
-1
Look for Sonos devices on the network and return the first IP address found
def discover result = SSDP::Consumer.new.search(service: 'urn:schemas-upnp-org:device:ZonePlayer:1', first_only: true, timeout: @timeout, filter: lambda {|r| r[:params]["ST"].match(/ZonePlayer/) }) @first_device_ip = result[:address] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend", "def find\...
[ "0.67007095", "0.6655891", "0.6606347", "0.65200466", "0.6434014", "0.6404742", "0.6386754", "0.6307892", "0.63044244", "0.6298022", "0.62897813", "0.6237097", "0.6225879", "0.616932", "0.61301744", "0.6038306", "0.60352594", "0.60295093", "0.60295093", "0.6010436", "0.596226...
0.5988056
20
Find all of the Sonos devices on the network
def topology self.discover unless @first_device_ip return [] unless @first_device_ip namespace = "urn:schemas-upnp-org:service:ZoneGroupTopology:1" action = "#{namespace}#GetZoneGroupState" message = %Q{<u:GetZoneGroupState xmlns:u="#{namespace}"></u:GetZoneGroupState>} response = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_devices\n get_device_paths.collect do |device_path|\n NetworkManager::Device.new(device_path)\n end\n end", "def devices(params={})\n res = @client.get(\"#{path}/devices\", params)\n\n res.json[\"devices\"].map{ |atts| ::M2X::Client::Device.new(@client, atts) } if res.success?\n...
[ "0.7357605", "0.71659994", "0.71115047", "0.70766914", "0.7033616", "0.7008837", "0.6970478", "0.6959616", "0.68751204", "0.68542933", "0.6784679", "0.677565", "0.6769558", "0.6769322", "0.6706875", "0.66958225", "0.6656071", "0.6555915", "0.65253353", "0.6487926", "0.6360122...
0.0
-1
Creates a new Expression from an infix expressions string. Builds a binary tree upon initialization.
def initialize(exp) @orig, @tree = exp, create_tree(exp) @prefix, @infix, @postfix = @tree.preorder_traverse, @tree.inorder_traverse, @tree.postorder_traverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_infix_tree\n return @infix_tree unless @infix_tree.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands o...
[ "0.7524389", "0.7079986", "0.7076356", "0.6936732", "0.6846916", "0.6608379", "0.6494733", "0.6386341", "0.6323832", "0.63109237", "0.6255394", "0.62244964", "0.613986", "0.6082874", "0.60073715", "0.59948367", "0.5962967", "0.59522575", "0.5942479", "0.5870598", "0.58393604"...
0.5803772
22
Evaluates the expression. Uses the postfix representation and integer arithmetic.
def evaluate() # operand stack opStack = [] # iterate over the tokens @postfix.split("").each do |c| # check if an operator if %w[+ - * / ^].include? c # pop the stack for the two operands where # a [operator] b b, a = opStack.pop, opStack.pop ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second nu...
[ "0.7586155", "0.75738376", "0.7543657", "0.7537", "0.752676", "0.7480811", "0.74662673", "0.7454852", "0.7355399", "0.73471344", "0.7335417", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0...
0.76909465
0
Converts an infix expression to a binary expression tree.
def create_tree(exp) operatorStack, nodeStack = [], [] # define function to create new tree segment subtree = Proc.new { # pop operands where # a [operator] b b, a = nodeStack.pop, nodeStack.pop nodeStack.push(Tree::Node.new(operatorStack.pop, a, b)) } exp.split("").each d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_infix_tree\n return @infix_tree unless @infix_tree.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands o...
[ "0.81183", "0.75568074", "0.70040524", "0.69331366", "0.68119454", "0.6729062", "0.64925843", "0.6306495", "0.622842", "0.60889727", "0.58949274", "0.5781334", "0.5761719", "0.5741115", "0.57316005", "0.5723823", "0.56861854", "0.56104773", "0.5591468", "0.55859727", "0.55159...
0.5757935
13
Evaluates the precedence of an operator.
def precedence_of(ch) case ch when '^' 10 when '*', '/' 5 when '+', '-' 1 else 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precedence\n case @operator\n when '+', '-'\n # addition and subtraction\n 0\n when '*', '/'\n # multiplication and division\n 1\n when '**', '^'\n # powers / roots (e.g. 2^(1/2))\n 2\n end\n end", "def inputPrecedence(operator)\n if operator == \"+\" || opera...
[ "0.8410472", "0.78838253", "0.7843743", "0.77748907", "0.7753463", "0.77295524", "0.756273", "0.75553393", "0.728769", "0.6883057", "0.67657137", "0.6631053", "0.65994614", "0.63554925", "0.63342714", "0.63204867", "0.6292086", "0.6285041", "0.62753016", "0.6177448", "0.61681...
0.7059917
9
================================================================================= Create the thead process for the Jekyll server Params: +preview+:: the preview
def jekyll_thread preview terminal_add preview, terminal_info(I18n.t('preview.message.start')) Rails.application.executor.wrap do Thread.new do Rails.application.reloader.wrap do Rails.application.executor.wrap do start_jekyll preview end end end e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview_title_and_toc\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_title_toc-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.title_...
[ "0.642627", "0.55547947", "0.54683995", "0.5409561", "0.5348179", "0.5309905", "0.52735263", "0.5262009", "0.52282965", "0.5199787", "0.51580495", "0.5153248", "0.5153248", "0.5111445", "0.508971", "0.50816727", "0.50076956", "0.49763697", "0.49747205", "0.49747205", "0.48802...
0.5884167
1
================================================================================= Start the Jekyll server for a preview Params: +preview+:: the preview
def start_jekyll preview path = get_dest_path preview Dir.chdir path Bundler.with_clean_env do ActiveSupport::Dependencies.interlock.permit_concurrent_loads do begin continue = true # Test if bundle was previously updated out, status = Open3.capture2e("bundle chec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jekyll_thread preview\n terminal_add preview, terminal_info(I18n.t('preview.message.start'))\n Rails.application.executor.wrap do\n Thread.new do\n Rails.application.reloader.wrap do\n Rails.application.executor.wrap do\n start_jekyll preview\n end\n end\n ...
[ "0.766323", "0.73429805", "0.6549405", "0.6487804", "0.6260098", "0.6255539", "0.61358005", "0.6128708", "0.6066154", "0.60524046", "0.5980425", "0.5856681", "0.5842496", "0.568482", "0.56844234", "0.5656416", "0.5656416", "0.56339175", "0.5616568", "0.5582136", "0.55745834",...
0.7350539
1
GET /movies GET /movies.json
def index @movies = Movie.joins(:indications).where("user_indicator_id = ?" , session[:user_id]).order("id DESC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movies\n get('Movies')\n end", "def pull_movies(options = {})\n response = HTTParty.get(build_url('movie', options), headers: HEADERS, debug_output: $stdout)\n JSON.parse(response.body)\n end", "def index\n @movies = @category.movies.find(:all)\n\n respond_to do |format|\n f...
[ "0.8228256", "0.74844414", "0.7479458", "0.7471823", "0.744568", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7343841", "0.7281429", "0.72150177", "0.7196884", "0.71509445", "0.7128497", "0.7031844", "0.70074904", "0.70027953", "0.6971893",...
0.0
-1
GET /movies/1 GET /movies/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movies\n get('Movies')\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.ht...
[ "0.7840408", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7337925", "0.7307941", "0.7254705", "0.7145913", "0.712192", "0.7111538", "0.70936346", "0.7092198", "0.70896614", "0.70844346", "0.7034522", "0.6987229", "0.69613814", "0.6960965", ...
0.0
-1
POST /movies POST /movies.json
def create @movie = Movie.new(movie_params) respond_to do |format| if @movie.save format.html { redirect_to @movie, notice: 'Movie was successfully created.' } format.json { render :show, status: :created, location: @movie } else format.html { render :new } format.js...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to root_path, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render...
[ "0.6937797", "0.6906045", "0.6906045", "0.6906045", "0.6906045", "0.6906045", "0.68716276", "0.6845159", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6773142", "0.677238", "0.677238", "0.6763869", "0...
0.6847402
7
PATCH/PUT /movies/1 PATCH/PUT /movies/1.json
def update respond_to do |format| if @movie.update(movie_params) format.html { redirect_to @movie, notice: 'Movie was successfully updated.' } format.json { render :show, status: :ok, location: @movie } else format.html { render :edit } format.json { render json: @movie.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit...
[ "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6808521", "0.6808521", "0.6808521", "0.6738241", "0.6642519", "0.6634734", "0.6623662", "0.65999764", "0.6576408", "0.6529476", "0.65115124", "0.648043", "0.64515513", "0.64442456", "0.6431154", ...
0.6672123
23
DELETE /movies/1 DELETE /movies/1.json
def destroy @movie.destroy respond_to do |format| format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.ht...
[ "0.75601494", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75291234", "0.74914795", "0.74914795", "0.74914795", "0.74914795", "0.74370456", "0.7318032", "0.72660154", "0.72660154", "0.72660154", "0.7200101", "0.716558", ...
0.7198954
35
Use callbacks to share common setup or constraints between actions.
def set_movie @movie = Movie.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def movie_params params.require(:movie).permit(:id, :titulo, :imdb, :poster, :ano, :nota, :genero) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
get every test to pass before coding runner below
def runner # code runner here end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no...
[ "0.7274132", "0.7200911", "0.71905994", "0.7134598", "0.7127439", "0.70358455", "0.6860759", "0.68229115", "0.68049264", "0.6790065", "0.6790065", "0.6768047", "0.65728307", "0.65551996", "0.65487796", "0.65460235", "0.65293026", "0.64595217", "0.6447049", "0.6447049", "0.644...
0.0
-1
GET /contract_doc_categories GET /contract_doc_categories.json
def index @contract_doc_categories = ContractDocCategory.all respond_to do |format| format.html # index.html.erb format.json { render json: @contract_doc_categories } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contractor_categories = ContractorCategory.all\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categor...
[ "0.69252735", "0.67598003", "0.673712", "0.6678443", "0.6576718", "0.65489995", "0.65432817", "0.64964265", "0.64686626", "0.64140546", "0.6370414", "0.63575125", "0.63302326", "0.6323264", "0.63148177", "0.630736", "0.6271636", "0.6251189", "0.6238842", "0.623381", "0.623291...
0.7734442
0
GET /contract_doc_categories/1 GET /contract_doc_categories/1.json
def show @contract_doc_category = ContractDocCategory.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @contract_doc_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def index\n @contractor_categories = ContractorCategory.all\n end", "def GetCategories params =...
[ "0.77587914", "0.6861526", "0.67619574", "0.6758411", "0.65605724", "0.6559104", "0.65535885", "0.6548796", "0.6535411", "0.64795077", "0.63826764", "0.6365459", "0.63415504", "0.63379645", "0.6326459", "0.6304687", "0.6299475", "0.62989205", "0.629847", "0.624121", "0.623838...
0.6912725
1
GET /contract_doc_categories/new GET /contract_doc_categories/new.json
def new @contract_doc_category = ContractDocCategory.new respond_to do |format| format.html # new.html.erb format.json { render json: @contract_doc_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category])\n\n respond_to do |format|\n if @contract_doc_category.save\n format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' }\n format.json { re...
[ "0.7617293", "0.69698524", "0.68557256", "0.67465174", "0.6687359", "0.6627671", "0.66260815", "0.6623843", "0.6615223", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.65653014", "0.6564173", "0...
0.77531904
0
POST /contract_doc_categories POST /contract_doc_categories.json
def create @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category]) respond_to do |format| if @contract_doc_category.save format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' } format.json { render json: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payl...
[ "0.65566033", "0.63240516", "0.6303891", "0.6094285", "0.6030948", "0.5988808", "0.5985044", "0.5959302", "0.5939959", "0.5842369", "0.5757353", "0.5753555", "0.57221884", "0.5650957", "0.5624956", "0.5618818", "0.56053704", "0.55904347", "0.5585924", "0.5581721", "0.5570876"...
0.71983665
0
PUT /contract_doc_categories/1 PUT /contract_doc_categories/1.json
def update @contract_doc_category = ContractDocCategory.find(params[:id]) respond_to do |format| if @contract_doc_category.update_attributes(params[:contract_doc_category]) format.html { redirect_to @contract_doc_category, notice: 'Contract doc category was successfully updated.' } format...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end", "def create\n @contract_doc_cat...
[ "0.71546346", "0.66962844", "0.6478813", "0.6278743", "0.6203736", "0.5856204", "0.583044", "0.5796072", "0.5766279", "0.5672686", "0.56694543", "0.5644705", "0.5630154", "0.56238836", "0.56124693", "0.5612258", "0.5565249", "0.5546055", "0.5505531", "0.54985297", "0.5494529"...
0.68047667
1
DELETE /contract_doc_categories/1 DELETE /contract_doc_categories/1.json
def destroy @contract_doc_category = ContractDocCategory.find(params[:id]) @contract_doc_category.destroy respond_to do |format| format.html { redirect_to contract_doc_categories_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contract_document.destroy\n respond_to do |format|\n format.html { redirect_to contract_documents_url }\n format.json { head :no_content }\n end\n end", "def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end", ...
[ "0.6751191", "0.6737136", "0.6669458", "0.66687363", "0.6652359", "0.6650014", "0.66235083", "0.6591029", "0.6556768", "0.65394855", "0.65357304", "0.6524285", "0.65047705", "0.65026826", "0.6485148", "0.64774173", "0.6464808", "0.64556545", "0.6451928", "0.6448894", "0.64394...
0.8030113
0
Method that prints out the contents of an album object nicely.
def to_s puts "The album #{@name} by #{@artist}. \n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_album album\n\tputs 'Album Title: ' + album.title\n\tputs 'Album Artist: ' + album.artist\n\tputs 'Album Genre: ' + album.genre\n\tputs ''\n\tputs 'Tracks: '\n\tprint_tracks(album.tracks)\nend", "def print_album album\n\tputs '*********************************************'\n\tputs 'Album Title: ' + alb...
[ "0.82961124", "0.82895875", "0.8070043", "0.80140465", "0.77267736", "0.7574771", "0.752466", "0.74853665", "0.74372077", "0.7381095", "0.7185317", "0.7158004", "0.6993709", "0.6963334", "0.6963334", "0.683148", "0.6743212", "0.6369995", "0.6368002", "0.6327267", "0.6311159",...
0.7086706
12
Method that checks if an object given to it is an album.
def isa? instance_of?(Album) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isa?\n\t\tinstance_of?(Album)\n\tend", "def album_unique?(album_object, artist_object)\n\n albums = self.albums.select{|album| album.artist.present?}\n non_nil_albums = albums.select{|album| album.artist.name == artist_object.name} << album_object.name\n non_nil_albums.length == non_nil_albums.uniq....
[ "0.8194015", "0.6476874", "0.6432577", "0.61883134", "0.61166966", "0.6001967", "0.59991974", "0.5900762", "0.57883006", "0.578643", "0.5775798", "0.57714975", "0.5757246", "0.5710056", "0.5710056", "0.5693423", "0.5691528", "0.56720376", "0.56223154", "0.5598594", "0.5591569...
0.81016976
1
Create Logger from environment variables. The following environment variables are supported: WEATHER_SAGE_LOG_LEVEL: Log level. One of "fatal", "error", "warning", "info", or "debug". Defaults to "warn". WEATHER_SAGE_LOG_PATH: Path to log file. Defaults to standard error.
def initialize(env) # get log level (default to "warn" if unspecified) log_level = (env.get('LOG_LEVEL', DEFAULT_LEVEL)).upcase # create logger from log path (default to STDERR) super(env.get('LOG_PATH', STDERR)) # set log level (default to WARN) self.level = ::Logger.const_get(log_level) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_logger\n path = Hanami.root.join(\"log\", [\"emergency_log.\", Hanami.env].join)\n Logger.new(path)\n end", "def create_logger path\n #path = File.join(ENV[\"LOGDIR\"] || \"./\" ,\"canis14.log\")\n _path = File.open(path, File::WRONLY|File::TRUNC|File::CREAT) \n ...
[ "0.58802617", "0.5512693", "0.548365", "0.54493564", "0.5412021", "0.5330148", "0.53199464", "0.52917814", "0.5280216", "0.5213973", "0.516227", "0.5125711", "0.5105448", "0.5087038", "0.5028018", "0.50257343", "0.49738595", "0.49733123", "0.49472165", "0.4919585", "0.4901498...
0.6035335
0
GET /organization_contacts GET /organization_contacts.json
def index if (current_user.role == "customer" || current_user.role == "supervisor") if params[:org_id].present? add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organiz...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end", "def get_contacts(options = {})\n send_request(\"get\", contacts_ur...
[ "0.7763893", "0.7644524", "0.7604293", "0.7509274", "0.7251787", "0.7153496", "0.71098584", "0.70868635", "0.7039071", "0.7007501", "0.70010036", "0.69918364", "0.6944387", "0.6922083", "0.6917199", "0.68698406", "0.6869466", "0.68459666", "0.6820051", "0.6804663", "0.6788378...
0.6572278
44
GET /organization_contacts/1 GET /organization_contacts/1.json
def show if (current_user.role == "customer" || current_user.role == "supervisor") add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organization_contacts_path(:org_id => "#{params[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end", "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def get_contacts(options = {})\n send_request(\"get\", contacts_ur...
[ "0.7529245", "0.7439879", "0.72882694", "0.72380465", "0.7131807", "0.7126097", "0.69347924", "0.6927793", "0.692478", "0.68884736", "0.68065065", "0.6806458", "0.6782019", "0.6763499", "0.6752455", "0.6741612", "0.674092", "0.67201394", "0.6719931", "0.6692103", "0.6689469",...
0.6350963
75
GET /organization_contacts/new GET /organization_contacts/new.json
def new if (current_user.role == "customer" || current_user.role == "supervisor") if params[:org_id].present? add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organizat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow r...
[ "0.7933381", "0.77920806", "0.76126516", "0.75914323", "0.75884795", "0.7508172", "0.74962723", "0.74962723", "0.74962723", "0.7457012", "0.7443107", "0.7412268", "0.739191", "0.7308839", "0.72314316", "0.7210511", "0.7210511", "0.7198996", "0.7173696", "0.71705043", "0.71630...
0.73356235
13
POST /organization_contacts POST /organization_contacts.json
def create @organization_contact = OrganizationContact.new(params[:organization_contact]) if params[:id][:org_id].empty? @organization_contact.organization_id = params[:organization_contact][:organization_id] else @organization_contact.organization_id = params[:id][:org_id] end respond...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end", "def cr...
[ "0.70148814", "0.6978043", "0.68544346", "0.68139714", "0.6790472", "0.6746869", "0.6730257", "0.67105407", "0.6706745", "0.6636133", "0.6622512", "0.661313", "0.657801", "0.6544441", "0.65436363", "0.6539426", "0.65168494", "0.6427256", "0.64032644", "0.6387553", "0.63725895...
0.7015095
0
PUT /organization_contacts/1 PUT /organization_contacts/1.json
def update @organization_contact = OrganizationContact.find(params[:id]) org_id = Organization.find_by_company_name(params[:organization_contact][:organization_id]).id respond_to do |format| params[:organization_contact][:organization_id] = org_id if @organization_contact.update_attributes(param...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_contacts(contacts)\n b = Builder::XmlMarkup.new\n request_xml = b.Contacts {\n contacts.each do | contact |\n contact.to_xml(b)\n end\n }\n\n response_xml = http_post(@client, \"#{@xero_url}/Contacts\", request_xml, {})\n\n response = parse_response(respon...
[ "0.68794465", "0.68764114", "0.6659082", "0.664357", "0.6634039", "0.66311294", "0.65473694", "0.6544432", "0.6540247", "0.65237737", "0.65087163", "0.6501151", "0.647436", "0.64389944", "0.6415391", "0.64046264", "0.64005375", "0.63825643", "0.6378881", "0.6361877", "0.63569...
0.76239353
0
DELETE /organization_contacts/1 DELETE /organization_contacts/1.json
def destroy if (current_user.role == "customer" || current_user.role == "supervisor") @organization_contact = OrganizationContact.find(params[:id]) @action = request.referrer @organization_contact.delflag = true if @organization_contact.update_attributes(params[:organization_contact]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contact.destroy\n render json: {status: 204}\n end", "def destroy\n @contact = @business.contacts.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to business_contacts_url(@business) }\n format.json { head :no_content }\n end\n ...
[ "0.74541485", "0.74085736", "0.73642683", "0.7354198", "0.73501456", "0.72563696", "0.72458166", "0.7237542", "0.718799", "0.71708286", "0.716746", "0.71490717", "0.71466285", "0.71466285", "0.71466285", "0.71424", "0.7129058", "0.7111794", "0.706215", "0.70514125", "0.704797...
0.0
-1
POST /custom_workouts POST /custom_workouts.json
def create @custom_workout = @user.custom_workouts.new(params[:custom_workout]) respond_to do |format| if @custom_workout.save # TODO need to get a specific month in there . . . format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom work...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @myworkout = Myworkout.new(params[:myworkout])\n\n respond_to do |format|\n if @myworkout.save\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully created.' }\n format.json { render :json => @myworkout, :status => :created, :location => @myworkout }\...
[ "0.72388965", "0.71684486", "0.71378744", "0.7121771", "0.6923282", "0.687507", "0.6815009", "0.66730154", "0.66602457", "0.66234684", "0.64854676", "0.64649713", "0.6462331", "0.6438944", "0.6381386", "0.6379294", "0.6376214", "0.63250685", "0.6314911", "0.62957966", "0.6261...
0.7617296
0
PUT /custom_workouts/1 PUT /custom_workouts/1.json
def update @custom_workout = @user.custom_workouts.find(params[:id]) respond_to do |format| if @custom_workout.update_attributes(params[:custom_workout]) format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom workout was successfully updated.' }...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n if @myworkout.update_attributes(params[:myworkout])\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully updated.' }\n format.json { head :no_content }\n else\n format.h...
[ "0.7118535", "0.70601964", "0.69140595", "0.6900946", "0.6875889", "0.6851672", "0.68229103", "0.6794696", "0.6784685", "0.6775333", "0.6775333", "0.6763716", "0.6688509", "0.6657758", "0.6657758", "0.6657758", "0.6657434", "0.656314", "0.65571964", "0.6500776", "0.6500776", ...
0.77989906
0
DELETE /custom_workouts/1 DELETE /custom_workouts/1.json
def destroy @custom_workout = @user.custom_workouts.find(params[:id]) @custom_workout.destroy respond_to do |format| flash[:notice] = "Successfully removed your workout." format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]) } format.json { head :ok } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @myworkout = Myworkout.find(params[:id])\n @myworkout.destroy\n\n respond_to do |format|\n format.html { redirect_to myworkouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout.destroy\n respond_to do |format|\n format.html { redirect_...
[ "0.79460603", "0.77279824", "0.7672459", "0.76446676", "0.7505636", "0.746544", "0.74533933", "0.74256665", "0.73984593", "0.7375284", "0.735805", "0.7272293", "0.7200361", "0.7187809", "0.7158609", "0.7149895", "0.714665", "0.714665", "0.714665", "0.714665", "0.71121323", ...
0.77093947
2
This sweeper is going to keep an eye on the r model
def after_create(r) expire_cache_for(r) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def broadcasting_for(model); end", "def mutate\n @weights = (1..@size).map { Random.rand(-0.5..0.5) }\n end", "def rebuild_weight_array\n end", "def test_recycling_robot\n @alpha = 0.1\n @beta = 0.1\n @r_search = 2\n @r_wait = 1\n @r_rescue = -3\n\n table_model = TableModel.ne...
[ "0.57930696", "0.5552664", "0.5537244", "0.5408959", "0.5396827", "0.53782517", "0.52675444", "0.52124196", "0.51471466", "0.51403415", "0.513921", "0.513054", "0.51225716", "0.50838363", "0.5014164", "0.5004037", "0.5001946", "0.4999097", "0.49673748", "0.49036282", "0.48953...
0.0
-1
instance method to check if the password from login form is identical to the password saved during sign up
def authenticate(password) BCrypt::Password.new(self.password_digest) == password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasSamePassword?(submittedPassword)\n encrypted_password == encryptUsingSalt(submittedPassword)\n end", "def password_match?\n self.password == self.password_confirmation\n end", "def has_password?(submitted_password)\n self.password == encrypt(submitted_password)\n end", "def passwords_match...
[ "0.8087815", "0.7930782", "0.7901597", "0.7901542", "0.78098774", "0.77931345", "0.7781721", "0.77812254", "0.77812254", "0.7770039", "0.77351993", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838"...
0.0
-1
Initialize a new Link instance.
def initialize(name, href, templated = false) @name = name @href = href @templated = templated end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(link_string)\n @link_string = link_string\n end", "def new_link\n @link = Link.new\n end", "def initialize(link_options={})\n @id = link_options[\"id\"]\n @assignment_id = link_options[\"assignment_id\"] \n @link = link_options[\"link\"]\n @type = link_options[\"type\"]\n...
[ "0.7395907", "0.7256082", "0.7241221", "0.7042234", "0.7018515", "0.7007218", "0.6862575", "0.6599071", "0.65781456", "0.6480334", "0.64769566", "0.6430168", "0.6430168", "0.64232516", "0.64232516", "0.6415516", "0.63884765", "0.63850474", "0.6359316", "0.632041", "0.626927",...
0.57998747
86
Predicate function denoting whether or not the Link url is a template.
def templated? @templated end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _templated?\n !!@link['templated']\n end", "def templated?\n !template.nil?\n end", "def is_link?\n self.type == 'Document::VirtualCollege' && !is_pdf?\n end", "def partial?\n\t\t\tlinks.by(:rel)['alternate'].any? do |l|\n\t\t\t\tl[3]=='application/atom+xml'||l[3]=='application/atom+x...
[ "0.701541", "0.63204515", "0.62723106", "0.62368125", "0.6198641", "0.6137688", "0.6066326", "0.587973", "0.5848728", "0.58456707", "0.58416855", "0.5805948", "0.57974344", "0.5789741", "0.5789728", "0.57859915", "0.57696664", "0.574656", "0.57238096", "0.5711904", "0.5711904...
0.56754375
23
removing all odd numbers from an array
def remove_odd_numbers_from_array(a) a.each do |x| if x%2!=0 a.delete x end end return a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_odd_numbers_from_array(a)\n a.reject {|n| n.odd?}\nend", "def remove_odd_numbers_from_array(a)\n a.each do |x|\n if x%2!=0\n a.delete x\n end\n end\n return a\nend", "def remove_odd array\n no_odds_array = []\n array.each do |number|\n if number % 2 == 0\n no_odds_ar...
[ "0.8649637", "0.8510921", "0.84928346", "0.8418858", "0.83774436", "0.8366879", "0.83448106", "0.803952", "0.802341", "0.79663587", "0.7959718", "0.7952741", "0.7950148", "0.7938811", "0.79222083", "0.7919922", "0.79122835", "0.78768367", "0.77158695", "0.7655689", "0.7617314...
0.8573983
1
Sample Dataset AAAACCCGGT Sample Output ACCGGGTTTT
def reverse_complement(dna_string) complementary = {'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C'} complement = "" dna_string.reverse.each_char do |nucleotide| complement += complementary[nucleotide] end complement end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_data\n %w(A,B,1 A,C,2 B,C,3 B,D,3 C,D,1 B,E,2 D,F,3 D,E,3 E,G,3 F,G,1)\n end", "def mutate_ugcid(_)\n (ALPHABET.sample(6) + DIGITS.sample(4)).join\n end", "def samples; end", "def samples; end", "def samples_values\n %w(\n 7-84794-00160-2\n 0-85798-02872-6\n 8-926...
[ "0.63853765", "0.5495993", "0.5343282", "0.5343282", "0.52739435", "0.5130214", "0.5120204", "0.5095826", "0.50125533", "0.4937378", "0.48821124", "0.48660684", "0.48475075", "0.48296756", "0.482702", "0.47889024", "0.47796342", "0.47577423", "0.47510543", "0.4744384", "0.471...
0.0
-1
GET /evaluators GET /evaluators.xml
def index respond_to do |format| format.html # index.html.erb format.xml { render :xml => @evaluators } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def index\n @evaluates = Evaluate.all\n ...
[ "0.6577595", "0.6472638", "0.6447232", "0.6365749", "0.63173395", "0.6290402", "0.62816536", "0.6276755", "0.6276755", "0.6276755", "0.6276755", "0.6276755", "0.626674", "0.6263589", "0.62486714", "0.62147796", "0.6130541", "0.6118378", "0.607262", "0.6069896", "0.6024948", ...
0.75014734
0
GET /evaluators/1 GET /evaluators/1.xml
def show respond_to do |format| format.html # show.html.erb format.xml { render :xml => @evaluator } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n @evaluacione = Evaluacione....
[ "0.72095126", "0.65815514", "0.63173735", "0.631313", "0.61492413", "0.61009884", "0.6095731", "0.60613704", "0.60271287", "0.59944963", "0.59503233", "0.5910722", "0.5910722", "0.5910722", "0.5910722", "0.5910722", "0.5869709", "0.5855464", "0.58416736", "0.57845193", "0.577...
0.6513785
2
GET /evaluators/new GET /evaluators/new.xml
def new @evaluator.owner_id = current_user.id respond_to do |format| format.html # new.html.erb format.xml { render :xml => @evaluator } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def new\n @evaluation = Evaluation.new\n\t\t\n\t\tif request.post?\n\t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', p...
[ "0.6955858", "0.6865809", "0.65242964", "0.6502246", "0.63965094", "0.63796264", "0.63490623", "0.6337453", "0.62919426", "0.62830216", "0.62442833", "0.62144375", "0.62033117", "0.6198021", "0.61828005", "0.6175798", "0.615987", "0.6137036", "0.6128745", "0.6126429", "0.6123...
0.6346291
7
POST /evaluators POST /evaluators.xml
def create @evaluator.owner_id = current_user.id @evaluator.accessible = [:owner_id] if can? :transfer, @evaluator # free to give others an evaluator to own @evaluator.attributes = params[:evaluator] respond_to do |format| if @evaluator.save format.html { redirect_to(@evaluator, :notice =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n ...
[ "0.6374229", "0.62855715", "0.5954634", "0.5865875", "0.5765015", "0.56849235", "0.56270635", "0.5614256", "0.5598371", "0.5561228", "0.5485529", "0.54726666", "0.54726666", "0.5431737", "0.5431031", "0.5415182", "0.5386472", "0.5356005", "0.5356005", "0.5346574", "0.531846",...
0.5828644
4
PUT /evaluators/1 PUT /evaluators/1.xml
def update @evaluator.accessible = [:owner_id] if can? :transfer, @evaluator respond_to do |format| if @evaluator.update_attributes(params[:evaluator]) format.html { redirect_to(@evaluator, :notice => 'Evaluator was successfully updated.') } format.xml { head :ok } else for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n if @evaluacione.update_attributes(params[:evaluacione])\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully updated.') }\n format.xml { head :ok }\n else\n for...
[ "0.6051337", "0.58860713", "0.57398343", "0.57144755", "0.56676656", "0.56303316", "0.56198335", "0.56019086", "0.5576047", "0.5538394", "0.5536711", "0.55187345", "0.55121624", "0.5458575", "0.54212207", "0.53900814", "0.5379518", "0.5348556", "0.53291637", "0.53169364", "0....
0.57602596
2
DELETE /evaluators/1 DELETE /evaluators/1.xml
def destroy @evaluator.destroy respond_to do |format| format.html { redirect_to(evaluators_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @evaluacione = Evaluacione.find(params[:id])\n @evaluacione.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n ...
[ "0.6882842", "0.681412", "0.681412", "0.6778896", "0.6495405", "0.6476748", "0.639871", "0.63172853", "0.629123", "0.62126756", "0.61966735", "0.6186981", "0.6186981", "0.6178857", "0.6157606", "0.6153738", "0.61197335", "0.6116494", "0.6100623", "0.60852253", "0.6043209", ...
0.7202966
0
Ensures that storeconfigs is present before calling AbstractCollector's evaluate method
def evaluate if Puppet[:storeconfigs] != true return false end super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_exists?; collect_data_exists? || collect_module_exists?; end", "def store_instances(enabled_stores, store_configs)\n fail \"No stores have been enabled, see configuration file\" if enabled_stores.blank?\n fail \"No store configuration present, see configuration file\" if store_configs.blank?\n\...
[ "0.59760356", "0.5726866", "0.55157197", "0.5411421", "0.5312494", "0.5292913", "0.52025586", "0.5150112", "0.5115923", "0.488663", "0.48714945", "0.48470297", "0.484389", "0.48265576", "0.47959197", "0.47775227", "0.47582924", "0.47565797", "0.47546118", "0.47405994", "0.473...
0.7297491
0
Collect exported resources as defined by an exported collection. Used with PuppetDB
def collect resources = [] time = Puppet::Util.thinmark do t = @type q = @cquery resources = scope.compiler.resources.find_all do |resource| resource.type == t && resource.exported? && (q.nil? || q.call(resource)) end found = Puppet::Resource.indirection. search(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end", "def catalog_resources\n # This method exists to supply a common interface to the puppet catalog\n # for different versions of puppet.\n @catalog.resources.map do...
[ "0.6269942", "0.62085956", "0.60153866", "0.59598154", "0.58800614", "0.5878395", "0.58030134", "0.57985556", "0.5784362", "0.57606655", "0.57126385", "0.5712488", "0.5709556", "0.5693825", "0.5692376", "0.56261975", "0.5625326", "0.5608248", "0.56036484", "0.559852", "0.5581...
0.75565386
0
Set an inclusion proc for this mixin. This block is evaluated in the tool class immediately after the mixin is included, and is passed any arguments provided to the `include` directive.
def on_include(&block) self.inclusion = block self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def when_included(&block)\n @cautious_included_block = block\n end", "def before_inclusion(&block)\n if block && block.respond_to?(:call)\n before_inclusion_procs << block\n else\n raise 'Anything added to be called before_inclusion must be callable (respond to #call).'\n end\n ...
[ "0.6221959", "0.6211982", "0.61903054", "0.61840326", "0.6139432", "0.609612", "0.606477", "0.6002307", "0.5992969", "0.5987443", "0.5961427", "0.59278387", "0.59278387", "0.59278387", "0.59224725", "0.58986557", "0.58627254", "0.5860639", "0.58554924", "0.5831537", "0.583062...
0.7361768
0
Eric Harman Created: 11/12/2015
def get_user_password puts "Welcome to the password strength checking program." print "Enter password: " password = gets.chomp return password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def schubert; end", "def formation; end", "def probers; end", "def schumann; end", "def verdi; end", "def terpene; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def suivre; end", "def berlioz; end", "def jack_h...
[ "0.6931777", "0.6831812", "0.6461347", "0.639777", "0.6227045", "0.622278", "0.6120379", "0.61015177", "0.6026858", "0.6026858", "0.6026858", "0.6026858", "0.60167944", "0.60154283", "0.60036105", "0.5968127", "0.5964167", "0.5916282", "0.57789636", "0.5756168", "0.5654938", ...
0.0
-1
Makes sure a user cant access the given action Example: assert_user_cant_access(:quentin, "destroy", :listing_id => 1)
def assert_user_cant_access(user, actions, params = {}) assert_user_access_check(false, user, actions, params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access_denied\n request.env[\"HTTP_REFERER\"] = journals_path\n yield\n assert_redirected_to root_path\n assert_equal \"You are not authorized to access this page.\", flash[:alert]\n end", "def assert_forbidden\n get :index\n\n assert_redirected_to login_path\n assert_equal evaluations_...
[ "0.71123266", "0.69788283", "0.6522834", "0.64373386", "0.64342105", "0.6428972", "0.6410233", "0.6398427", "0.63782954", "0.6375055", "0.63680017", "0.6304291", "0.6302578", "0.62869495", "0.62827134", "0.6269447", "0.62516826", "0.6247354", "0.6228233", "0.6224001", "0.6208...
0.8491018
0
This is the core of the test system.
def request_passes_role_security_system?(action, params) did_it_pass = false action = action.to_s hijacker = Hijacker.new(@controller.class) begin assert hijacker.hijack_instance_method(action, "@last_action_passed='#{action}'; render :text => 'passed'"), "unable to hijack method ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests; end", "def tests; end", "def test_setup\r\n \r\n end", "def testing\n # ...\n end", "def self_test; end", "def self_test; end", "def my_tests\n end", "def testloop\n \n end", "def running_test_case; end", "def run_app_tests\n end", "def default_test\r\...
[ "0.7824516", "0.7824516", "0.7509247", "0.75055563", "0.7347401", "0.7347401", "0.728895", "0.7216379", "0.7194009", "0.7146875", "0.7134804", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "...
0.0
-1
Save away the view but also call super (SimpleDelegator) which will make sure that any calls in any subclass, like content_tag, will be forwarded onto the view_context automatically via SimpleDelegator method_missing implementation.
def initialize(view_context) @view_context = view_context super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(*args, &block)\n @view_context.send(*args, &block)\n end", "def method_missing(method, *args, &block)\n if @view.respond_to?(method)\n (class << self; self; end).class_eval do\n delegate method, to: :@view\n end\n self.send method, *args, &block\n ...
[ "0.72142464", "0.720461", "0.70156986", "0.6997656", "0.69651043", "0.68389076", "0.6830885", "0.6448301", "0.62301654", "0.61429715", "0.6089511", "0.60467744", "0.59703636", "0.5967247", "0.5857007", "0.5852681", "0.5852681", "0.584519", "0.5812232", "0.5747315", "0.5736524...
0.579116
19
Date / Time helper.
def display_time(timestamp) return nil if timestamp.blank? timestamp.to_s(:date_time_long) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date()\n @time\n end", "def date_and_time(options = {})\n @time.is_a?(Time) ? \"#{date(options)} at #{time(options)}\" : date(options = {})\n end", "def date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend", "def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end", "def my...
[ "0.72658706", "0.7052581", "0.7037743", "0.6997325", "0.6992995", "0.6985463", "0.6932825", "0.693001", "0.6900612", "0.6900612", "0.677878", "0.6778727", "0.6770018", "0.6682366", "0.66756177", "0.665279", "0.664885", "0.6639189", "0.6625472", "0.65879464", "0.65701634", "...
0.0
-1
Start and end date helper.
def format_start_end_date(s_date, e_date) # Format the dates based on month and year. if (s_date.mon == e_date.mon) && (s_date.year == e_date.year) date = s_date.strftime("%b %d-").to_s + e_date.strftime("%d, %Y").to_s elsif s_date.year == e_date.year date = s_date.strftime("%b %d - ").to_s + e_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dates\n start_s = start_date ? start_date.to_s : '?'\n end_s = end_date ? end_date.to_s : '?'\n \"#{start_s} to #{end_s}\"\n end", "def event_start_end_dates\n esdate and eedate\n end", "def start_date\n date\n end", "def determine_date\n if !params[:date_start].blank? && !params[:da...
[ "0.7806334", "0.7504897", "0.7229408", "0.72161454", "0.71717966", "0.7134071", "0.7122624", "0.70484227", "0.6962576", "0.6899374", "0.6869305", "0.68627644", "0.6831647", "0.67916477", "0.6781976", "0.67743236", "0.67740023", "0.6692568", "0.6621987", "0.6620965", "0.661599...
0.6749762
17
upload_file(remote_filepath, remote_filename, local_filedata) remote_filepath: Remote filepath where the file will be uploaded remote_filename: Remote name of the file to be executed ie. boot.ini local_file: File containing the read data for the local file to be uploaded, actual open/read/close done in exploit()
def upload_file(remote_filepath, remote_filename, local_filedata = null) magic_code = "\xdd\xdd" opcode = [6].pack('L') # We create the filepath for the upload, for execution it should be \windows\system32\wbem\mof\<file with extension mof! file = "..\\..\\" << remote_filepath << remote_filename <...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_file(remote, local)\n write_file(remote, ::File.read(local))\n end", "def upload(remote_path, contents)\n end", "def upload_file local_source, remote_dest, options = {}\n add [local_source, remote_dest], check_file(remote_dest)\n chmod options[:perms], remote_dest if options[:perms]...
[ "0.7708411", "0.74333805", "0.7370586", "0.7252144", "0.70272493", "0.69999075", "0.6986755", "0.6977685", "0.6925003", "0.69215", "0.6871475", "0.686814", "0.6854381", "0.6843439", "0.6840953", "0.67960453", "0.67590165", "0.67536944", "0.6699718", "0.6699118", "0.66800934",...
0.85107166
0
Use for check if the service encountered unknown exception
def normal_failed? return status == PRE_FAILED || status == WORKFLOW_FAILED || status == UPLOADING_RESULTS_VCF_FAILED || status == UPLOADING_RESULTS_SCORE_FAILED end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_exception?\n data['isException'] == true\n end", "def service_exception?\n original.body.include? '\"isException\":true,'\n end", "def service_unavailable\n\n end", "def test_does_not_consider_unknown_errors\n ig = ScoutApm::ErrorService::IgnoredExceptions.new(...
[ "0.74428755", "0.70238966", "0.6777485", "0.6479445", "0.64747727", "0.6433331", "0.6433331", "0.634382", "0.633796", "0.63092834", "0.62726694", "0.6247315", "0.6177071", "0.6176167", "0.6157352", "0.6113539", "0.60616314", "0.60440475", "0.60015726", "0.59978557", "0.599220...
0.0
-1
Return True if the workflow is completed If the workflow is completed, then we can return the results via rest api
def workflow_complete? return status == WORKFLOW_COMPLETE || status == UPLOADING_RESULTS_SCORE_RUNNING || status == UPLOADING_RESULTS_SCORE_COMPLETE || status == UPLOADING_RESULTS_VCF_RUNNING || status == UPLOADING_RESULTS_VCF_COMPLETE || status == COMPLETE e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completed?\n completed\n end", "def completed? # Is task completed? method\n completed_status # True or false\n end", "def complete()\n if @status.status == 'running'\n @logger.info \"Workflow #{self.class.name} has completed successfully\"\n @status.finished\n end\n end...
[ "0.69871557", "0.68729615", "0.68460083", "0.6821065", "0.6821065", "0.6776346", "0.67746854", "0.67564654", "0.670055", "0.66626245", "0.66512233", "0.6635171", "0.6626636", "0.66002434", "0.6598844", "0.6595642", "0.6595642", "0.6580231", "0.6569916", "0.6567461", "0.654173...
0.7996282
0
Check if the whole pedia service is complete
def pedia_complete? return status == COMPLETE end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete?\n status_code == 'OK'\n end", "def complete?\n !pending?\n end", "def complete?\n true\n end", "def complete?\n completed_at && response\n end", "def check_for_completeness\n mark_complete(Time.now) if paid? && received?\n end", "def compl...
[ "0.6847561", "0.68245554", "0.6812771", "0.681015", "0.6793678", "0.6774665", "0.6720847", "0.670837", "0.66802007", "0.6670647", "0.66577137", "0.6652871", "0.66319555", "0.6612134", "0.66067743", "0.65827566", "0.65827566", "0.6579573", "0.65789956", "0.6576879", "0.6539317...
0.7960537
0
GET /candidates GET /candidates.json
def index @candidates = Candidate.where(user_id: current_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def index\n @candidates = Candidate.a...
[ "0.7828381", "0.73522097", "0.73016286", "0.73016286", "0.73016286", "0.73016286", "0.73016286", "0.72219783", "0.6899774", "0.6775134", "0.67688996", "0.6342606", "0.6194655", "0.6079805", "0.6058217", "0.60146403", "0.596775", "0.5949632", "0.5942194", "0.59386665", "0.5871...
0.6928002
8
GET /candidates/1 GET /candidates/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def show\n @candidate = Candidate.fin...
[ "0.7575423", "0.7197467", "0.71252155", "0.712431", "0.7115484", "0.7115484", "0.7115484", "0.7115484", "0.7115484", "0.6741638", "0.66203165", "0.6575366", "0.64869016", "0.6464353", "0.61950725", "0.6021751", "0.60195464", "0.6016882", "0.59765464", "0.5966909", "0.59580374...
0.0
-1
POST /candidates POST /candidates.json
def create @candidate = current_user.candidates.new(candidate_params) respond_to do |format| if @candidate.save format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' } format.json { render :show, status: :created, location: @candidate } else form...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\...
[ "0.6904368", "0.6874747", "0.6840404", "0.6840404", "0.6840404", "0.6840404", "0.6836909", "0.681982", "0.67530876", "0.67346483", "0.6661026", "0.66238564", "0.6538402", "0.64989924", "0.64921826", "0.6466355", "0.6316517", "0.63106084", "0.6291944", "0.627492", "0.62635297"...
0.7399355
0
PATCH/PUT /candidates/1 PATCH/PUT /candidates/1.json
def update respond_to do |format| if @candidate.update(candidate_params) format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' } format.json { render :show, status: :ok, location: @candidate } else format.html { render :edit } format.json { r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html...
[ "0.6997068", "0.6843286", "0.67535204", "0.6686334", "0.65477365", "0.6542974", "0.6518262", "0.6458349", "0.64341927", "0.6364452", "0.63492894", "0.624964", "0.61845785", "0.6174728", "0.61387515", "0.61366266", "0.60592806", "0.5986286", "0.5959036", "0.5920511", "0.591544...
0.6768482
8
DELETE /candidates/1 DELETE /candidates/1.json
def destroy @candidate.destroy respond_to do |format| format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n res...
[ "0.7436304", "0.7436304", "0.71688795", "0.71688795", "0.71688795", "0.7097595", "0.7083692", "0.68879616", "0.67611915", "0.67196244", "0.6716783", "0.6708224", "0.6674849", "0.6648467", "0.6633264", "0.663056", "0.66255254", "0.6576449", "0.6526477", "0.65194345", "0.651943...
0.717342
9
Use callbacks to share common setup or constraints between actions.
def set_candidate @candidate = Candidate.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.532...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def candidate_params params.require(:candidate).permit(:name, :cellphone, :birth_date, :genre, :status, :regional_candidate, :country_code, :civil_status, :recruitment_source, :relocate, :actual_salary, :email, :variable_salary, :wage...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Initialized database from db_file
def initialize(db_file = false) if (db_file) @db_file = db_file else @db_file = CONFIG['resonance']['db_file'] end self.createIfNotExists end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_db\n # we want to check a couple levels 2011-09-28 \n unless @db\n unless File.exists? @file\n 3.times do |i|\n @file = \"../#{@file}\"\n break if File.exists? @file\n end\n end\n end\n @db ||= DB.new @file\n end", "def initialize(database_file)\n ...
[ "0.74505645", "0.73558855", "0.73324645", "0.7270188", "0.7239706", "0.7234668", "0.7230711", "0.72055304", "0.71879315", "0.7167892", "0.7106977", "0.70874065", "0.6946988", "0.6937854", "0.68809336", "0.6823428", "0.68010926", "0.6795747", "0.6790379", "0.6788123", "0.67649...
0.68781185
15
Create empty database file (for new actions)
def create File.open(@db_file, "w" ) do |file| end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_default_databases()\n # Create subfolder for databases if needed.\n dir = \"./databases\"\n Dir.mkdir(dir) unless Dir.exist?(dir)\n # TODO: sanity check: if db-file exist, create copy first, make sure the\n # name of the copy makes it highly unlikely to match an already existing\n # file, e.g. cur...
[ "0.70180553", "0.70034385", "0.6916622", "0.67767686", "0.6750496", "0.6745915", "0.67454153", "0.6736713", "0.66946566", "0.65877306", "0.65702873", "0.6518181", "0.64506614", "0.641259", "0.6378093", "0.6374572", "0.63407344", "0.6326909", "0.6324662", "0.63072497", "0.6294...
0.8056952
0
Checks has the given asteroid resonance or no body_number: number of body
def check?(body_number) File.open(@db_file, 'r').each do |line| arr = line.split(';') if (arr[0].to_i == body_number) return true end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_bodies\n if bat.actor? && $game_system.actors_bodies?\n @effect_type = nil\n @effect_duration = 0\n elsif !bat.actor? && $game_system.enemies_bodies?\n @effect_type = nil\n @effect_duration = 0\n end\n end", "def ball_is_resting?(walls, true_normal)\n entropy < 1.5 && !...
[ "0.5769949", "0.5396754", "0.52232695", "0.510508", "0.5100115", "0.50642204", "0.50398177", "0.5031931", "0.50051504", "0.49749032", "0.49733672", "0.49694163", "0.49031928", "0.4894748", "0.48898667", "0.48831612", "0.48384365", "0.47926685", "0.479218", "0.4764188", "0.474...
0.5127236
3
Add new resonance to database (if not exists) body_number: number of new body resonance: array of resonance values type: type of resonance
def add(body_number, resonance, type = 1) if !self.check?(body_number) File.open(@db_file, 'a+') do |db| db.puts(body_number.to_s+';'+type.to_s+';'+resonance.inspect) end true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveReceipt\n\t\tcurrent_time = DateTime.now\n\t\tReceipt.create!(:concept => params[:tipofactura],\n\t\t\t\t\t\t\t:subtotal => params[:subtotal],\n\t\t\t\t\t\t\t:total => params[:pagototal],\n\t\t\t\t\t\t\t:iva => params[:iva],\n\t\t\t\t\t\t\t:xml => params[:rawxml],\n\t\t\t\t\t\t\t:users_id => current_user.i...
[ "0.55727786", "0.5414552", "0.54082865", "0.5372017", "0.5306836", "0.52967393", "0.5277086", "0.5268584", "0.52550507", "0.5231991", "0.51906204", "0.5178119", "0.51626855", "0.5160992", "0.51592076", "0.51131296", "0.51053286", "0.5103857", "0.509744", "0.5084057", "0.50640...
0.72508407
0
Find all asteroids in resonances for given interval [start, stop] in body numbers start: start of the interval stop: stop of the interval
def find_between(start, stop) asteroids = Array.new File.open(@db_file, 'r').each do |line| arr = line.split(';') tmp = arr[0].to_i if ((tmp >= start) && (tmp <= stop) ) resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f} asteroids.push(Asteroid.new(arr[0], re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend", "def ranges\n x_start, y_start = absolute(0, 0)\n x_end, y_end = absolute(@diameter - 1, @diameter - 1)\n\n [x_start..x_end, y_start..y_end]\n end", "def front_rear_and...
[ "0.57230544", "0.54768497", "0.5457582", "0.54111487", "0.5384382", "0.53677857", "0.5340084", "0.53324497", "0.5291634", "0.52822244", "0.52500904", "0.5245245", "0.5233917", "0.5157799", "0.51520157", "0.5142144", "0.5095644", "0.50856274", "0.5076656", "0.5047769", "0.5044...
0.66536564
0
Find all asteroids in given resonance resonance: resonance array
def find_asteroids_in_resonance(c_resonance) asteroids = Array.new File.open(CONFIG['resonance']['db_file'], 'r').each do |line| arr = line.split(';') resonance = arr[1].gsub!('[', '').gsub!(']', '').split(', ').map{|elem| elem.to_f} if ((resonance[0] == c_resonance[0]) && (resonance[1] == c_r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def asteroid_collision(asteroids)\n puts '-' * 43\n puts \"asteroid_collision: #{asteroids}\"\n\n return [] if asteroids.empty?\n\n res = []\n\n asteroids.each do |ast|\n puts res.to_s\n\n if res.empty?\n res.push(ast)\n next\n end\n\n temp = res.pop\n\n if (temp < 0) && (ast < 0)\n ...
[ "0.57883084", "0.55295974", "0.54605013", "0.5421821", "0.54022443", "0.5327467", "0.5319856", "0.5249486", "0.517589", "0.5160459", "0.5139191", "0.5129507", "0.5119351", "0.5116142", "0.510882", "0.51056117", "0.50999314", "0.5088872", "0.50880206", "0.5084541", "0.5074132"...
0.73080885
0
parse one line of database file line: string from database file
def parse_line(line) if (line.include?(';')) arr = line.split(';') tmp = arr[0].to_i resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f} [tmp, arr[2].to_i, resonance] else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n...
[ "0.6612272", "0.6518746", "0.6329131", "0.62976557", "0.6276832", "0.6156063", "0.6134973", "0.61136055", "0.6107523", "0.6067316", "0.60390955", "0.6009634", "0.5993658", "0.5935391", "0.5924141", "0.5879338", "0.5875901", "0.58673316", "0.5862568", "0.57577676", "0.57549715...
0.0
-1
TODO: Make this function available to all models somehow. Maybe add it to ApplicationRecord?
def get_coords(address) coords = Geocoder.search(address) location = self.location if coords.length === 0 coords = Geocoder.search(self.name) end debugger self.lat ||= coords.first.coordinates[0] self.lng ||= coords.first.coordinates[1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_class; end", "def after_save(record)\n \n end", "def model_name; end", "def model_name; end", "def related_fields(method)\n \n end", "def before_update_save(record); end", "def orm_patches_applied; end", "def before_save(sender); end", "def before_create_save(record); end", ...
[ "0.607274", "0.59070873", "0.5874809", "0.5874809", "0.5852584", "0.58442867", "0.5819886", "0.58083105", "0.5755825", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.5644574", "0.5...
0.0
-1
END View/Controller Stuff BEGIN OTrunk/Data Utilities
def otCreate(rconstant, &block) otObj = $otObjectService.createObject(rconstant.java_class) yield otObj otObj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def get_data()\t\n\tend", "def display_data_universe\n\n end", "def main_troopda...
[ "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.5811213", "0.57824266", "0.56300616", "0.5572082", "0.5563232", "0.5553046", "0.5553046", "0.5495474", "0.5488229", ...
0.0
-1
END OTrunk/Data Utilities BEGIN Misc. Utilities
def avg(list) list.inject(0) { |sum, e| sum + e } / list.length.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trd; end", "def private; end", "def operations; end", "def operations; end", "def get_data()\t\n\tend", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def da...
[ "0.61586803", "0.6146449", "0.60834986", "0.60834986", "0.5680337", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.5653207", "0.5653207", "0.5633895", "...
0.0
-1
can add more datasets as support becomes available
def initialize(api_key, options = {}) raise ArgumentError, "You must set an api_key." unless api_key # Use RestClient directly to determine the validity of the API Key path = "http://api.census.gov/data/2010/sf1?key=#{api_key}&get=P0010001&for=state:01" response = RestClient.get(path) if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datasets\n @datasets || []\n end", "def datasets\n @datasets || []\n end", "def uses(*datasets)\n @used_datasets = datasets\n end", "def set_datasets\n @datasets = current_user.get_datasets 'all'\n\n @metadata_array = []\n @metadata_array = Dataset.get_metadata_list(@...
[ "0.6455594", "0.6455594", "0.64135355", "0.63395333", "0.6231442", "0.61922234", "0.6170293", "0.608951", "0.60767317", "0.6069225", "0.6061368", "0.60588247", "0.6057436", "0.60275024", "0.5948483", "0.58938587", "0.5854952", "0.57962847", "0.5788733", "0.5782818", "0.577197...
0.0
-1
define the binary tree data by reading the contents of an array. Overwrites exisitng data if called on an existing tree. Considers an empty tree (root = nil) to not contain 'nil' Assumes all items in the data array are of similar, or compatible, data type.
def build_tree(data_array) @root = nil # overwrites tree, even if array is empty data_array.each_with_index do |data, index| if index == 0 @root = Node.new(data) else set_next_node(data) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def build_tree(array)\n\t\t@root_nod...
[ "0.7098929", "0.70791733", "0.6836663", "0.68199146", "0.67296803", "0.66995484", "0.6675161", "0.65784395", "0.6575065", "0.6522355", "0.64704555", "0.6445603", "0.6444982", "0.6413812", "0.6316787", "0.63120574", "0.63006896", "0.627045", "0.6244209", "0.62240076", "0.62186...
0.76057476
0
Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def breadth_first_search(data) queue = [@root] node_match = nil match_found = false until queue.empty? || match_found || @root.nil? cur_node = queue.first if cur_node.value == data match_found = true node_match = cur_node else queue.push(cur_node.left_child) unl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\...
[ "0.82784593", "0.8275606", "0.8269769", "0.82460755", "0.8243444", "0.82096183", "0.8159495", "0.81193894", "0.81172967", "0.80881375", "0.80769527", "0.8070723", "0.8068296", "0.8062668", "0.8058313", "0.8056598", "0.80003446", "0.79880637", "0.7985552", "0.79556835", "0.795...
0.7376877
35
Same method as breadth_first_search, but with debugging output that lists the number nodes visited, and the actual order visited. Note: Handles case where data searched for and tree are not the same type
def breadth_first_search_with_debug(data) search_order = [] # For Debug output queue = [@root] node_match = nil match_found = false until queue.empty? || match_found || @root.nil? cur_node = queue.first next_node_value = cur_node.nil? ? "nil" : cur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.n...
[ "0.7347308", "0.6729006", "0.662765", "0.65168625", "0.6457625", "0.6426889", "0.64240444", "0.6405202", "0.6271761", "0.626424", "0.62619036", "0.6259853", "0.6248911", "0.62266546", "0.62127036", "0.6198458", "0.6155168", "0.61439085", "0.6132902", "0.61186343", "0.6074785"...
0.7838283
0
Iterative PreOrder depthfirst search (Parent > Left Child > Right Child) Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def depth_first_search_pre_order(data) stack = [@root] node_match = nil match_found = false until stack.empty? || match_found || @root.nil? cur_node = stack.pop if cur_node.value == data match_found = true node_match = cur_node end right = cur_node.right_child ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left chil...
[ "0.8119697", "0.7890585", "0.7884613", "0.78070575", "0.7770379", "0.7769602", "0.77549934", "0.7731764", "0.77259016", "0.77247083", "0.7719595", "0.77187645", "0.76705396", "0.7649889", "0.7642115", "0.7638175", "0.76211554", "0.7618138", "0.75921905", "0.7591433", "0.75731...
0.84809583
0
Same method as depth_first_search_pre_order (iterative), but with debugging output that lists the number nodes visited, and the actual order visited. Note: Handles case where data searched for and tree are not the same type
def depth_first_search_pre_order_with_debug(data) search_order = [] # For Debug output stack = [@root] node_match = nil match_found = false until stack.empty? || match_found || @root.nil? cur_node = stack.pop next_node_value = cur_node.nil? ? "nil" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ?...
[ "0.7068602", "0.6529732", "0.6499556", "0.6468799", "0.64642525", "0.64460623", "0.6432414", "0.6365465", "0.63020855", "0.62877464", "0.62871575", "0.6270008", "0.6225689", "0.6198207", "0.6187993", "0.6116962", "0.6110345", "0.6089103", "0.60853326", "0.6075992", "0.6073185...
0.8022904
0
Recursive PreOrder depthfirst search (Parent > Left Child > Right Child) Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def dfs_rec(data, cur_node = @root) node_match = nil # no match possible if node is 'nil' unless cur_node.nil? # check for match if cur_node.value == data node_match = cur_node else # check for matches along each child path ('nil' returned = no match found) unless c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node....
[ "0.83905023", "0.81256664", "0.8081075", "0.8005304", "0.79382217", "0.79340684", "0.7888093", "0.78857064", "0.7880151", "0.78092194", "0.77895653", "0.7789275", "0.7777955", "0.7769718", "0.77675", "0.77390414", "0.77325255", "0.77277493", "0.7727203", "0.77218056", "0.7718...
0.6699696
42
Note: alternative version of recursive depthfirst search, but can only be used if the tree is all of the same data type (ie; can't compare strings and integers using '>' or "<", but you can compare integers and floats...that's why I implemented as above...). Would have to preformat arrays used to create the binary tree...
def show_binary_tree text = tree_levels_text_array puts "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" puts "\nBinary Tree Display:\n " text.each { |row| puts "\n" + row } puts "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper...
[ "0.7087236", "0.6803723", "0.6554015", "0.654651", "0.65244675", "0.65088713", "0.6485999", "0.64475465", "0.6445219", "0.64397174", "0.64328563", "0.64007485", "0.6398177", "0.63844514", "0.6377408", "0.63551474", "0.632815", "0.6294613", "0.62916875", "0.62847054", "0.62701...
0.0
-1
Creates a new node in the Binary Tree by tracing path from Root. new nodes with data value less than parent are placed along left_child path
def set_next_node(data) data_placed = false temp = @root until data_placed if data == temp.value data_placed = true elsif data < temp.value if temp.left_child.nil? temp.left_child = Node.new(data, temp) data_placed = true else temp = temp.lef...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_left_child\n # Guard condition for movement not possible\n return nil if blank_x + 1 == size\n\n # Make the movement\n new_state = swap_left\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node....
[ "0.6684141", "0.6645556", "0.63360727", "0.6290818", "0.626753", "0.62021494", "0.6194916", "0.61836714", "0.61578786", "0.6120916", "0.6091174", "0.60829717", "0.6071566", "0.6020305", "0.6007758", "0.5987953", "0.59781754", "0.5967891", "0.5957147", "0.5949755", "0.5942498"...
0.54446495
91
Builds an array of text to print binary tree. Each array position is a row of text that represents one level of the tree. Position 0 is level 0 (toplevel, or Root), Position 1 is level 1, etc... (Uses fact that there are 2^n nodes in each level "n", level 0 = root level) This really only works well for smaller trees. T...
def tree_levels_text_array text_rows = [] num_levels = num_tree_levels # set string size for spacing and "nil" nodes (with default if tree too big) max_length = (num_levels > 4) ? 2 : max_node_value_length blank_node = "_" * max_length # text for nil nodes cell_pad = " " * max_length # text ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end", "def draw_t...
[ "0.7588622", "0.6982911", "0.64528465", "0.63787144", "0.63711566", "0.6337727", "0.6287795", "0.62840784", "0.62748057", "0.6244077", "0.62364006", "0.6231077", "0.6226879", "0.61911505", "0.61880326", "0.6178838", "0.6178838", "0.6136494", "0.6130256", "0.60903126", "0.6088...
0.83797944
0
Returns an array of all node values in breadthfirst search order. Includes 'nil' nodes, such that the array is a representation of the tree as a complete binary tree (even if the actual binary tree is NOT complete)
def all_node_values_with_nil tree_nodes = [] queue = [@root] queue_all_nil = false # continue adding all child nodes to queue until it contains only nil nodes until queue_all_nil cur_node = queue.first next_value = cur_node.nil? ? nil : cur_node.value tree_nodes << next_value ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end", "def breadth_first\n ...
[ "0.7739973", "0.7470075", "0.7301787", "0.7235261", "0.7193675", "0.715518", "0.7110694", "0.70759076", "0.7072268", "0.6938686", "0.69078094", "0.6819643", "0.67454106", "0.6710788", "0.66445833", "0.66087765", "0.65865344", "0.6582494", "0.6518734", "0.6475558", "0.6470963"...
0.7706944
1
Returns the number of levels in the binary tree
def num_tree_levels level = 0 num_nodes= all_node_values_with_nil.length # considers tree as 'complete num_nodes_in_full_tree = 2**level until num_nodes_in_full_tree >= num_nodes level += 1 num_nodes_in_full_tree += 2**level end num_tree_levels = level + 1 # (started count at 0)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length\n @tree.length\n end", "def level\n root? ? 0 : ancestors.count\n end", "def leaf_count\n @leaf_count\n end", "def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.le...
[ "0.7820029", "0.75637954", "0.73583835", "0.73572165", "0.73358834", "0.7318168", "0.7289695", "0.72789776", "0.7276516", "0.72135735", "0.713046", "0.7125948", "0.7125948", "0.7102207", "0.70956147", "0.70953685", "0.7085641", "0.70844376", "0.7083465", "0.70783395", "0.7041...
0.8804443
0
Returns the length of string for the node whose string representation is the longest among all nodes in the tree
def max_node_value_length max_length = 0 all_node_values_with_nil.each do |value| value_length = value.to_s.length max_length = value_length if value_length > max_length end return max_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_string_length\n longest_string.size\n end", "def longest str\n\tstr.max_by(&:length)\nend", "def longest_string ar\n\tar.max_by(&:length)\nend", "def longest_string ar\n return ar.max_by(&:length)\nend", "def longest\n @strings.max { |a,b| a.length <=> b.length}\n end", "def long...
[ "0.7383232", "0.7254043", "0.71928215", "0.7162197", "0.70681995", "0.6968198", "0.6892347", "0.6880295", "0.68238384", "0.6734872", "0.67140096", "0.6706588", "0.67043746", "0.66891026", "0.6689079", "0.65879536", "0.6586231", "0.6578444", "0.6574343", "0.65297693", "0.65258...
0.6904298
6