query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
POST /review_images POST /review_images.json
def create @review_image = ReviewImage.new(params[:review_image]) respond_to do |format| if @review_image.save format.html { redirect_to @review_image, notice: 'Review image was successfully created.' } format.json { render json: @review_image, status: :created, location: @review_image } ...
[ "def create\n @add_image_to_review = AddImageToReview.new(add_image_to_review_params)\n\n respond_to do |format|\n if @add_image_to_review.save\n format.html { redirect_to @add_image_to_review, notice: 'Add image to review was successfully created.' }\n format.json { render :show, status: :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /review_images/1 PUT /review_images/1.json
def update @review_image = ReviewImage.find(params[:id]) respond_to do |format| if @review_image.update_attributes(params[:review_image]) format.html { redirect_to @review_image, notice: 'Review image was successfully updated.' } format.json { head :no_content } else format....
[ "def update\n respond_to do |format|\n if @add_image_to_review.update(add_image_to_review_params)\n format.html { redirect_to @add_image_to_review, notice: 'Add image to review was successfully updated.' }\n format.json { render :show, status: :ok, location: @add_image_to_review }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /review_images/1 DELETE /review_images/1.json
def destroy @review_image = ReviewImage.find(params[:id]) @review_image.destroy respond_to do |format| format.html { redirect_to review_images_url } format.json { head :no_content } end end
[ "def destroy\n @add_image_to_review.destroy\n respond_to do |format|\n format.html { redirect_to add_image_to_reviews_url, notice: 'Add image to review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @shop_review_image = ShopReviewImage.find(pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function to extract the line of the config that specified the operation. Useful in printing helpful error messages
def get_config_line(call_history) call_history.first.split(':in').first end
[ "def get_config( rqst = nil )\r\n scope = \"show configuration\"\r\n scope.concat( \" \" + rqst ) if rqst\r\n begin\r\n @ndev.rpc.command( scope, :format => 'text' ).xpath('configuration-output').text\r\n rescue NoMethodError\r\n # indicates no configuration found\r\n nil\r\n rescue =>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DSL method to specify a component. Expects a name, specification, and set of component specific options, that must be marshallable into the database (i.e. should all be strings)
def component(component_name, component_specification, component_options={}) @current_shard[:components] << { :name => component_name, :specification => component_specification.to_s, :options => component_options, :config_line => get_config_line(caller) } end
[ "def specify(name=:default, &specification)\n if @@specifications[name]\n @@specifications[name].blat(&specification)\n @@specifications[name]\n else\n @@specifications[name] = Specification.new(name, &specification)\n end\n end", "def to_component\n trans = TransObject...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DSL method to specify a connection between a component/output_port and another component/input_port. The component/port specification is a string where the names of the two elements are separated by '', and the "connection" is specified by a Ruby Hash, i.e.: connect 'componentAoutput' => 'componentBinput' Array ports a...
def connect(connection_hash) config_file_line = get_config_line(caller) connection_hash.each do |output_string, input_string| output_component_name, output_port_name, output_port_key = parse_connection_string(output_string) input_component_name, input_port_name, input_port_key = pars...
[ "def process_connection_spec(connection_spec)\n RFlow.logger.debug \"Found connection from '#{connection_spec[:output_string]}' to '#{connection_spec[:input_string]}', creating\"\n\n # an input port can be associated with multiple outputs, but\n # an output port can only be associated with one ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Iterates through each shard specified in the DSL and creates rows in the database corresponding to the shard and included components
def process_shard_specs @shard_specs.each do |shard_spec| RFlow.logger.debug "Found #{shard_spec[:type]} shard '#{shard_spec[:name]}', creating" shard_class = case shard_spec[:type] when :process RFlow::Configuration::ProcessShard ...
[ "def init_shards\n for i in 0..@number_of_shards-1 do\n @session.execute(@init_shard_stmt, @name, i)\n @logger.info(\"Create shard control row for queue #{@name}, shard #{i}\")\n end\n end", "def build_node_content_databases\n # NOTE: we will have to refresh those then we are re-assigned sha...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Iterates through each component specified in the DSL and uses 'process_connection' to insert all the parts of the connection into the database
def process_connection_specs connection_specs.each do |connection_spec| process_connection_spec(connection_spec) end end
[ "def connect_components!\n RFlow.logger.debug \"Connecting components\"\n components.each do |component|\n RFlow.logger.debug \"Connecting component '#{component.name}' (#{component.uuid})\"\n component.connect!\n end\n end", "def setup_connection(conn)\n conn ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For the given connection, break up each input/output component/port specification, ensure that the component already exists in the database (by name). Also, only supports ZeroMQ ipc sockets
def process_connection_spec(connection_spec) RFlow.logger.debug "Found connection from '#{connection_spec[:output_string]}' to '#{connection_spec[:input_string]}', creating" # an input port can be associated with multiple outputs, but # an output port can only be associated with one input ...
[ "def find_or_create_input_port_if_necessary(port)\n find_or_create_port_if_necessary(:input, port)\n end", "def connect!\n input_ports.each do |input_port|\n input_port.connect!\n\n # Create the callbacks for recieving messages as a proc\n input_port.keys.each do |input_port_key|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /forums/1 PUT /forums/1.json
def update respond_to do |format| if @forum.update(forum_params) format.html { redirect_to forums_path, notice: t('.success') } format.json { render :show, status: :ok, location: @forum } else format.html { render :edit } format.json { render json: @forum.errors, status: ...
[ "def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\r\n @forum = Forum.find(params[:id])\r\n respond_to do |format|\r\n if @forum.update(forum_params)\r\n\r\n format.json { render :show, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method called to check if player is done (ie have they reached 0 lives)
def done @lives <= 0 end
[ "def lives_checker\n if (player_1.lives == 0 || player_2.lives == 0)\n self.game_over\n else\n puts \"------NEW ROUND------\"\n self.start_game\n end\n end", "def finished?\n\n @players.each do |current_player|\n return true if current_player.position >= @length\n end\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Used to compare replica activity to master. Raises exception if it does not match.
def activity_database_matches_self?(replica_host) # Save a beaker host_hash[:vmhostname], set it to the supplied host_name param, # and then set it back to the original at the end of the ensure. The :vmhostname #overrides the host.hostname, and nothing should win out over it. original_ho...
[ "def check_replication\n secondary_states = ReplicaResult.all(@connection)\n master_state = @connection.execute(MASTER_LOG_LOCATION_QUERY)\n\n report!(secondary_states, master_state)\n end", "def reconfiguring_replica_set?\n err = details[\"err\"] || details[\"errmsg\"] || details[\"$err\"] || \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calculate fitting DP, Equipment DP, Control Valve DP, Orifice DP
def calculate_and_save_delta_ps fittings = PipeSizing.fitting1 orifice_id = nil fittings.each {|item| orifice_id = item[:id] if item[:value] == 'Orifice' } orifice_dp = self.discharge_circuit_piping.sum(:delta_p, :conditions => ['fitting = ? ', orifice_id]) #calculate flow elements sum flow_elem...
[ "def calculate_and_save_delta_ps\n\t #assuming 51 for fitting type orifice\n\t orifice_dp = self.hydraulic_turbine_circuit_pipings.sum(:delta_p, :conditions => ['fitting = ? ', 51])\n\t #assuming 49 for fitting type equipment\n\t equipment_dp = self.hydraulic_turbine_circuit_pipings.sum(:delta_p, :conditions =>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
generate remomve_constraint list file
def remove_const file_name = @dir + "remove_const_list.txt" printf("@I:generate %s\n",file_name) f = open("#{file_name}","w") comment = "Removed constraint list" Common.print_file_header(f,"#{comment}",$TOOL,$VERSION,"##") i = 0 @attribute_all.each{|attribute_name,data| data[1].ea...
[ "def constraint_list\n list = []\n list << @nolong\n list << @wsp\n list << @ml\n list << @mr\n list << @idstress\n list << @idlength\n list << @culm\n list\n end", "def permutation_constraints\n items = (1..@size).to_a.join \", \"\n lines = [\"Set = [...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Synplify Rpt error report
def rpt_error(error_list) file_name = @dir + "rpt_error_list.txt" printf("@I:generate %s\n",file_name) f = open("#{file_name}","w") comment = "Error attribute list refferd from Synplify Rpt file" Common.print_file_header(f,"#{comment}",$TOOL,$VERSION,"##") print_synplify_rpt(f,error_list) ...
[ "def analysis_errors; end", "def srr_error(error_list)\n file_name = @dir + \"srr_error_list.csv\"\n printf(\"@I:generate %s\\n\",file_name)\n f = open(\"#{file_name}\",\"w\")\n comment = \"Error attribute list refferd from Synplify Srr file\" \n Common.print_file_header(f,\"#{comment}\",$TOOL,$VER...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Synplify Srr error report
def srr_error(error_list) file_name = @dir + "srr_error_list.csv" printf("@I:generate %s\n",file_name) f = open("#{file_name}","w") comment = "Error attribute list refferd from Synplify Srr file" Common.print_file_header(f,"#{comment}",$TOOL,$VERSION,"##") print_synplify_srr(f,error_list) ...
[ "def format_error(err) Ripl::Runner.format_error(err) end", "def lookup_all_error; end", "def rpt_error(error_list)\n file_name = @dir + \"rpt_error_list.txt\"\n printf(\"@I:generate %s\\n\",file_name)\n f = open(\"#{file_name}\",\"w\")\n comment = \"Error attribute list refferd from Synplify Rpt fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /api/v1/quizzes/:id/questions Return [Array] The questions belongs to Quiz
def get_questions result = QuizQuestion.includes(:quiz_answers).where(quiz_id: params[:id]) @questions = result.map { |question| QuestionPresenter.new(question) } end
[ "def index\n @quizzes_answers = Quizzes::Answer.all\n end", "def questions\n self.class.get('/2.2/questions', @options)\n end", "def index\n \n ####\n # TODO: It might be more efficient to load all the quizzes in memory first\n # and then construct different arrays instead of using m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
state if they are happy and/or clean The clean? and happy? methods are pretty similiar: they should return true if the happiness or hygiene points exceed seven. Otherwise they should return false.
def happy? if @happiness > 7 return true else false end end
[ "def happy?\n # if happiness > 7\n # true\n # else\n # false\n # end\n happiness > 7\n end", "def happy?\n happiness > 7\n end", "def happy?\n @happiness > 7 \n end", "def hungry?\n if @hungry\n puts \"I'm hungry!\"\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /funnies POST /funnies.json
def create @funny = current_user.funnies.build(funny_params) respond_to do |format| if @funny.save format.html { redirect_to @funny, notice: 'Funny was successfully created.' } format.json { render :show, status: :created, location: @funny } else format.html { render :new } ...
[ "def create\n @funny = current_user.funnies.new(params[:funny])\n respond_to do |format|\n if @funny.save\n format.html { redirect_to @funny, notice: 'Funny was successfully created.' }\n format.json { render json: @funny, status: :created, location: @funny }\n else\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the disc instance in position(row, col)
def [](row, col) get_disc(row, col) end
[ "def get_disc(row, col)\n @board[row * @size + col]\n end", "def [](pos)\n row,col=pos[0],pos[1]\n @grid[row][col]\n end", "def get_position row, col\n return @matrix[row][col]\n end", "def cell_at(position)\n return self.cells_by_position[position]\n end", "def get_item...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the disc instance in position(row, col)
def get_disc(row, col) @board[row * @size + col] end
[ "def [](row, col)\n get_disc(row, col)\n end", "def [](pos)\n row,col=pos[0],pos[1]\n @grid[row][col]\n end", "def get_position row, col\n return @matrix[row][col]\n end", "def cell_at(position)\n return self.cells_by_position[position]\n end", "def get_item(x, y)\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Commits tax transaction to avalara when order is finalized.
def finalize_with_avalara_tax! finalize_without_avalara_tax! avalara_tax_transaction.commit end
[ "def finalize_transaction(type='purchase')\n self.save\n self.user.make_paid! if (!user.nil? && user.persisted?)\n self.transactions.create(action:type, amount: self.price_in_cents, response: self.purchase_response)\n end", "def finalize(reimbursement)\n if !SpreeAvatax::Config.enabled\n log...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If the shipping address changes we want to update tax.
def ship_address_tax_update if ship_address and (ship_address_id_changed? or ship_address.changed?) create_avalara_tax_adjustment end end
[ "def apply_tax\n rate = case addresses.detect {|a| a.address_type == 'shipping' }.region\n when 'KY' then 0.06\n when 'IL' then 0.0625\n when 'CA' then 0.0725\n else 0\n end\n\n # Shipping N/A if this is an order quote (in which case the shipping address is blank).\n self.shipping_pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
using the comment_params which we get from a form to create a new comment, switching its profile_id to the user who is currently signed in (and posting the comment). after that, if the comment is valid, it saves and we are redirected to the home page if not, we get redirected to profiles index
def create @comment = Comment.new(comment_params) if user_signed_in? @comment.profile_id = Profile.find_by(user_id: current_user.id).id end if @comment.save redirect_to '/', :notice => "Comment posted." else flash[:alert] ="Problem occured while commenting." redirect_to '/pro...
[ "def associate_comment_with_user_at_sign_in_up\n if session[:comment_tracking_number].present?\n comment = Comment.where(\n :user_id => nil,\n :comment_tracking_number => session[:comment_tracking_number]\n ).first\n else\n comment = Comment.where(\n :user_id => nil,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /boiler_plates GET /boiler_plates.xml
def index @boiler_plates = BoilerPlate.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @boiler_plates } end end
[ "def show\n @boiler_plate = BoilerPlate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @boiler_plate }\n end\n end", "def new\n @boiler_plate = BoilerPlate.new\n\n respond_to do |format|\n format.html # new.html.erb\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /boiler_plates/1 GET /boiler_plates/1.xml
def show @boiler_plate = BoilerPlate.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @boiler_plate } end end
[ "def index\n @boiler_plates = BoilerPlate.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boiler_plates }\n end\n end", "def new\n @boiler_plate = BoilerPlate.new\n\n respond_to do |format|\n format.html # new.html.erb\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /boiler_plates/new GET /boiler_plates/new.xml
def new @boiler_plate = BoilerPlate.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @boiler_plate } end end
[ "def create\n @boiler_plate = BoilerPlate.new(params[:boiler_plate])\n\n respond_to do |format|\n if @boiler_plate.save\n flash[:notice] = 'BoilerPlate was successfully created.'\n format.html { redirect_to(@boiler_plate) }\n format.xml { render :xml => @boiler_plate, :status => :cr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /boiler_plates POST /boiler_plates.xml
def create @boiler_plate = BoilerPlate.new(params[:boiler_plate]) respond_to do |format| if @boiler_plate.save flash[:notice] = 'BoilerPlate was successfully created.' format.html { redirect_to(@boiler_plate) } format.xml { render :xml => @boiler_plate, :status => :created, :loca...
[ "def new\n @boiler_plate = BoilerPlate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boiler_plate }\n end\n end", "def create\n @boiler = Boiler.new(boiler_params)\n\n respond_to do |format|\n if @boiler.save\n format.html { redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /boiler_plates/1 PUT /boiler_plates/1.xml
def update @boiler_plate = BoilerPlate.find(params[:id]) respond_to do |format| if @boiler_plate.update_attributes(params[:boiler_plate]) flash[:notice] = 'BoilerPlate was successfully updated.' format.html { redirect_to(@boiler_plate) } format.xml { head :ok } else ...
[ "def create\n @boiler_plate = BoilerPlate.new(params[:boiler_plate])\n\n respond_to do |format|\n if @boiler_plate.save\n flash[:notice] = 'BoilerPlate was successfully created.'\n format.html { redirect_to(@boiler_plate) }\n format.xml { render :xml => @boiler_plate, :status => :cr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /boiler_plates/1 DELETE /boiler_plates/1.xml
def destroy @boiler_plate = BoilerPlate.find(params[:id]) @boiler_plate.destroy respond_to do |format| format.html { redirect_to(boiler_plates_url) } format.xml { head :ok } end end
[ "def destroy\n @boiler = Boiler.find(params[:id])\n @boiler.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_boilers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_bare = PhotoBare.find(params[:id])\n @photo_bare.destroy\n\n respond...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ABCDEFGH and PAPORODPPEEGH is ADEGH Solution ================================================ 1Recursive approach if last char of a == last char of b lcs = 1 + lcs(a[0..size1], b[0..size1]) else lcs = max (
def lcs(a,b) return "" if a.size==0 || b.size==0 if (a.size == 1 || b.size == 1) return (a[a.size-1] == b[b.size-1]) ? "#{a[a.size-1]}" : "" end #LCS with one char less and add 1 for the last char return "#{a[a.size-1]}" + lcs(a[0..a.size-2], b[0..b.size-2]) if a[a.size-1] == b[b.size-1] lcs_1 = lcs(a...
[ "def lcs(string, other_string)\n if string.length == 0 || other_string.length == 0\n ''\n elsif string[-1] == other_string[-1]\n lcs(string[0..-2], other_string[0..-2]) + string[-1]\n else\n [\n lcs(string[0..-2], other_string),\n lcs(string, other_string[0..-2])\n ].max\n end\nend", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
after a partial is rendered
def after_partial_setup(view) end
[ "def after_render_template\n end", "def after_rendering( state=nil )\n\t\t# Nothing to do\n\t\treturn nil\n\tend", "def after_render(&block)\n @after_render_block = block\n end", "def render_partial(context, options, &block); end", "def render_partial(*args, **kwargs); end", "def after_view_setup\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
after a complete view is rendered
def after_view_setup end
[ "def after_rendering( state=nil )\n\t\t# Nothing to do\n\t\treturn nil\n\tend", "def visual_rendering_finished\n end", "def after_partial_setup(view)\n end", "def after_render_template\n end", "def after_create_view\n\t\t\treturn true\n\t\tend", "def after_render(&block)\n @after_render_block ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO: make it using respond_to?(:ps_skip_sync?) before preparing data to sync
def ps_skip_sync?(_action) false end
[ "def old_sync; end", "def no_sync!\n @no_sync = true\n end", "def syncAllPs()\n sync() ;\n eachPs(){|_ps|\n _ps.reload() ;\n }\n end", "def sync() end", "def sync=(*) end", "def salesforce_skip_sync?\n return true if ::SfDbSync.config[\"SYNC_ENABLED\"] == false\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests loading all valid png files in the suite that are supported for saving as bmp, saving them as bmp, loading the resaved images and comparing them pixelwise.
def test_load_save_load_valid_png_files_as_bmp each_file_with_updated_info do |file_path| #Valid color image with bit depth less than 16 and no transparency if @test_feature != "x" && @bit_depth != 16 && @test_feature != "t" && (@color_type_desc == "c" || @color_type_desc == "p") ...
[ "def test_load_valid_png_files\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature != \"x\"\n\n #Reading valid png files should not raise any exception\n assert_nothing_raised do\n Imgrb::Image.new(file_path)\n end\n\n img = Imgrb::Image.new(file_p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the timetable for the course an instance was initialised with. Returns: A timetable for a course.
def get_timetable @timetable_parser.get_timetable_for_course(@courseCode, @year) end
[ "def timetable\n @today = Date.today\n @time_table = TimeTable.time_table_date(@today)\n end", "def timetable_info\n end", "def timetable_for_class( school_class )\n Timetable.select{|t| t.school_class == school_class }.to_a\n end", "def core_timetable(course_code)\n Tableau::TimetableP...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /producto_platillos POST /producto_platillos.json
def create combo_producto combo_platillo @producto_platillo = ProductoPlatillo.new(producto_platillo_params) respond_to do |format| if @producto_platillo.save format.html { redirect_to @producto_platillo, notice: 'El Detalle del Platillo Fue Creado Exitosamente.' } format.json { r...
[ "def create\n @producto_plato = ProductoPlato.new(producto_plato_params)\n\n respond_to do |format|\n if @producto_plato.save\n format.html { redirect_to @producto_plato, notice: 'Producto plato was successfully created.' }\n format.json { render :show, status: :created, location: @producto...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /producto_platillos/1 PATCH/PUT /producto_platillos/1.json
def update respond_to do |format| if @producto_platillo.update(producto_platillo_params) format.html { redirect_to @producto_platillo, notice: 'El Detalle del Platillo Fue Actualizado Exitosamente.' } format.json { render :show, status: :ok, location: @producto_platillo } else fo...
[ "def update\n respond_to do |format|\n if @producto_plato.update(producto_plato_params)\n format.html { redirect_to @producto_plato, notice: 'Producto plato was successfully updated.' }\n format.json { render :show, status: :ok, location: @producto_plato }\n else\n format.html { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /producto_platillos/1 DELETE /producto_platillos/1.json
def destroy combo_producto combo_platillo @producto_platillo.destroy respond_to do |format| format.html { redirect_to producto_platillos_url, notice: 'El Detalle del Platillo Fue Eliminado Exitosamente.' } format.json { head :no_content } end end
[ "def destroy\n @producto_plato.destroy\n respond_to do |format|\n format.html { redirect_to producto_platos_url, notice: 'Producto plato was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto_ofertado.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fixtures/1 GET /fixtures/1.json
def show @fixtures = Fixture.all @fixture = Fixture.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @fixture } end end
[ "def show\n @fixture = Fixture.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @fixture }\n end\n end", "def index\n @fixtures = Fixture.all\n\n respond_to do |format|\n format.json { render json: @fixtures }\n end\n end", "def show\n @fixture = Fixture...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /fixtures/1 DELETE /fixtures/1.json
def destroy @fixture = Fixture.find(params[:id]) @fixture.destroy respond_to do |format| format.html { redirect_to fixtures_url } format.json { head :no_content } end end
[ "def destroy\n @admin_fixture.destroy\n respond_to do |format|\n format.html { redirect_to admin_fixtures_url, notice: 'Fixture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fixturestat = Fixturestat.find(params[:id])\n @fixturestat.destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get the level of the entity
def level @level || Helpers.char_level(@entity) end
[ "def level\n return @level\n end", "def level\n @level\n end", "def level\n parent_id.nil? ? 0 : compute_level\n end", "def level\n if self.class.column_names.include?('level')\n super\n else\n tree_level\n end\n end", "def le...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a value from the range based on the level of the entity. Examples: level 1 entity, will get the minimum sandbox = Sandbox.new(some_level_1_entity) sandbox.by_level(13..30, max_at: 65) => 13 level 65 entity, will get the maximum sandbox = Sandbox.new(some_level_65_entity) by_level(13..30, max_at: 65) => 60
def by_level(range, max_at:) level >= max_at ? range.last : range.first + (((range.size - 1)/max_at.to_f)*level).to_i end
[ "def current_level_range\n Range.new(@data['currentLevel']['minPoints'], @data['currentLevel']['maxPoints'])\n end", "def max_level\n lookup_stat(\"Level:\").last\n end", "def find_level\n level = 0\n max_value = max_number_of_a_level(level)\n while max_value < input\n level += 1\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /proforma_invoices GET /proforma_invoices.json
def index @proforma_invoices = ProformaInvoice.all.paginate(page: params[:page], per_page: 15) end
[ "def show_invoices\n data = {\n invoices: @subscription.invoices\n }\n\n render json: data\n end", "def index\n @invoices = Invoice.all\n\n render json: @invoices\n end", "def index\n @invoices = @project.invoices\n\n respond_to do |format|\n format.html # index.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /proforma_invoices POST /proforma_invoices.json
def create @proforma_invoice = ProformaInvoice.new(proforma_invoice_params) respond_to do |format| if @proforma_invoice.save format.html { redirect_to @proforma_invoice, notice: 'Proforma invoice was successfully created.' } format.json { render :show, status: :created, location: @proform...
[ "def create\n @invoice = Invoice.new(invoice_params)\n\n if @invoice.save\n render json: @invoice, status: :created, location: @invoice\n else\n render json: @invoice.errors, status: :unprocessable_entity\n end\n end", "def invoice(options = nil)\n request = Request.new(@client)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /proforma_invoices/1 PATCH/PUT /proforma_invoices/1.json
def update respond_to do |format| if @proforma_invoice.update(proforma_invoice_params) format.html { redirect_to @proforma_invoice, notice: 'Proforma invoice was successfully updated.' } format.json { render :show, status: :ok, location: @proforma_invoice } else format.html { ren...
[ "def update\n @invoice = Invoice.find(params[:id])\n\n if @invoice.update(invoice_params)\n head :no_content\n else\n render json: @invoice.errors, status: :unprocessable_entity\n end\n end", "def update\n\n respond_to do |format|\n if @invoiceline.update(invoiceline_params)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /proforma_invoices/1 DELETE /proforma_invoices/1.json
def destroy @proforma_invoice.destroy respond_to do |format| format.html { redirect_to proforma_invoices_url, notice: 'Proforma invoice was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_co}\n end\n end", "def destroy\n # @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loop through reader infos
def parse_reader_infos(reader_infos) reader_infos.each do |reader_info| process_emails(reader_info) end end
[ "def read_items\n i = 0\n headers = true\n read_rows do |row|\n if i == 0 && headers\n headers = false\n next\n end\n i+= 1\n yield row, i if block_given?\n end\n end", "def iterate(callbacks = {}) # rubocop:disable PerceivedComplexity, CyclomaticComplexity\n @r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Only process reader_infos with email enabled
def process_emails(reader_info) notifications = reader_info.notifications notifications.each do |notification| case notification[:notification_type] when "email" send_email(reader_info) if notification[:checked] when "internal" send_internal(reader_info) if notification[:c...
[ "def parse_reader_infos(reader_infos)\n reader_infos.each do |reader_info|\n process_emails(reader_info)\n end\n end", "def email_list \n self.readers.map do |reader|\n \"#{reader.email}; \"\n end\n end", "def email_parse(influencer)\n r = Regexp.new(/\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Stubs out RefernetService class with fake API responses
def stub_refernet_service(*methods) # Categories allow_any_instance_of(RefernetService) .to receive(:get_categories) .and_return(REFERNET_RESPONSES[:categories]) # SubCategories allow_any_instance_of(RefernetService) .to receive(:get_sub_categories) .with("T...
[ "def stub_responses\n Creditsafe::Api::DummyResponse.new\n end", "def request_stub; end", "def stub_eventbrite_event_get\n mock_event = { name: { text: 'test' }, ticket_classes: [ { id: '1234', name: 'test', free: true, hidden: true }]}\n response = double('Yay!', to_hash: {\"Status\" => [\"200 OK...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /estados_civiles/1 GET /estados_civiles/1.xml
def show @estados_civil = EstadosCivil.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @estados_civil } end end
[ "def show\n @estado_civil = EstadoCivil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estado_civil }\n end\n end", "def index\n @estados_civiles = EstadosCivil.search(params[:search], params[:page])\n end", "def new\n @estad...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /estados_civiles/new GET /estados_civiles/new.xml
def new @estados_civil = EstadosCivil.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @estados_civil } end end
[ "def new\n @estado_civil = EstadoCivil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estado_civil }\n end\n end", "def new\n @civilite = Civilite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /estados_civiles POST /estados_civiles.xml
def create @estados_civil = EstadosCivil.new(params[:estados_civil]) respond_to do |format| if @estados_civil.save flash[:notice] = 'EstadosCivil was successfully created.' format.html { redirect_to(@estados_civil) } format.xml { render :xml => @estados_civil, :status => :created...
[ "def create\n @estados_civil = EstadosCivil.new(estados_civil_params)\n\n respond_to do |format|\n if @estados_civil.save\n format.html { redirect_to @estados_civil, notice: 'El Estado Civil se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @estados_ci...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /estados_civiles/1 PUT /estados_civiles/1.xml
def update @estados_civil = EstadosCivil.find(params[:id]) respond_to do |format| if @estados_civil.update_attributes(params[:estados_civil]) flash[:notice] = 'EstadosCivil was successfully updated.' format.html { redirect_to(@estados_civil) } format.xml { head :ok } else ...
[ "def update\n @estado_civil = EstadoCivil.find(params[:id])\n\n respond_to do |format|\n if @estado_civil.update_attributes(params[:estado_civil])\n format.html { redirect_to(@estado_civil, :notice => 'Estado civil was successfully updated.') }\n format.xml { head :ok }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /estados_civiles/1 DELETE /estados_civiles/1.xml
def destroy @estados_civil = EstadosCivil.find(params[:id]) @estados_civil.destroy respond_to do |format| format.html { redirect_to(estados_civiles_url) } format.xml { head :ok } end end
[ "def destroy\n @estado_civil = EstadoCivil.find(params[:id])\n @estado_civil.destroy\n\n respond_to do |format|\n format.html { redirect_to(estado_civils_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estagiarios = Estagiario.find(params[:id])\n @estagiarios.destroy\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
retrieve results of a job
def job_results(jobid) wait_on_status(jobid) puts "Retrieving results for job [#{jobid}]" uri = URI("http://api.idolondemand.com/1/job/result/" + jobid) uri.query = URI.encode_www_form(:apikey => $api_key) res = Net::HTTP.get_response(uri, p_addr = $proxy_host, p_port = $proxy_port) return JSON.parse(...
[ "def get_results(options={})\n all_job_results = []\n job_result_filenames = []\n unfinished_subqueries = []\n # check each job and put it there\n @jobs_in_progress.each do |job|\n job_results = job.get_results(options)\n all_job_results.push(job_results)\n job_result_f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run Sentiment Analysis on a text string
def sentiment(text) return iod_request('analyzesentiment', {:text => text, :language => $sentiment_language, :apikey => $api_key}) end
[ "def get_sentiment(text)\n Sentimentalizer.analyze(text)\n end", "def get_sentiment(text)\n\t\t@@analyzer.get_sentiment text\n\tend", "def analyze_sentiment ( text )\n\t \n\t # load the word file (words -> sentiment score)\n\t sentihash = load_senti_file ('sentiwords.txt')\n\n\t # load the symbol file (...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run Speech Analysis on a media asset
def speech_analysis(url) return iod_request('recognizespeech', {:url => url, :language => $audio_language, :apikey => $api_key}) end
[ "def apply_audio\n # TODO\n # @output.set_audio\n end", "def main_audio ; end", "def audio_rec\n\n end", "def speech; end", "def audios_test\n end", "def analyze\n #puts @results\n count = 0\n\n @results.each do |result|\n begin\n puts \"Processing SONATYPE IQ Find...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Like TOP, but CPU Find oldest timestamp and newest slice. Compare the duration, vs the total of slice.methods.all.duration That's your app's "load"
def get_app_load(slices) tstart = slices.first.timestamp tend = TruestackClient.to_timestamp(Time.now) total = slices.inject(0) do |sum, slice| sum + (slice.method_types['all']['duration'] || 0) end (total / (tend.to_f - tstart)) * 100 end
[ "def find_sorted_entries_by_timelimit(section, oldest,limit)\n # entries = record.send(section).any_of([:time.gt => e], [:start_time.gt => e]).limit(limit)\n entries = send(section).timelimit(oldest).limit(limit)\n now = Time.now\n recs = entries.to_a\n recs.sort! do |x, y|\n t1 = x.time || x.st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Description Deletes the attachment. MethodRequestType DELETE Parameters attachment_id ID of the attachement to be deleted. attachment_number Number of attachements linked to this post.
def delete Attachment.destroy(params[:id]) unless params[:id].blank? if request.delete? @attachment_count = params[:attachment_number] || 0 end
[ "def delete_attachment\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n begin\n attachment = MailAttachment.find(params[:attachment_id])\n @email = Email.find(params[:id])\n\n if attachment.email_id == @email.id\n attachment.destroy\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /plcmanuals GET /plcmanuals.json
def index @plcmanuals = Plcmanual.all end
[ "def index\n @manuals = Manual.all\n\n render json: @manuals\n end", "def index\n @manuals = Manual.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @manuals }\n end\n end", "def create\n @plcmanual = Plcmanual.new(plcmanual_params)\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /plcmanuals POST /plcmanuals.json
def create @plcmanual = Plcmanual.new(plcmanual_params) respond_to do |format| if @plcmanual.save format.html { redirect_to @plcmanual, notice: 'Plcmanual was successfully created.' } format.json { render :show, status: :created, location: @plcmanual } else format.html { ren...
[ "def create\n @manual = Manual.new(manual_params)\n\n if @manual.save\n render json: @manual, status: :created, location: @manual\n else\n render json: @manual.errors, status: :unprocessable_entity\n end\n end", "def create\n @manual = Manual.new(manual_params)\n\n respond_to do |form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /plcmanuals/1 PATCH/PUT /plcmanuals/1.json
def update respond_to do |format| if @plcmanual.update(plcmanual_params) format.html { redirect_to @plcmanual, notice: 'Plcmanual was successfully updated.' } format.json { render :show, status: :ok, location: @plcmanual } else format.html { render :edit } format.json { r...
[ "def update\n\n respond_to do |format|\n if @manual_laboratory.update_attributes(params[:manual_laboratory])\n format.html { redirect_to manual_subject_laboratories_path, notice: 'Laboratory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /plcmanuals/1 DELETE /plcmanuals/1.json
def destroy @plcmanual.destroy respond_to do |format| format.html { redirect_to plcmanuals_url, notice: 'Plcmanual was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n need_admin!\n\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do |format|\n format.html { redirect_to manuals_url }\n format.json { head :ok }\n end\n end", "def destroy\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /location_url_maps/1 GET /location_url_maps/1.json
def show @location_url_map = LocationUrlMap.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @location_url_map } end end
[ "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /location_url_maps/new GET /location_url_maps/new.json
def new @location_url_map = LocationUrlMap.new respond_to do |format| format.html # new.html.erb format.json { render json: @location_url_map } end end
[ "def new\n @location_map = LocationMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_map }\n end\n end", "def new\n @locationmap = Locationmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /location_url_maps POST /location_url_maps.json
def create @location_url_map = LocationUrlMap.new(params[:location_url_map]) respond_to do |format| if @location_url_map.save format.html { redirect_to @location_url_map, notice: 'Location url map was successfully created.' } format.json { render json: @location_url_map, status: :created,...
[ "def create\n @location_map = LocationMap.new(params[:location_map])\n\n respond_to do |format|\n if @location_map.save\n format.html { redirect_to @location_map, notice: 'Location map was successfully created.' }\n format.json { render json: @location_map, status: :created, location: @loca...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /location_url_maps/1 PUT /location_url_maps/1.json
def update @location_url_map = LocationUrlMap.find(params[:id]) respond_to do |format| if @location_url_map.update_attributes(params[:location_url_map]) format.html { redirect_to @location_url_map, notice: 'Location url map was successfully updated.' } format.json { head :no_content } ...
[ "def update\n respond_to do |format|\n if @url_map.update(url_map_params)\n format.html { redirect_to @url_map, notice: 'Url map was successfully updated.' }\n format.json { render :show, status: :ok, location: @url_map }\n else\n format.html { render :edit }\n format.json {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /location_url_maps/1 DELETE /location_url_maps/1.json
def destroy @location_url_map = LocationUrlMap.find(params[:id]) @location_url_map.destroy respond_to do |format| format.html { redirect_to location_url_maps_url } format.json { head :no_content } end end
[ "def destroy\n @location_map = LocationMap.find(params[:id])\n @location_map.destroy\n\n respond_to do |format|\n format.html { redirect_to location_maps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @locationmap = Locationmap.find(params[:id])\n @locationmap.destroy\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create method added 28 jul 17 for making submit form create new person (step 15)
def create # next line commented out and following line added 2 aug 17 for connecting users to people (step 17) # Person.create(person_params) current_user.people.create(person_params) # check nomster/flixter code in this area redirect_to new_person_path # change to redirect to page showi...
[ "def create\n\t\t@person = Person.create(person_params)\n\t\tredirect_to person_url(@person)\n\tend", "def create\n @person = current_user.persons.new(person_params)\n\n respond_to do |format|\n if @person.save\n format.html { redirect_to @person, notice: 'Person was successfully created.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run an application 'cmd' in a separate thread and monitor its stdout. Also send status reports to the 'observer' by calling its "call(eventType, appId, message")"
def initialize(id, cmd, map_std_err_to_out = false, working_directory = nil, &observer) @id = id || self.object_id @observer = observer @@all_apps[@id] = self @exit_status = nil @threads = [] pw = IO::pipe # pipe[0] for read, pipe[1] for write pr = IO::pipe pe = IO::pipe logger....
[ "def run(cmd)\n @pipe = pipe = IO::pipe\n info \"Starting #{cmd}\"\n @running = true\n @pid = fork {\n # set the process group ID to the pid of the child\n # this way, the child and all grandchildren will be in the same process group\n # so we can terminate all of them with just one signa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
analyze children DOM nodes of the specific action_node, get all of action node params
def analyze_node_children(action_node) res_array = [] action_node.element_children.each do |child| if child.key?("class") reg_res = /action-([\w-]+)/.match(child["class"]) unless reg_res.nil? arg_name = replace_to_underscore(reg_res[1]) arg_value = child["data-value"] ...
[ "def visit_params(node); end", "def parameter_children\n []\n end", "def extract_parameters(op_options, node)\n logger.debug \"Operation node: #{node.inspect}\"\n r = []\n op_options[:parameters].each do |p|\n logger.debug \" Looking for: tns:#{p.first.camelize_if_symbol(:lowe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called after svc_activate completes boilerplate functions.
def _activate end
[ "def after_activate\n result = service.try(:after_activate)\n if result.present?\n update(service_options: result)\n end\n end", "def activate\n STDERR.print \"Activating version #{@version_id}...\"\n service = @app_engine.get_app_service(@app_id, @service_id)\n service.split.a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called before svc_deactivate does boilerplate functions.
def _deactivate end
[ "def after_deactivate\n end", "def svc_deactivate(svc_man)\n\t\t@handlers.clear\n\t\t@fwk = nil\n\t\t@svc_man.remove_event_listener(self)\n\t\t@svc_man = nil\n\tend", "def after_activate\n result = service.try(:after_activate)\n if result.present?\n update(service_options: result)\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /contact_forms/new GET /contact_forms/new.xml
def new @contact_form = ContactForm.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @contact_form } end end
[ "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @contact }\n end\n end", "def new\n @contactos = Contactos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contactos...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get info about track
def tracks_get_info params = { :track_id => nil } json = send_request 'tracks_get_info', params if json['success'] == true json['data'] else puts "Error: " + json['message'] exit end end
[ "def get_track\n get_player_trackinfo(:name)\n end", "def get_info( params )\n xml = LastFM.get( \"track.getInfo\", params )\n LastFM::Track.from_xml( xml )\n end", "def get_info(artist, track)\n LastFM::Api::Track.get_info( :artist => artist, :track => track )\n rescue LastFM...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get download link for track
def tracks_get_download_link params = { :track_id => nil, :reason => 'save' } json = send_request 'tracks_get_download_link', params if json['success'] == true json['url'] else puts "Error: " + json['message'] exit end end
[ "def track_download\n connection.get(links.download_location)[\"url\"]\n end", "def url\n @client.get_download_link(@path)\n end", "def download_link\n download_params = { :sub => 'download', :fileid => @fileid, :filename => @remote_filename, :cookie => @api.cookie }\n DOWN...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /bid_events GET /bid_events.json
def index @bid_events = BidEvent.all end
[ "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def index\n @events = @product.events\n .includes(bid: [:user])\n .page(params[:page]).per(Settings.events.count_per_page)\n @ev...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /bid_events POST /bid_events.json
def create @bid_event = BidEvent.new(bid_event_params) respond_to do |format| if @bid_event.save format.html { redirect_to :back } format.json { render :show, status: :created, location: @bid_event } else format.html { redirect_to :back } format.json { render json: @...
[ "def create\n @bet_event = BetEvent.new(bet_event_params)\n\n respond_to do |format|\n if @bet_event.save\n format.html { redirect_to @bet_event, notice: 'Bet event was successfully created.' }\n format.json { render :show, status: :created, location: @bet_event }\n else\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /bid_events/1 PATCH/PUT /bid_events/1.json
def update respond_to do |format| if @bid_event.update(bid_event_params) format.html { redirect_to @bid_event, notice: 'Bid event was successfully updated.' } format.json { render :show, status: :ok, location: @bid_event } else format.html { render :edit } format.json { r...
[ "def update\n event = event.find(params[\"id\"]) \n event.update_attributes(event_params) \n respond_with event, json: event\n end", "def update\n #TODO params -> strong_params\n if @event.update(params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /bid_events/1 DELETE /bid_events/1.json
def destroy @bid_event.destroy respond_to do |format| format.html { redirect_to :back, notice: 'Bid event was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This is the main entry point to do a search on a node. It takes a single argument: actor: Actor is the node that you want to find a path to KB from. It returns an array (sorted with your input first) that is the path from your node to KB himself!
def calculate_path(actor) reset_baconator(actor) node_search do |current_node| process_single_node(current_node) end end
[ "def find_kevin_bacon(start, kevin)\n return @path if start == kevin\n\n @queue << start\n for film in start.film_actor_hash.keys\n if !included_film?(film)\n @path.push(film)\n if start.film_actor_hash[film].include?(kevin)\n add_path # Adds the new path into @paths\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This is the heart of the algorithm, the rest is just dressing. This method takes a newly created node and checks for a few conditions: 1. if the node is in the current queue. If it is, check to see if our new node is better than the one in the queue. If it is, delete the one in the queue. 2. if the node is in the marke...
def process_new_node(node) continue_unless_match(node) do if (node_in_queue = queue.find { |n| n.name == node.name }).present? if node.depth < node_in_queue.depth @requeued += 1 queue.delete(node_in_queue) queue << node end elsif (node_in_que...
[ "def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << nei...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method just iterates over the final_path array and sets bacon_links if they haven't been set already
def save_results unless self.options[:disable_save] == true self.final_path.inject(nil) do |previous, link| unless previous.nil? || previous.element.bacon_link.present? previous.element.update_attribute(:bacon_link_id, link.element.id) end link end e...
[ "def populate_links\n stack = [[[], @source]]\n until stack.empty?\n roots, dir = *stack.pop\n dir.children.each do |child|\n name = block_given? && yield(child) || child.basename.to_s\n path = roots + [name]\n\n if child.directory?\n stack.push [path, c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /shared_networks or /shared_networks.json
def index @dhcp_server = DhcpServer.find_by_id(params[:dhcp_server_id]) @shared_networks = @dhcp_server.shared_networks end
[ "def neutron_v2_networks(neutron_url,\n\t\t\tnet_name,\n token)\n\n url = URI.parse(\"#{neutron_url}/networks?name=#{net_name}\")\n req = Net::HTTP::Get.new url.path\n req['content-type'] = 'application/json'\n req['x-auth-token'] = token\n\n res = handle_request(req, url)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /shared_networks or /shared_networks.json
def create if params[:dhcp_server_id] && @dhcp_server = DhcpServer.find_by_id(params[:dhcp_server_id]) @shared_network = @dhcp_server.shared_networks.new(shared_network_params) end respond_to do |format| if @shared_network.save format.html { redirect_to @shared_network, notice: "Shared ...
[ "def create body = {}\n @connection.request(method: :post, path: \"/networks/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def create\n @network = current_user.networks.new(network_params)\n\n respond_to do |format|\n if @network.save\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /shared_networks/1 or /shared_networks/1.json
def update respond_to do |format| if @shared_network.update(shared_network_params) format.html { redirect_to @shared_network, notice: "Shared network was successfully updated." } format.json { render :show, status: :ok, location: @shared_network } else format.html { render :edit,...
[ "def update\n @network = current_organization.owned_networks.find(params[:id])\n \n if @network.update_attributes(params[:network]) then\n redirect_to network_path(@network)\n else\n render :action => 'edit'\n end\n end", "def update\n @network = Network.find(params[:id])\n\n resp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /shared_networks/1 or /shared_networks/1.json
def destroy @shared_network.destroy respond_to do |format| format.html { redirect_to shared_networks_url, notice: "Shared network was successfully destroyed." } format.json { head :no_content } end end
[ "def delete(id)\n request(:delete, \"/settings/networks/#{id}.json\")\n end", "def destroy\n @network.destroy\n\n respond_to do |format|\n format.html { redirect_to networks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @saved_network = SavedNetwork.find(pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /categors/1 DELETE /categors/1.json
def destroy @categor.destroy respond_to do |format| format.html { redirect_to categors_url, notice: 'Categor was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @categoty.destroy\n respond_to do |format|\n format.html { redirect_to categoties_url, notice: 'Categoty was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n EconomicCategory.delete_hack(params[:id])\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns client with the given name if in catalog, nil otherwise
def find_client(cl_name) chef_clients.find{|ccl| ccl.name == cl_name } end
[ "def getClient(name)\n @clients.each { |client| client.name == name}.first\n end", "def client(name)\n client_to_find = name\n @clients.find {|key, value| key == client_to_find } \n end", "def client(name)\n Clients.with_name(name)\n end", "def get_client( query ) \n client = nil\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Walk the list of chef nodes and vivify the server, associate the chef node if the chef node knows about its instance id, memorize that for lookup when we discover cloud instances.
def discover_chef_nodes! chef_nodes.each do |chef_node| if chef_node["cluster_name"] && chef_node["facet_name"] && chef_node["facet_index"] cluster_name = chef_node["cluster_name"] facet_name = chef_node["facet_name"] facet_index = chef_node["facet_index"] elsif ch...
[ "def discover_chef_nodes!\n chef_nodes.each do |chef_node|\n if (cchef = chef_node['cluster_chef'])\n cluster_name = cchef[\"cluster\"] || cchef[\"name\"]\n facet_name = cchef[\"facet\"]\n facet_index = cchef[\"index\"]\n elsif chef_node[\"cluster_name\"] && chef_node[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Walk the list of servers, asking each to discover its chef client.
def discover_chef_clients! servers.each(&:chef_client) end
[ "def each\n (@servers || []).each { |server| yield server }\n end", "def each\n @list.each do |server|\n case server\n when Server then yield server\n when DynamicServer then server.each { |item| yield item }\n else raise ArgumentError, \"server list contains non-server: #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Browse submissions by subreddit
def browse(subreddit, options={}) subreddit = sanitize_subreddit(subreddit) options.merge! :handler => "Submission" if options[:limit] options.merge!({:query => {:limit => options[:limit]}}) end read("/r/#{subreddit}.json", options ) end
[ "def index\n @sub_reddits = SubReddit.all\n end", "def subreddit = self", "def index\n @sub_reddit_comments = SubRedditComment.all\n end", "def index\n @related_sub_reddits = RelatedSubReddit.limit(20).all\n end", "def get_subreddit(subreddit)\n do_action(\"/r/#{subreddit}/about.json\")\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joins the command history together with ` && `, to form a single command.
def join commands = [] @history.each do |command| program = command[0] arguments = command[1..-1].map { |word| shellescape(word.to_s) } commands << [program, *arguments].join(' ') end return commands.join(' && ') end
[ "def join\n @history.map { |command| command.join(' ') }.join(' && ')\n end", "def command_join_string!\n (@mode == :pipe) ? \" | \" : \" && \"\n end", "def cmd_concat_operator\n\t\t\" & \"\n\tend", "def cmd_concat_operator\n \" & \"\n end", "def andand(*commands)\n cmdjoin(comman...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the URI to one compatible with SSH.
def ssh_uri unless @uri.host raise(InvalidConfig,"URI does not have a host: #{@uri}",caller) end new_uri = @uri.host new_uri = "#{@uri.user}@#{new_uri}" if @uri.user return new_uri end
[ "def ssh_uri\n new_uri = @uri.host\n new_uri = \"#{@uri.user}@#{new_uri}\" if @uri.user\n\n return new_uri\n end", "def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end", "def ssh_uri\n ssh_root = \"#{ConfigVar['git_user']}@#{ConfigVar['ssh_host']}\"\n \"#...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replays the command history on the remote server.
def replay ssh(self.join) unless @history.empty? end
[ "def replay\n puts \"Restarting song\"\n SpotifyCli::App.replay!\n end", "def cmd_history argv\n setup argv\n msg run_cmd(\"history\")\n end", "def replay(none)\n\tend", "def replay message\n puts message\n request_human_move\n end", "def replay(game)\n\t\t@moves.each { |mov...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets all records currently stored in the repo.
def all copy_and_return(@records) end
[ "def fetch_all\n\t\tresult = []\n\t\teach_record do |record|\n\t\t\tresult.push(record)\n\t\tend\n\t\treturn result\n\tend", "def records\n @records ||= eshelf.records\n end", "def records\n @records ||= search.records\n end", "def records\n if options[:in_memory]\n @record...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds a single record by its id.
def find(id) find_one do |record| record.id == id end end
[ "def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end", "def find_by_id(id)\n find_one(id)\n rescue RecordNotFound\n nil\n end", "def find(id)\n records.find {|r| r.id == id } || raise('Unknown Record')\n end", "def find(id)\n @r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clones result or array and returns it ensuring any changes don't
def copy_and_return(result_or_array) if result_or_array.nil? nil elsif result_or_array.is_a?(Array) result_or_array.map {|r| copy_and_return(r) } else result_or_array.clone end end
[ "def clone() end", "def clone(*) end", "def safe_clone\r\n self.clone\r\n end", "def clone_list_to_array\n clone = Array.new\n self.items.each do |item| \n result.push(item.get_clone())\n end\n return clone\n end", "def full_clone(_arg=nil)\r\n self.clone\r\n end", "def clone\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Truncates workflow history to a specified event id.
def truncate_history(events, replay_upto = nil) return nil if events.nil? || events.empty? # Just return the original array of events if replay_upto is not set # or if the number of events is less than replay_upto return events if replay_upto.nil? || events.last['eventId'] <= re...
[ "def delete_event(id)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_timeline\") do |m|\n m.where(id: id).delete\n end\n end", "def history_destroy\n SygiopsSupport::History.remove(self.class.to_s, id)\n end", "def clear_events\n Record.with(collection:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }