query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
GET /thing_types GET /thing_types.json
def index @thing_types = ThingType.all end
[ "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /thing_types POST /thing_types.json
def create @thing_type = ThingType.new(thing_type_params) respond_to do |format| if @thing_type.save format.html { redirect_to @thing_type, notice: 'Thing type was successfully created.' } format.json { render :show, status: :created, location: @thing_type } else format.html...
[ "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def create\n @clothing_type = ClothingType.new(clothing_type_params)\n\n respond_to do |format|\n if @clo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /thing_types/1 PATCH/PUT /thing_types/1.json
def update respond_to do |format| if @thing_type.update(thing_type_params) format.html { redirect_to @thing_type, notice: 'Thing type was successfully updated.' } format.json { render :show, status: :ok, location: @thing_type } else format.html { render :edit } format.jso...
[ "def patch_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end", "def update\n respond_to do |format|\n if @clothing_type.update(cl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /thing_types/1 DELETE /thing_types/1.json
def destroy @thing_type.destroy respond_to do |format| format.html { redirect_to thing_types_url, notice: 'Thing type was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @thing_type1 = ThingType1.find(params[:id])\n @thing_type1.destroy\n\n respond_to do |format|\n format.html { redirect_to(thing_type1s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @clothing_type.destroy\n respond_to do |format|\n format.html { red...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add a test db.execute("INSERT INTO tasks (task, due_date, completed) VALUES ('pay bills again', '9/4/17', 'false')")
def create_task (db, task, due_date, completed) db.execute("INSERT INTO tasks (task, due_date, completed) VALUES (?, ?, ?)", [task, due_date, completed]) end
[ "def create_task(db,date,start_time,end_time,location,description)\n db.execute(\"INSERT INTO planner (date,start_time,end_time,location,description) VALUES (?,?,?,?,?)\", [date,start_time,end_time,location,description])\nend", "def add_item(db, new_item, new_date)\n db.execute(\"INSERT INTO todolist (item, dat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check if puzzle solved.
def solved? # pour toutes les pièces (0..8).each { |i| # la case est encore vide : solved = false return false if @cases[i] == nil # sinon, est-ce que les pièces matchent entre elles. return false if not self.match?(i) } # sinon, ca match partout : le puzzle est résolu (solved) ! return t...
[ "def solved?(board)\n return true if solve(board)\n false\nend", "def solved?\n # Return whether the total passed in is equal to the total for a valid house.\n def is_valid_house_total?(total)\n return total == 45\n end\n\n # Return the total of adding up all the cells in this house.\n def h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method formats the TO address to include the provider.
def formatted_to "#{to}@#{Base.gateways[@provider][:sms]}" rescue raise "Invalid provider" end
[ "def format_address( address )\n return address.to_str if address.respond_to? :to_str\n address.join(\"\\nA\")\n end", "def mailing_address\n return unless @user.loa3?\n\n dig_out('addresses', 'address_pou', VAProfile::Models::Address::CORRESPONDENCE)\n end", "def to_s\n u = uri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method sanitizes the message body.
def sanitized_message message.to_s[0,140] end
[ "def sanitize_body\n end", "def filter_body\n\t\tself.body = Sanitize.clean(self.body, Sanitize::Config::BASIC) unless self.body.blank?\n\t\tself.title = Sanitize.clean(self.title, Sanitize::Config::BASIC) unless self.title.blank?\n\tend", "def clean\n unless self.subject.nil?\n self.subject = sa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
prompts player to choose from available columns
def choose_column available_cols = board.available_columns loop do puts "#{@light_turn ? LIGHT : DARK}'s turn." puts "Please choose a column from (#{available_cols.join(", ")})" col = gets.chomp.to_i return col if available_cols.include? col end end
[ "def column_choice\n print \"Please enter the column you would like to drop your disc:\\n>> \"\n choice = gets.chomp.to_i\n until @board.valid_column?(choice)\n print \"Not a valid column. Please enter a valid column:\\n>> \"\n choice = gets.chomp.to_i\n end\n choice\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Populate the game board with chess pieces
def populate @board[7][0] = ChessPiece.new "w_rook_1", "\u2656" @board[7][1] = ChessPiece.new "w_knight_1", "\u2658" @board[7][2] = ChessPiece.new "w_bishop_1", "\u2657" @board[7][3] = ChessPiece.new "w_queen", "\u2655" @board[7][4] = ChessPiece.new "w_king", "\u2654" @board[7][5] = ChessPiece.n...
[ "def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |po...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a string that resembles a chess board
def format display_string = "" (0..7).each do |row| display_string += "#{row}" (0..7).each do |col| if @board[row][col].instance_of? ChessPiece display_string += "[#{@board[row][col].unicode} ]" elsif @board[row][col].is_a? String display_string += @board[row][co...
[ "def board_string\n result = \" 0 1 2\\n\"\n (0...3).each do |row|\n result += \"#{row} \"\n (0...3).each do |col|\n value = maybe_colorize(row, col)\n result += value + '|'\n end\n result = result[0..-2] + \"\\n\"\n result += \" #{'-' * 5}\\n\" unless row == 2 # No h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /data_errors/1 GET /data_errors/1.json
def show @data_error = DataError.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @data_error } end end
[ "def errors\n fetch_results('error')\n end", "def render_errors(errors)\n render json: errors, status: :bad_request\n end", "def new\n @data_error = DataError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_error }\n end\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /data_errors/new GET /data_errors/new.json
def new @data_error = DataError.new respond_to do |format| format.html # new.html.erb format.json { render json: @data_error } end end
[ "def new\n @error = Error.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @error }\n end\n end", "def new\n @information_error = InformationError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /data_errors POST /data_errors.json
def create @data_error = DataError.new(params[:data_error]) respond_to do |format| if @data_error.save format.html { redirect_to @data_error, notice: 'Data error was successfully created.' } format.json { render json: @data_error, status: :created, location: @data_error } else ...
[ "def post(exception_data)\n hash = exception_data.to_hash\n hash[:session].delete(\"initialization_options\")\n hash[:session].delete(\"request\")\n call_remote(:errors, hash.to_json)\n end", "def render_json_validation_errors(resource)\n errors = []\n resource.errors.each do |fieldNa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /data_errors/1 PUT /data_errors/1.json
def update @data_error = DataError.find(params[:id]) respond_to do |format| if @data_error.update_attributes(params[:data_error]) format.html { redirect_to @data_error, notice: 'Data error was successfully updated.' } format.json { head :no_content } else format.html { rende...
[ "def update_errors\n @c.get_data(:update_errors)\n end", "def update\n @error = Error.find(params[:id])\n\n respond_to do |format|\n if @error.update_attributes(params[:error])\n format.html { redirect_to @error, notice: 'Error was successfully updated.' }\n format.json { head :no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /data_errors/1 DELETE /data_errors/1.json
def destroy @data_error = DataError.find(params[:id]) @data_error.destroy respond_to do |format| format.html { redirect_to data_errors_url } format.json { head :no_content } end end
[ "def delete_errors\n @c.get_data(:delete_errors)\n end", "def destroy\n @error = Error.find(params[:id])\n @error.destroy\n\n respond_to do |format|\n format.html { redirect_to errors_url }\n format.json { head :ok }\n end\n end", "def destroy\n @error = Error.find(params[:id])...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /usuario_carta/1 GET /usuario_carta/1.json
def show @usuario_cartum = UsuarioCartum.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @usuario_cartum } end end
[ "def show\n @user = User.find(params[:user_id])\n @cart_item = @user.cart_items.find(params[:id])\n json_response(@cart_item)\n end", "def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /usuario_carta/new GET /usuario_carta/new.json
def new @usuario_cartum = UsuarioCartum.new respond_to do |format| format.html # new.html.erb format.json { render json: @usuario_cartum } end end
[ "def new\n @cartelera = Cartelera.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cartelera }\n end\n end", "def new\n \t\"puts get carts new\"\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /usuario_carta POST /usuario_carta.json
def create @usuario_cartum = UsuarioCartum.new(params[:usuario_cartum]) respond_to do |format| if @usuario_cartum.save format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully created.' } format.json { render json: @usuario_cartum, status: :created, location: @u...
[ "def create\n product = Product.find(params[:product_id])\n quantity = params[:pocet]\n @cart_product = @cart.add_product(product.id, quantity)\n :add_cart_to_current_user\n respond_to do |format|\n if @cart_product.save\n if user_signed_in?\n user = current_user\n user....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /usuario_carta/1 PUT /usuario_carta/1.json
def update @usuario_cartum = UsuarioCartum.find(params[:id]) respond_to do |format| if @usuario_cartum.update_attributes(params[:usuario_cartum]) format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully updated.' } format.json { head :no_content } else ...
[ "def update_cart_item\n\t\t@persona = Persona.where(:screen_name => params[:persona_id]).first\n\t\t@cart = @persona.carts.find(params[:cart_id])\n\t\trespond_to do |format|\n\t\t\tif @cart.update_attributes(params[:cart]) then\n\t\t\t\tformat.json { respond_with_bip @cart }\n\t\t\telse\n\t\t\t\tformat.json { respo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /usuario_carta/1 DELETE /usuario_carta/1.json
def destroy @usuario_cartum = UsuarioCartum.find(params[:id]) @usuario_cartum.destroy respond_to do |format| format.html { redirect_to usuario_carta_url } format.json { head :no_content } end end
[ "def destroy\n @users_carts_conector.destroy\n respond_to do |format|\n format.html { redirect_to cart_url, notice: 'Producto Eliminado del carrito' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cartorio.destroy\n respond_to do |format|\n format.html { redirect_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET customer_quotes/1/customer_quote_lines/1 GET customer_quotes/1/customer_quote_lines/1.json
def show @customer_quote = CustomerQuote.find(params[:customer_quote_id]) @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @customer_quote_line } end end
[ "def show\n @quote = Quote.find(params[:quote_id])\n @quote_line = @quote.quote_lines.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @quote_line }\n end\n end", "def destroy\n @customer_quote = CustomerQuote.find(params[:cus...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET customer_quotes/1/customer_quote_lines/new GET customer_quotes/1/customer_quote_lines/new.json
def new @customer_quote = CustomerQuote.find(params[:customer_quote_id]) @customer_quote_line = @customer_quote.customer_quote_lines.build @attachable = @customer_quote respond_to do |format| format.html # new.html.erb format.json { render :json => @customer_quote_lin...
[ "def new\n @quote_line_cost = QuoteLineCost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote_line_cost }\n end\n end", "def new\n @quote = Quote.find(params[:quote_id])\n @quote_line = @quote.quote_lines.build\n @attachable = @quote\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST customer_quotes/1/customer_quote_lines POST customer_quotes/1/customer_quote_lines.json
def create @customer_quote = CustomerQuote.find(params[:customer_quote_id]) params[:customer_quote_line][:item_name_sub] = params[:alt_name_id] @customer_quote_line = @customer_quote.customer_quote_lines.build(customer_quote_line_params) @attachable = @customer_quote respond_to ...
[ "def create\n @quote_line = QuoteLine.new(quote_line_params)\n\n respond_to do |format|\n if @quote_line.save\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote_line }\n els...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT customer_quotes/1/customer_quote_lines/1 PUT customer_quotes/1/customer_quote_lines/1.json
def update @customer_quote = CustomerQuote.find(params[:customer_quote_id]) @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id]) @attachable = @customer_quote respond_to do |format| if @customer_quote_line.update_attributes(customer_quote_line_params) ...
[ "def update\n @quote = Quote.find(params[:quote_id])\n @quote_line = @quote.quote_lines.find(params[:id])\n\n respond_to do |format|\n if @quote_line.update_attributes(params[:quote_line])\n format.html { redirect_to new_quote_quote_line_path(@quote), :notice => 'Quote line was successfully upd...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE customer_quotes/1/customer_quote_lines/1 DELETE customer_quotes/1/customer_quote_lines/1.json
def destroy @customer_quote = CustomerQuote.find(params[:customer_quote_id]) @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id]) @customer_quote_line.destroy respond_to do |format| format.html { redirect_to customer_quote_path(@customer_quote), :notic...
[ "def destroy\n @quote = Quote.find(params[:quote_id])\n @quote_line = @quote.quote_lines.find(params[:id])\n @quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to new_quote_quote_line_path(@quote) }\n format.json { head :ok }\n end\n end", "def destroy\n @quote_li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
convert tweet url to embedding html
def embedding_tweet(content) embedded_content = content content.scan(/(https?:\/\/twitter\.com\/[a-zA-Z0-9_]+\/status\/([0-9]+)\/?)/).each do |url, id| tweet_json = open("https://api.twitter.com/1/statuses/oembed.json?id=#{id}").read tweet_html = JSON.parse(tweet_json, { :symbolize_names => true })[:html] ...
[ "def parse_tweet(tweet)\n oembeds = []\n # link urls:\n re = Regexp.new('(^|[\\n ])([\\w]+?://[\\w]+[^ \\\"\\n\\r\\t<]*)')\n # find urls through redirects\n urls = []\n tweet.scan(re) do |s|\n # find final url\n url = fetch(s[1])\n # replace url with found url\n urls << [s[1], url]\n end\n # do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Code Snippet pour une nouvelle QD
def snippet_for_qd "[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0" end
[ "def snippet_for_new_qdf\n snippet_for_new_qd\n end", "def q(*) end", "def q\n self\n end", "def qp(field_name,opts = {})\n options = {:show_hide_options => {},:question_options=>{}}.update(opts)\n show_hide_options = {\n :condition => \"#{field_name}=N\",\n :show => false\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Code Snippet pour une QDF
def snippet_for_new_qdf snippet_for_new_qd end
[ "def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end", "def pca_qda\n end", "def generate_fram(idx, qa_pair)\n q,a = qa_pair.map{|s| markdown(s)}\n \"<fram ord='#{idx}'><ord>#{idx}</ord><question>#{q}</question><answer>#{a}</answer></fram>\"\nend", "def to_Qdl\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Code Snippet pour une RDF
def snippet_for_new_rdf snippet_for_new_rd end
[ "def _get_dbpedia_rdf(dbpedia_url, type=\"ntriples\")\n puts \"_get_dbpedia_rdf: \"+ dbpedia_url\n #urls.each do |url|\n #print url + \"\\n\"\n nurl = dbpedia_url.dup #url.dup\n nurl['resource']='data'\n nurl.concat('.'+type) # n3, rdf, json, ntriples\n #puts nurl\n rdf_xml = open(nurl).read...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Code Snippet pour une nouvelle RD
def snippet_for_new_rd qd_id = select_qd_without_rd horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop type_reponse = select_type_reponse_rd while type_reponse.match(/\[tab_stop\]/) type_reponse.sub!(/\[tab_stop\]/, "\${#{Snippet::next_tab}:TEXTE}") end sn = ""...
[ "def statement\n self.snippet\n end", "def snippet_for_new_rdf\n snippet_for_new_rd\n end", "def use_for_snippets; end", "def code_keyword; end", "def code_description_support; end", "def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end", "def doc_st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retourne l'identifiant de la QD choisie
def select_qd_without_rd qds = hash_qds true if qds.empty? Snippet::alert "Aucune QD n'est sans réponse dans ce fichier…", "Il faut définir une QD avant de définir sa RD." else items_string = qds.collect do |dqd| dqd[:qd].gsub!(/\"/,"\\\""); "\"#{dqd[:qd]}\"" end.join...
[ "def identifier_value\n DEFAULT_QUESTIONNAIRE_ID\n end", "def which_questionaire\n @q = 0\n Questionaire.find(:all).each do|q|\n if q.activated\n @q = q.id\n break\n end\n end \n return @q \n end", "def option_number\n pricing_db_hp_support_option.option_number\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
VBS payload and Post Data preparation
def get_payload handler payload = generate_payload_exe @vbs_content = Msf::Util::EXE.to_exe_vbs(payload) ## determining the target directory if target.name == 'AppManager 14' tfile = "AppManager14" elsif target.name == 'AppManager 13' tfile = "AppManager13" elsif targe...
[ "def vbs_down_payload\n\t\tprint_status(\"Simple VBScript Downloader Script Builder\")\n\t\tprint_caution(\"Please provide (pre-encoded) URL to the file you want to download: \")\n\t\tzSITE=gets.chomp\n\n\t\tprint_caution(\"Provide Name to save file as: \")\n\t\tzNAME=gets.chomp\n\n\t\tprint_status(\"Generating dow...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create the splash screen
def makeSplash clearScreen splash = ConsoleSplash.new(15,70) splash.write_header("Welcome to Sokoban","Ben Cornforth","Alpha Build, November 2015",{:nameFg=>:green,:authorFg=>:green, :versionFg=>:green, :bg=>:black}) splash.write_horizontal_pattern("/*",{:fg=>:white, :bg=>:black}) splash.write_vertical_patter...
[ "def display_splash_screen(splash)\n #Game general information\n splash.write_header(\" Flood it !\", \"Alex Bondrea\", \"1.0\", {:nameFg=>:white,\n :nameBg=>:blue})\n splash.write_center(-2, \"Copyright © 2016 Alex Bondrea\")\n\n splash.splash # => re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this code will run when the user wants to select a level
def selectLevel puts "Choose a level from 1 - 90:" input = gets.chomp() tempLevelNo = input.to_i if (input == tempLevelNo.to_s) if 1 > tempLevelNo || tempLevelNo > 90 puts "Level does not exist, please choose a level from 1-90" puts "Do you wish to continue choosing? y/n" case(...
[ "def select_level\n\t\t\t\t\t\t\t\t\tlevel = nil\n\t\t\t\t\t\t\t\t\tloop do\n\t\t\t\t\t\t\t\t\t\tputs \"\"\n\t\t\t\t\t\t\t\t\t\tputs \"Choose difficulty Level:\"\n\t\t\t\t\t\t\t\t\t\tputs \"[1] Easy\"\n\t\t\t\t\t\t\t\t\t\tputs \"[2] Medium\"\n\t\t\t\t\t\t\t\t\t\tputs \"[3] Hard\"\n\t\t\t\t\t\t\t\t\t\tputs \"Enter t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creating an array for locateMan, where the 0th element is x across, and the 1st element is y down
def locateMan yDown=0 @levelArr.each do |y| xCount=1 y.each do |x| if x == '@' return xCount,yDown end xCount+=1 end yDown+=1 end end
[ "def pos\n return [@x, @y]\n end", "def location\n [@x, @y, @floor]\n end", "def positions(x=@x,y=@y) \n return [[x,y]] if unit_size == 1\n tiles = [] \n for ox in x...(x+unit_size)\n for oy in y...(y+unit_size)\n tiles.push([ox,oy])\n end\n end\n return tiles\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /traces/1 GET /traces/1.xml
def show @trace = Trace.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @trace } end end
[ "def index\n @traces = Trace.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traces }\n end\n end", "def index\n @traces = Trace.all\n end", "def traces\n @traces ||= RequestList.new\n end", "def index\n @traces = Trac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /traces/new GET /traces/new.xml
def new @trace = Trace.new(params[:trace]) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @trace } end end
[ "def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end", "def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trail }\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /traces/1 PUT /traces/1.xml
def update @trace = Trace.find(params[:id]) respond_to do |format| if @trace.update_attributes(params[:trace]) format.html { redirect_to(@trace, :notice => 'Trace was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } for...
[ "def test_api_update_tags\n tracetag = create(:tracetag)\n trace = tracetag.trace\n basic_authorization trace.user.display_name, \"test\"\n\n content trace.to_xml\n put :api_update, :params => { :id => trace.id }\n assert_response :success\n\n updated = Trace.find(trace.id)\n # Ensure there'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /traces/1 DELETE /traces/1.xml
def destroy @trace = Trace.find(params[:id]) @trace.destroy respond_to do |format| format.html { redirect_to(traces_url) } format.xml { head :ok } end end
[ "def destroy\n @trace.destroy\n respond_to do |format|\n format.html { redirect_to traces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /studenttests GET /studenttests.json
def index @studenttests = Studenttest.all end
[ "def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end", "def index\n @student_tests = StudentTest.all\n end", "def get_student(parameters)\n json_post('students/api....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /studenttests POST /studenttests.json
def create @studenttest = Studenttest.new(studenttest_params) respond_to do |format| if @studenttest.save format.html { redirect_to @studenttest, notice: 'Studenttest was successfully created.' } format.json { render :show, status: :created, location: @studenttest } else for...
[ "def create\n @student_test = StudentTest.new(student_test_params)\n respond_to do |format|\n if @student_test.save\n format.html { redirect_to @student_test, notice: 'Student test was successfully created.' }\n format.json { render :show, status: :created, location: @student_test }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /studenttests/1 PATCH/PUT /studenttests/1.json
def update respond_to do |format| if @studenttest.update(studenttest_params) format.html { redirect_to @studenttest, notice: 'Studenttest was successfully updated.' } format.json { render :show, status: :ok, location: @studenttest } else format.html { render :edit } forma...
[ "def update\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n if @student_test.update_attributes(params[:student_test])\n format.html { redirect_to @student_test, notice: 'Student test was successfully updated.' }\n format.json { head :ok }\n else\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /studenttests/1 DELETE /studenttests/1.json
def destroy @studenttest.destroy respond_to do |format| format.html { redirect_to studenttests_url, notice: 'Studenttest was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @student_test.destroy\n respond_to do |format|\n format.html { r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add some books into inventory
def purchase_books(newbooks) newbooks.each {|book, number| inventory[book] = number} end
[ "def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend", "def add_to_inventory(item)\n @inventory.push(item)\n update\n end", "def add_book(book)\n @books << book\n puts \"We have just added the following NEW book '#{book.title}' to the Library\"\n end", "def add(book)\n\t\t @books ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new record for current transaction One record is created for one book. Every user can only borrow a book for 60 days.
def add_a_record(user, book) now = DateTime.now.to_date borrow_days = 60 due = now + borrow_days @records << Record.new(user.id, book.isbn, now, due) puts "Successfully lend <#{book.title}> to #{user.name}. Due:#{due}" end
[ "def create\n @book_transaction = BookTransaction.new(book_transaction_params)\n if @book_transaction.save\n flash[:notice] = \"Transaction saved successfully\"\n redirect_to books_url\n else\n render \"new\"\n end\n end", "def create\n @account_book = AccountBook.create(account_boo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check records of a user.
def check_records(user) @records.select{|record| !record.has_return && record.user_id == user.id}.each do |record| @inventory.each do |book,value| if book.isbn == record.book_isbn then puts "=> Warning! \n" puts "#{user.name} borrowed <#{book.title}> on #{record.borrow_date}, #{user.name} has to retu...
[ "def check_user\n if current_user != @record.user\n redirect_to root_url, alert: \"Sorry, this Record belongs to someone else\"\n end\n end", "def checkUser(user)\n\treturn getAllUsersWithRoster().include?(user)\nend", "def own?\r\n @user.id == @record.user_id\r\n end", "def check_search_u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /admin/funcionarios/1 GET /admin/funcionarios/1.json
def show @funcionario = Funcionario.find(params[:id]) respond_with @funcionario, :location => admin_funcionario_path end
[ "def show\n @funcionario = Funcionario.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @funcionario }\n end\n end", "def show\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /admin/funcionarios/new GET /admin/funcionarios/new.json
def new @funcionario = Funcionario.new @funcionario.contato_telefones.build respond_with @funcionario, :location => new_admin_funcionario_path end
[ "def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funcionario }\n end\n end", "def new\n @funcionario = Funcionario.new\n localidad_new\n @estados_funcionarios=EstadosFuncionario.all\n respond_to do |form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /admin/funcionarios/1 PUT /admin/funcionarios/1.json
def update @funcionario = Funcionario.find(params[:id]) respond_to do |format| if @funcionario.update_attributes(params[:funcionario]) format.html { redirect_to [:admin, @funcionario], notice: 'Funcionario Atualizado com sucesso.' } format.json { head :no_content } else form...
[ "def update\n # render text: params.inspect\n respond_to do |format|\n if @funcionario.update(funcionario_params)\n @funcionario.usuario.update_attributes(tipo: params[:funcionario][:usuarios][:tipo], nome: @funcionario.apelido)\n format.html { redirect_to area_funcionarios_path(@funcionari...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /admin/funcionarios/1 DELETE /admin/funcionarios/1.json
def destroy @funcionario = Funcionario.find(params[:id]) @funcionario.destroy respond_to do |format| format.html { redirect_to admin_funcionarios_url } format.json { head :no_content } end end
[ "def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to funcionarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the square of the sum of the first +n+ natural numbers
def square_of_sums return (@n * (@n + 1) / 2)**2 end
[ "def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end", "def square_of_sums\n\n\t\t#Sum all numbers between 1 and n\n\t\tsum = (1..@n_numbers).reduce(:+)\n\t\t#Square the sum\n\t\tsum **= 2\n\tend", "def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /ways GET /ways.json
def index @ways = Way.all end
[ "def index\n\n begin\n @pathways = Pathway.order(:name).to_a\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pathways }\n end\n rescue\n handle_unspecified_error\n end\n\n end", "def show\n @pathway = Pathway.find(params[:id])\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ways POST /ways.json
def create @way = Way.new(way_params) respond_to do |format| if @way.save format.html { redirect_to @way, notice: 'Way was successfully created.' } format.json { render :show, status: :created, location: @way } else format.html { render :new } format.json { render js...
[ "def create\n @pathway = Pathway.new(params[:pathway])\n\n respond_to do |format|\n if @pathway.save\n format.html { redirect_to @pathway, notice: 'Pathway was successfully created.' }\n format.json { render json: @pathway, status: :created, location: @pathway }\n else\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /ways/1 PATCH/PUT /ways/1.json
def update respond_to do |format| if @way.update(way_params) format.html { redirect_to @way, notice: 'Way was successfully updated.' } format.json { render :show, status: :ok, location: @way } else format.html { render :edit } format.json { render json: @way.errors, statu...
[ "def update\n @pathway = Pathway.find(params[:id])\n\n respond_to do |format|\n if @pathway.update_attributes(params[:pathway])\n format.html { redirect_to @pathway, notice: 'Pathway was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return an array of addresses from 1 or more aliases that match either IPv4 or IPv6
def resolve_alias(addresses, ipvers) addresses = [addresses] unless addresses.is_a?(Array) result = [] addresses.each do |address| if address =~ /^([\w\-]+)$/ if aliases[address] result += select_ipvers(aliases[address], ipvers) else raise "Alias is not defined: #{a...
[ "def ipv6_addresses\n addresses.select { |address| address.match /:/ }\n end", "def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend", "def extract_addresses(addre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This endpoint allows to recommend a new member to airlines.
def create_recommend_a_new_member(body) # Prepare query url. _path_url = '/v1/airline/members/' _query_builder = Configuration.get_base_uri _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'a...
[ "def recommendation_create\n expose Member.recommendation_create(@oauth_token, params[:membername], \n params[:recommendation_from_username], params[:recommendation_text])\n end", "def recommendations\n expose Member.recommendations(@oauth_token, params[:membername], recommendations_fields)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This endpoint allows to search a member on the airline system.
def create_member_search(body) # Prepare query url. _path_url = '/v1/airline/members/actions/search' _query_builder = Configuration.get_base_uri _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' ...
[ "def search\n expose Member.search(@oauth_token, params[:keyword], search_fields)\n end", "def search_member\n search_params = params[:member].select {|k,v| not v.empty?}\n search_params['email'] = search_params['email'].split().last().gsub(/[()]/, '') if search_params['email']\n search_params['locat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
sets the genre to the genre of the specified name
def genre_name=(name) self.genre = Genre.find_or_create_by(name: name) self.genre = genre end
[ "def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end", "def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end", "def set_genre(genre)\n @songs.each { |s| s.genre = genre }\n end", "def genre(value)\n @ole.Genre = value\n nil\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
then, the method will print: "a", "b", "c", "ab", "bc", "abc" if the input string is "abcd", then, the method will print: "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd"
def print_combinations(str) return if !str || str.length == 0 str_length = str.length char_count = 1 while char_count <= str_length start_index = 0 print_current(start_index, char_count, str, str_length) char_count += 1 end return end
[ "def string_reduction(str)\n idx = 0\n until str.chars.uniq.size == 1\n if idx >= str.size - 1\n idx = 0\n next\n end\n if str[idx] == 'a'\n if str[idx + 1] == 'b'\n str[idx..idx + 1] = 'c'\n idx = 0\n elsif str[idx + 1] == 'c'\n str[idx..idx + 1] = 'b'\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Process argument, return register code if arg is like R0,R1 or AX,FLAG. Else if arg is a defined label, then returns it's address. If it is a integer, just read and parse to the caller. Otherwise it must be a undefined lebel, feel free to return nil. process_argument("123h") porcess_argument("R0") process_argument("sta...
def process_argument(arg) return REG[arg] if REG.has_key?(arg) return EREG[arg] if EREG.has_key?(arg) return SREG[arg] if SREG.has_key?(arg) return @labels[arg] if @labels.has_key?(arg) return arg.to_i(16) if arg =~ /^\d*[Hh]$/ return arg.to_i(10) if arg =~ /^\d*[Dd]+$/ ...
[ "def process_argument(arg)\n # no additional paramaeters\n raise_invalid_parameter(arg)\n nil\n end", "def argument\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 39 )\n\n\n return_value = ArgumentReturnValue.new\n\n # $rule.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate the required signature as specified by unionpay official document it returns the signature string
def generate_signature sha1x16 = Digest::SHA1.hexdigest(signed_string) .tap { |s| logger.debug "sha1x16 #{s}" } enc = case form_fields['signMethod'] when '01' # 01 means RSA merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16) ...
[ "def signature_string\n @signature_string\n end", "def calculate_signature_string(parameters)\n merchant_sig_string = \"\"\n merchant_sig_string << parameters[:payment_amount].to_s << parameters[:currency_code].to_s <<\n parameters[:ship_before_date].to_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate the string to sign on from all in from_fields. Currently Unionpay doc specifies that the fields are arranged alphabetically
def signed_string signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) } signed_data_only.sort.collect { |s| "#{s[0]}=#{s[1]}" }.join('&') .tap { |ss| logger.debug "signed string is #{ss}" } end
[ "def signed_field_names\n @signed_fields.join(',')\n end", "def make_sign\n\t\t\t#warn 'TODO: Add signature to fields'\n return '' if self.fields.blank?\n _sorted = Hash.send :[], self.fields.select{ |key,val| val.present? && key != 'sign_type' && key != 'sign' }.sort_by{ |key,val| key }\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Inject inprocess correlations into the supplied carrier.
def inject(carrier, context, &setter) return carrier unless (correlations = context[ContextKeys.correlation_context_key]) && !correlations.empty? setter ||= default_setter setter.call(carrier, @correlation_context_key, encode(correlations)) carrier end
[ "def inject(carrier, context = Context.current, &setter)\n @injectors.inject(carrier) do |memo, injector|\n injector.inject(memo, context, &setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in CompositePropagator#inject #{e....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the target_modules == :all, or contains the module_name in the collection.
def can_use(module_name) target_is_all? or target_includes? module_name end
[ "def includes_modules?\n @includes_modules\n end", "def has_modules?\n m = @context.modules.find{|m| m.document_self}\n m ? true : false\n end", "def has_all?\n @privileges.fetch(@target) == :all\n end", "def modules?\n name == Modules\n end", "def active?(submodule_name)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
display_board Should accept a board as an argument and print out the current state of the board for the user.
def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end
[ "def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end", "def display_board\n\t\t@board_state.each_wit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A collection of Drip objects associated with a given `Caffeinate::Dripper`
def drips drip_collection.values end
[ "def trips\n Trip.find_for_rider(@rider_id)\n end", "def trips\n Trip.find_for_driver(@driver_id)\n end", "def trips\n arr = []\n Trips.all.each do |trip|\n if trip.listing == self\n arr << trip\n end\n end\n arr\n end", "def get_trips #from trip object\n tri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method to determine if a flowcell can be cleaned or not. For a flowcell to be cleaned, all of the following conditions must be true : 1) Marker file ".rsync_finished" must be present 2) It must have been modified 20 days ago (i.e. 1728000 seconds earlier) 3) The flowcell must not have been cleaned earlier (i.e., it mus...
def isAvailableForCleaning(fcName) markerName = fcName + "/.rsync_finished" if File::exist?(markerName) modTime = File::mtime(markerName) timeDiff = (Time.now- modTime) intensityLaneDir = fcName + "/Data/Intensities/L00*" intensityLaneDir = Dir[fcName + "/Data/Intensities/L00*"...
[ "def fcReady?(fcName)\n if File::exist?(@instrDir + \"/\" + fcName + \"/.rsync_finished\")\n return true\n end\n \n if fcName.match(/SN601/) || fcName.match(/SN166/) \n puts \"Flowcell \" + fcName + \" is not configured for automatic analysis\"\n return false\n end\n\n # If the mar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns wheter the neuron is self connected
def selfconnected? !selfconnection.weight.zero? end
[ "def selfconnected?\n list.all?(&:selfconnected?)\n end", "def connected?\n @neighbors.count.nonzero?\n end", "def connected?\n MSPhysics::Newton::Joint.is_connected?(@address)\n end", "def connected?\n state == :CONNECTED\n end", "def connected\n\t\treturn @connected\n\tend", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes configuration and an arg that is expected to be key=value format. If c is empty, creates one and returns it
def add_to_configuration(c, arg) kv = arg.split('=') kv.length == 2 || (raise "Expected parameter #{kv} in key=value format") c = org.apache.hadoop.hbase.HBaseConfiguration.create if c.nil? c.set(kv[0], kv[1]) c end
[ "def hash_arg_to_config(hash_arg, klass)\n case hash_arg\n when Hash \n klass.new(hash_arg)\n when NilClass \n klass.new\n else \n # this assumes it already is an element of klass, or acts like one,\n # if not something bad will happen later, that's yo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Usage: git alias The second parameter is optional, if so, it will show the current value of the alias.
def git_alias(args) # check if the alias exists right now system("git config --global alias.#{args[0]} #{args[1]}") end
[ "def git_alias(name,action)\n system 'git', 'config', '--global', '--replace-all', \"alias.#{name}\", action\n end", "def aliases\n\t\t\twith_dir do\n\t\t\t\t%x/git config --get-regexp 'alias.*'/.each_line.map do |l|\n\t\t\t\t\tputs l.sub(/^alias\\./,\"\").sub(/ /,\" = \")\n\t\t\t\tend\n\t\t\tend\n\t\tend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /animalcontrols POST /animalcontrols.json
def create @animalcontrol = Animalcontrol.new(animalcontrol_params) respond_to do |format| if @animalcontrol.save format.html { redirect_to @animalcontrol, notice: 'Animal Control Call-Out was successfully created.' } format.json { render :show, status: :created, location: @animalcontrol ...
[ "def create\n @animal_owner = AnimalOwner.new(params[:animal_owner])\n\n respond_to do |format|\n if @animal_owner.save\n format.html { redirect_to @animal_owner, notice: 'Animal owner was successfully created.' }\n format.json { render json: @animal_owner, status: :created, location: @anim...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /animalcontrols/1 PATCH/PUT /animalcontrols/1.json
def update respond_to do |format| if @animalcontrol.update(animalcontrol_params) format.html { redirect_to @animalcontrol, notice: 'Animal Control Call-Out was successfully updated.' } format.json { render :show, status: :ok, location: @animalcontrol } else format.html { render :...
[ "def update\n \n if @animal.update(animal_params)\n render json: @animal\n else\n render json: {}, status: :bad_request \n end\n end", "def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /animalcontrols/1 DELETE /animalcontrols/1.json
def destroy @animalcontrol.destroy respond_to do |format| format.html { redirect_to animalcontrols_url, notice: 'Animal Control Call-Out was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the full set of configuration options for the specified backup
def full_options(backup_name) backup_options = {} # Get backup defaults backup_options.merge!(@options[:backup_defaults].dup_contents_1_level) # Get the specific backup definition unless @options[:backups].has_key?(backup_name.to_sym) @logger.fatal("The backup name specified '#{bac...
[ "def backup_configuration\n settings[\"backup_configuration\"]\n end", "def get_backup_config(opts = {})\n data, _status_code, _headers = get_backup_config_with_http_info(opts)\n return data\n end", "def backups_config\n backups_root.join fetch(:backups_config)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a deep copy of a hash This is useful for copying a hash that will be mutated
def deep_copy_hash hash require_that(hash.is_a?(Hash), "deep_copy_hash requires a hash be specified, got #{hash.class}") Marshal.load Marshal.dump(hash) end
[ "def copy_hash(hashin)\n hashin.deep_clone\n end", "def initialize_copy(orig)\n @hash = orig.to_h.dup\n end", "def copy &alter\n Rumor.new(hash).tap &alter\n end", "def clone_hash(value)\n if value.is_a?(Hash)\n result = value.dup\n value.each { |k, v| result[k] = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Require that a guard condition passes Simply checks that the guard is truthy, and throws an error otherwise
def require_that guard, message, return_guard = false if not guard then raise ExpectationFailedError.new(message) end if return_guard == true then guard elsif return_guard != false then return_guard end end
[ "def assert cond\n fail! unless cond\n end", "def require_that guard, message, alt_result = nil #return_guard = false\n unless guard then\n raise ExpectationFailedError.new(message)\n end\n if alt_result.nil? then\n guard\n else\n alt_result\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /user_work_skills/1 PATCH/PUT /user_work_skills/1.json
def update respond_to do |format| if @user_work_skill.update(user_work_skill_params) format.html { redirect_to action:"index",:user_work_experience_role_id=>@user_work_skill.user_work_experience_role_id } format.json { render :show, status: :ok, location: @user_work_skill } else ...
[ "def update\n @skill = current_user.skills.find(params[:id])\n\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n format.html { redirect_to @skill, notice: 'Skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /controlpltkts GET /controlpltkts.json
def index @controlpltkts = Controlpltkt.all end
[ "def index\n @controltltkts = Controltltkt.all\n end", "def index\n @controlpnytts = Controlpnytt.all\n end", "def index\n @controltnytts = Controltnytt.all\n end", "def create\n @controlpltkt = Controlpltkt.new(controlpltkt_params)\n\n respond_to do |format|\n if @controlpltkt.save\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /controlpltkts POST /controlpltkts.json
def create @controlpltkt = Controlpltkt.new(controlpltkt_params) respond_to do |format| if @controlpltkt.save format.html { redirect_to @controlpltkt, notice: 'Controlpltkt was successfully created.' } format.json { render :show, status: :created, location: @controlpltkt } else ...
[ "def create\n @tnpsc = Tnpsc.new(tnpsc_params)\n\n respond_to do |format|\n if @tnpsc.save\n format.html { redirect_to @tnpsc, notice: 'Tnpsc was successfully created.' }\n format.json { render :show, status: :created, location: @tnpsc }\n else\n format.html { render :new }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /controlpltkts/1 PATCH/PUT /controlpltkts/1.json
def update respond_to do |format| if @controlpltkt.update(controlpltkt_params) format.html { redirect_to @controlpltkt, notice: 'Controlpltkt was successfully updated.' } format.json { render :show, status: :ok, location: @controlpltkt } else format.html { render :edit } ...
[ "def update\n respond_to do |format|\n if @controlpnytt.update(controlpnytt_params)\n format.html { redirect_to @controlpnytt, notice: 'Controlpnytt was successfully updated.' }\n format.json { render :show, status: :ok, location: @controlpnytt }\n else\n format.html { render :edit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /controlpltkts/1 DELETE /controlpltkts/1.json
def destroy @controlpltkt.destroy respond_to do |format| format.html { redirect_to controlpltkts_url, notice: 'Controlpltkt was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @controltltkt.destroy\n respond_to do |format|\n format.html { redirect_to controltltkts_url, notice: 'Controltltkt was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @controlqltkt.destroy\n respond_to do |format|\n format.h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Init with exception message and response object if one is available
def initialize(httpMsg, responseObj = nil) @response = responseObj super("An error occurred executing the HTTP request: #{httpMsg}") end
[ "def initialize(message = nil, response = nil)\n @response = response\n @code = response.code\n\n json = JSON.parse(response.body)\n api_message = json['error'] || json['errors']\n\n message ||= ''\n message = \"#{message} #{api_message}\"\n\n super(message, response)\n rescue ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Equality. All false instances are equal each other, plus a FalseClass instance is also equal to this.
def == other case other when FalseClass, self.class true else false end end
[ "def false?\n FalseClass === self\n end", "def ==(other)\n return false unless super\n self.force == other.force\n end", "def ==(other)\n return false if other.class != self.class\n hash_attr_diff(self) == hash_attr_diff(other)\n end", "def ==(other)\n return false if other.cl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
attempts to set the number showing to number and returns if cheat was successful
def cheat number if number > 0 && number < 7 @numberShowing = number return true end return false end
[ "def cheat( number )\n if number.between?(1,6)\n @number_showing = number\n else\n puts \"You are not a very smart cheater.\"\n end\n end", "def check(number)\n \n end", "def tricky_number\n if true \n number = 1\n else\n 2\n end\nend", "def nummerieren(nr)\n \n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the number showing
def showing return @numberShowing end
[ "def show_number\n @number_showing\n end", "def showing \n @numberShowing\n end", "def number\n content_tag('span', @question.position.to_s + '. ', :class => :number )\n end", "def display(number)\n number % 1 == 0 ? number.to_i.to_s : number.to_s\n end", "def number_s\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Changes the value of the given name stored in the S3Object's metadata: object = bucket.object['myobject'] object.metadata['purpose'] = 'research' object.metadata['purpose'] => 'research'
def []= name, value raise "cannot change the metadata of an object version; "+ "use S3Object#write to create a new version with different metadata" if @version_id metadata = to_h.dup metadata[name.to_s] = value object.copy_from(object.key, :me...
[ "def set_metadata\n s3_obj.metadata[\"filename\"] = file_name\n s3_obj.metadata[\"bindery-pid\"] = persistent_id\n end", "def overwrite_metadata(metadata, section, key, value); end", "def name(name)\n @metadata = @metadata.with_name(name)\n end", "def update_metadata_field(field_name, v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /testreplyposts GET /testreplyposts.json
def index @testreplyposts = Testreplypost.all end
[ "def index\n @replies = Reply.all\n\n render json: @replies\n end", "def index\n @post_replies = PostReply.all\n end", "def index\n @replies = Reply.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @replies }\n end\n end", "def new\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /testreplyposts POST /testreplyposts.json
def create @testreplypost = Testreplypost.new(testreplypost_params) respond_to do |format| if @testreplypost.save format.html { redirect_to @testreplypost, notice: 'Testreplypost was successfully created.' } format.json { render :show, status: :created, location: @testreplypost } el...
[ "def create\n @post = Post.find(params[:post_id])\n @reply = @post.replies.new(reply_params)\n\n respond_to do |format|\n if @reply.save\n format.html { redirect_to @post, notice: \"Reply was successfully created.\" }\n format.json { render :show, status: :created, location: @reply }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /testreplyposts/1 DELETE /testreplyposts/1.json
def destroy @testreplypost.destroy respond_to do |format| format.html { redirect_to testreplyposts_url, notice: 'Testreplypost was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @reply = Reply.find(params[:id])\n @reply.destroy\n\n respond_to do |format|\n format.html { redirect_to replies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @reply_vote = ReplyVote.find(params[:id])\n @reply_vote.destroy\n\n respond_to do |format|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /commodities/1 GET /commodities/1.json
def show @commodity = Commodity.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @commodity } end end
[ "def index\n @commodities = PlanetaryCommodity.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commodities }\n end\n end", "def index\n @commodities = Commodity.all\n end", "def index\n @commodities = Commodity.all\n if params[:search...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /commodities/new GET /commodities/new.json
def new @commodity = Commodity.new respond_to do |format| format.html # new.html.erb format.json { render json: @commodity } end end
[ "def new\n @commodity = Commodity.new\n @ingredients = Ingredient.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commodity }\n end\n end", "def create\n @commodity = Commodity.new(commodity_params)\n\n respond_to do |format|\n if @commod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /commodities POST /commodities.json
def create @commodity = Commodity.new(commodity_params) respond_to do |format| if @commodity.save format.html { redirect_to commodities_url, notice: 'Commodity was successfully created.' } format.json { render json: @commodity, status: :created, location: @commodity } else f...
[ "def create\n @commodity = Commodity.new(params[:commodity])\n\n respond_to do |format|\n if @commodity.save\n format.html { redirect_to @commodity, notice: 'Commodity was successfully created.' }\n format.json { render json: @commodity, status: :created, location: @commodity }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /commodities/1 PUT /commodities/1.json
def update @commodity = Commodity.find(params[:id]) respond_to do |format| if @commodity.update_attributes(commodity_params) format.html { redirect_to commodities_url, notice: 'Commodity was successfully updated.' } format.json { head :no_content } else format.html { render ...
[ "def update\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n if @commodity.update_attributes(params[:commodity])\n format.html { redirect_to @commodity, notice: 'Commodity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /commodities/1 DELETE /commodities/1.json
def destroy @commodity = Commodity.find(params[:id]) @commodity.destroy respond_to do |format| format.html { redirect_to commodities_url } format.json { head :no_content } end end
[ "def destroy\n @commodity.destroy\n respond_to do |format|\n format.html { redirect_to commodities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @commodoty.destroy\n respond_to do |format|\n format.html { redirect_to commodoties_url, notice: 'Commodoty was su...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The definition of the ranks for this board. By default it will be files 1 .. 8. You can change this by initializing the board with a different range.
def ranks Outpost::Config.instance.ranks end
[ "def ranks\n @ranks ||= RANK_RANGE.map(&:to_i)\n end", "def ranks\n @ranks ||= (viewed_from_side == :black) ? Chess::Ranks : Chess::Ranks.reverse\n end", "def rank_names\n (1..8).to_a\n end", "def card_ranks\n load_cards_data['ranks']\n end", "def rank=(value)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This helper will give you a way to cycle the colors
def cycled_colors @cycled_colors ||= colors.cycle end
[ "def colourable_cycle(colours, speed)\n @colourable_loop = true\n colourable_start_list(colours, speed)\n end", "def cycle colors=[], delay=0.5\n unless colors.all? {|c| COLORS.include? c}\n raise \"Invalid color\"\n end\n\n reset\n\n @thread = Thread.new do\n i = 0\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse the JSON from all VMs and templates. Then return an array of objects (without duplicates)
def read_vms_info vms_arr = json([]) do execute_prlctl('list', '--all','--info', '--json') end templates_arr = json([]) do execute_prlctl('list', '--all','--info', '--json', '--template') end vms_arr | templates_arr end
[ "def read_vms_info\n args = %w(list --all --info --no-header --json)\n vms_arr = json([]) { execute_prlctl(*args) }\n templates_arr = json([]) { execute_prlctl(*args, '--template') }\n\n vms_arr | templates_arr\n end", "def read_all_info\n vms_arr = json({}) do\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /videos/list GET /videos/list.json
def list @videos = Video.all respond_to do |format| format.html # list.html.erb format.json { render json: @videos } end end
[ "def list(options = {})\n make_request(:get, \"/videos\", options)\n end", "def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end", "def index\n @videos = Video.all\n render json: @videos\n end", "def video_list(login = nil, authenticated = false, page=1)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
source can take any of the following as arguments A single string argument Multiple string arguments An array or strings A delayed evaluator that evaluates to a string or array of strings All strings must be parsable as URIs. source returns an array of strings.
def source(*args) arg = parse_source_args(args) ret = set_or_return(:source, arg, { callbacks: { validate_source: method(:validate_source), } }) if ret.is_a? String Array(ret) else ret end end
[ "def source(*args)\n arg = parse_source_args(args)\n ret = set_or_return(:source,\n arg,\n { :callbacks => {\n :validate_source => method(:validate_source),\n } })\n if ret.is_a? St...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }