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 |
|---|---|---|---|---|---|---|
Attempts to create a new product redirect '/create' | def skapa_produkt(params, userid)
val = validate_create(params)
if val == false
return {
error: true,
message: "something empty"
}
end
titel = params["titel"]
description = params["description"]
price = params["price"]
image = params["img"]
type = image["type"].split("/")[-1]
new_name = SecureRandom.uuid + "." + type
db = connect()
FileUtils.cp(image["tempfile"].path, 'public/uploads/' + new_name)
db.execute("INSERT INTO Product (titel,description,price,userid,img) VALUES (?,?,?,?,?)",titel,description,price,userid,new_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.create( product_params )\n redirect_to '/products'\nend",
"def create\n @product = Product.create( product_params )\n redirect_to '/products'\nend",
"def create\n @product = Product.create( params[:product] )\n #this redirect only applies for when the product w... | [
"0.81530344",
"0.81530344",
"0.7980499",
"0.7829527",
"0.77743673",
"0.77606773",
"0.7727944",
"0.7727616",
"0.7721866",
"0.7705496",
"0.770474",
"0.76803404",
"0.7651549",
"0.7606655",
"0.75777984",
"0.7545432",
"0.75445664",
"0.7524616",
"0.75131273",
"0.7510534",
"0.749779... | 0.0 | -1 |
Fetches first 5 rows in product database | def get_products()
db = connect()
result = db.execute("SELECT id, titel, description, price, userid, img FROM Product LIMIT 5")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(n=1)\n query(@sql + ' LIMIT ' + n.to_s, cache: false)\n end",
"def landing_page\n @products = Product.limit(3) \n end",
"def latest_five\n self.find :all, :limit=>5, :order => \"created_at desc\"\n end",
"def take(num=1)\n if num > 1\n rows = connection.execute <<-SQ... | [
"0.69186",
"0.66685486",
"0.66238135",
"0.6423952",
"0.6221952",
"0.6192801",
"0.61306405",
"0.61162806",
"0.6076306",
"0.6064676",
"0.60339755",
"0.60064745",
"0.59551674",
"0.5916164",
"0.5879985",
"0.5845748",
"0.57677287",
"0.5760091",
"0.575608",
"0.5751547",
"0.5670129"... | 0.71212834 | 0 |
Adds product selected to users cart database and uppdates amount if product previously had been added | def add_cart(params, userid)
id = params["product_id"]
db = connect()
result = db.execute("SELECT * FROM ProduCart WHERE user_id = ? AND product_id = ?",userid, id)
if result.length > 0
db.execute("UPDATE ProduCart SET antal = antal + 1 WHERE user_id = ? AND product_id = ?",userid,id)
else
db.execute("INSERT INTO ProduCart (product_id,user_id,antal) VALUES (?,?,?)",id,userid, 1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_cart\n @cart = current_user.carts.find_or_create_by(completed: false)\n @line_item = @cart.line_items.find_or_create_by(product_id: params[:product_id])\n @line_item.update quantity: @line_item.quantity + 1\n end",
"def add_to_cart(product)\n @products << product\n @sub_total += produc... | [
"0.76689506",
"0.7493448",
"0.7405807",
"0.7401978",
"0.7313946",
"0.7283929",
"0.72731215",
"0.72219276",
"0.71915746",
"0.7173938",
"0.714771",
"0.70888865",
"0.7084782",
"0.7074948",
"0.70672506",
"0.70521355",
"0.70327",
"0.7013152",
"0.69985527",
"0.69970095",
"0.6992186... | 0.71350574 | 11 |
Creates visible cart personal to user by selecting product information and cart information | def get_cart(userid)
db = connect()
result = db.execute("SELECT Product.id, Product.titel, Product.description, Product.price, Product.userid, Product.img, ProduCart.antal, ProduCart.product_id FROM Product INNER JOIN ProduCart ON Product.id = ProduCart.product_id WHERE user_id =?",userid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # grabbing cart from application controller current_cart method\n @cart = current_cart\n # session[:cart_id] = @cart.id\n # individual product items get added to cart item and added to cart and saved\n @cart_item = @cart.cart_items.build(cart_item_params)\n @cart.save\n end",
"def... | [
"0.726473",
"0.71267754",
"0.69952375",
"0.697385",
"0.6883869",
"0.68807435",
"0.6869921",
"0.6856334",
"0.6833856",
"0.6819074",
"0.6797873",
"0.67907244",
"0.67876947",
"0.67723835",
"0.67284244",
"0.6722781",
"0.6722141",
"0.6713615",
"0.6691501",
"0.66608953",
"0.6648593... | 0.0 | -1 |
Removes selected product from cart | def remove(params, userid)
id = params["product_id"]
db = connect()
result = db.execute("DELETE FROM ProduCart WHERE product_id = ? AND user_id = ?",id,userid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_product(name)\n @products_in_cart.delete(Product)\nend",
"def remove_from_cart\n Cart.remove_from_cart(session[:cart], params[:id])\n redirect_to show_cart_products_path\n end",
"def remove_product(name)\n @cart_items = @cart_items.select do |item|\n item.name != name\n end\n end... | [
"0.7909089",
"0.7474331",
"0.73775285",
"0.736409",
"0.7358405",
"0.73409086",
"0.7320551",
"0.730285",
"0.72924674",
"0.72595614",
"0.72488695",
"0.72404253",
"0.71632403",
"0.7159684",
"0.71495056",
"0.7142633",
"0.7140317",
"0.712586",
"0.7105761",
"0.70777345",
"0.7075642... | 0.6346352 | 78 |
Use callbacks to share common setup or constraints between actions. | def set_hairstyle
@hairstyle = Hairstyle.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the internet, only allow the white list throughj. | def hairstyle_params
params.require(:hairstyle).permit(:style, :image_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_params_authentication!; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def check_params; true; end",
"def strong_... | [
"0.7085893",
"0.6459565",
"0.6281302",
"0.62428606",
"0.62302023",
"0.6168435",
"0.608429",
"0.60763985",
"0.60737795",
"0.6050914",
"0.6000718",
"0.5982888",
"0.5969225",
"0.59691215",
"0.5961157",
"0.5932711",
"0.58666945",
"0.5859118",
"0.5847172",
"0.5837114",
"0.5820634"... | 0.0 | -1 |
Override this method in your controller to get current_user. | def user_for_vestal_versions; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n get_from_options_or_controller(:current_user)\n end",
"def get_user\n @current_user = current_user\n end",
"def current_user\n\t\tview_context.current_user\n\tend",
"def current_user\n @current_user ||= authorize_request\n end",
"def current_user\n @current... | [
"0.86228776",
"0.8516442",
"0.8434702",
"0.84066635",
"0.8361182",
"0.8361182",
"0.83535296",
"0.8349328",
"0.8349328",
"0.8349328",
"0.8349328",
"0.8349328",
"0.8349328",
"0.8349328",
"0.8349328",
"0.83361906",
"0.8332966",
"0.83164483",
"0.8315593",
"0.830756",
"0.8305677",... | 0.0 | -1 |
if book's checkout id matches current_id if book'd id matched current_id | def just_added? #TODO: improve
created_at + 4.days > Time.zone.now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_out_book(book_id, borrower)\n #Runs through each book in the library\n @books.each do |book|\n #If the book's id matches the id of the checkout id,\n #tries to check the book out\n if book.id == book_id && book.check_out(borrower)\n borrower.checked_out << book\n return... | [
"0.64777637",
"0.6468187",
"0.6388537",
"0.6381281",
"0.63414526",
"0.6331811",
"0.6293747",
"0.6244156",
"0.6215258",
"0.6080385",
"0.60742456",
"0.6054469",
"0.6043288",
"0.60092163",
"0.60061496",
"0.5973762",
"0.5966721",
"0.5932448",
"0.59176207",
"0.59118646",
"0.590638... | 0.0 | -1 |
Iterate over the pages. | def each_page
return enum_for :each_page unless block_given?
loop do
break if @page.nil?
yield @page
next_page!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_page\n page_obj = load_page(1)\n loop do\n yield page_obj\n break unless page_obj.has_next?\n page_obj = load_page(page_obj.next_page)\n end\n end",
"def each_page(&block); end",
"def each\n page = Page.new @uri, @filters, @headers\n until page.nil?... | [
"0.77524847",
"0.7692155",
"0.75988823",
"0.73805964",
"0.73350966",
"0.7297736",
"0.71546745",
"0.71435505",
"0.71083444",
"0.69794106",
"0.6969692",
"0.6964266",
"0.692602",
"0.6915897",
"0.68610567",
"0.68605036",
"0.68471956",
"0.68117243",
"0.6780891",
"0.6777255",
"0.67... | 0.7326349 | 5 |
True if it has the next page. | def next_page?
@page.next_page_token?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_next?\n return self.current_page != self.total_pages && self.total_pages > 1\n end",
"def has_next_page\n if first\n paged_nodes.length >= first\n else\n false\n end\n end",
"def has_next_page?\n @current_page < page_count\n end",
"def h... | [
"0.8867417",
"0.8810399",
"0.8796267",
"0.87511414",
"0.8717775",
"0.87151986",
"0.8700311",
"0.8688514",
"0.867125",
"0.8639595",
"0.8562574",
"0.84730244",
"0.8441148",
"0.83216757",
"0.81949306",
"0.81871074",
"0.81414413",
"0.8084883",
"0.7848749",
"0.77575445",
"0.774659... | 0.8552243 | 11 |
Update the response in the current page. | def next_page!
unless next_page?
@page = nil
return @page
end
next_request = @request.dup
next_request.page_token = @page.next_page_token
@grpc_stub.call_rpc @method_name, next_request, options: @options do |next_response, next_operation|
@page = Page.new next_response, @resource_field, next_operation, format_resource: @format_resource
end
@page
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh(response)\n @code = response.code\n @body = response.body\n @next_page = response.next_page\n response\n end",
"def response_handler( request, response )\n return response if response.scope.out? || !response.text? ||\n response.code == 304\n\n ... | [
"0.6656315",
"0.6642924",
"0.6475819",
"0.6471291",
"0.6463367",
"0.640535",
"0.64013004",
"0.6285323",
"0.6245627",
"0.61608756",
"0.6152384",
"0.6152355",
"0.61494684",
"0.61456174",
"0.613375",
"0.61101425",
"0.60568184",
"0.6055713",
"0.6027203",
"0.59705776",
"0.595932",... | 0.0 | -1 |
The page token to be used for the next RPC call. | def next_page_token
@page.next_page_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page_token\n @response.next_page_token\n end",
"def next_page_token\n return if @response.nil?\n\n @response.next_page_token\n end",
"def next_page_token\n # puts \"Next Page Token report: #{report.report}\"\n report.next_page_token\n end",
"def next_p... | [
"0.8214915",
"0.8034675",
"0.78933346",
"0.7810605",
"0.7792588",
"0.652583",
"0.6521095",
"0.6507621",
"0.6500331",
"0.64198446",
"0.6417449",
"0.64081246",
"0.6397281",
"0.6371535",
"0.63595754",
"0.6355078",
"0.633611",
"0.6315322",
"0.6281704",
"0.62683105",
"0.6258892",
... | 0.8148076 | 1 |
The current response object, for the current page. | def response
@page.response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_page\n response[\"current_page\"]\n end",
"def response\n @page&.response\n end",
"def current_page\n return unless response.headers['PaginationCurrentPage']\n response.headers['PaginationCurrentPage'].to_i\n end",
"def response\n @_response\n en... | [
"0.7775949",
"0.76681817",
"0.69234663",
"0.6887135",
"0.68052834",
"0.68052834",
"0.67892176",
"0.6789127",
"0.6722892",
"0.6721052",
"0.66058004",
"0.66058004",
"0.6588276",
"0.6581627",
"0.656762",
"0.6551719",
"0.65272725",
"0.6505685",
"0.64634484",
"0.6452353",
"0.64148... | 0.7708566 | 1 |
Iterate over the resources. | def each
return enum_for :each unless block_given?
return if @response.nil?
# We trust that the field exists and is an Enumerable
@response[@resource_field].each do |resource|
resource = @format_resource.call resource if @format_resource
yield resource
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n @resources.each_pair {|k, v| yield(k, v)}\n end",
"def iterate resource, &block\n data = YAML.load_file \"#{@path}/#{resource}\" # cached file may be either in YAML or JSON format\n data['items'].each do |i|\n yield(i)\n end\n nil\n end",
... | [
"0.77442795",
"0.70580053",
"0.6977858",
"0.6912148",
"0.68508005",
"0.676971",
"0.67362535",
"0.67194784",
"0.6612272",
"0.6609677",
"0.66019243",
"0.6590125",
"0.65486556",
"0.6534017",
"0.65206075",
"0.6493249",
"0.6408933",
"0.6383589",
"0.63534254",
"0.63294744",
"0.6325... | 0.64401203 | 16 |
The page token to be used for the next RPC call. | def next_page_token
return if @response.nil?
@response.next_page_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page_token\n @response.next_page_token\n end",
"def next_page_token\n @page.next_page_token\n end",
"def next_page_token\n # puts \"Next Page Token report: #{report.report}\"\n report.next_page_token\n end",
"def next_page_token\n @page&.next_page_token\n ... | [
"0.8215477",
"0.8147788",
"0.7893065",
"0.7810384",
"0.7792135",
"0.6526964",
"0.6520517",
"0.6507424",
"0.65018344",
"0.64208496",
"0.64166164",
"0.6409534",
"0.63985246",
"0.6370565",
"0.6359636",
"0.6354527",
"0.63375235",
"0.63147676",
"0.6282915",
"0.6270543",
"0.6259861... | 0.8035044 | 2 |
Convenient way to call the current player | def current_player
@players[@turn%2]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player\n\t\t@current_player\n\tend",
"def getCurrentPlayer() # : Player\n @currentPlayer\n end",
"def player \n \"player\" \n end",
"def set_player\n\n end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"de... | [
"0.78647006",
"0.7761586",
"0.7635443",
"0.7536276",
"0.7529723",
"0.7529723",
"0.7529723",
"0.7529723",
"0.7529723",
"0.7529723",
"0.7529723",
"0.7512523",
"0.7323313",
"0.7288553",
"0.7266765",
"0.72514486",
"0.72091573",
"0.71792614",
"0.713055",
"0.71135867",
"0.70996267"... | 0.6592573 | 52 |
Asks the player for a valid move Keeps asking and displaying the current turn number and current player. Returns the player's choice, and which player made that choice. | def valid_move
display_current_turn
col = prompt_legal_move
return col, @turn%2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_move\n puts \"#{current_player}, select a cell to place your #{whose_turn}. Select a number between 1 - 9.\"\n move = gets.chomp.to_i\n puts\n\n # If move is valid and is not taken, then create a key-value pair in @taken: number => X or O.\n if valid_move?(move) && !taken?(move)\n @t... | [
"0.7881849",
"0.77230155",
"0.7349367",
"0.73252445",
"0.73124266",
"0.72790235",
"0.7255166",
"0.7188375",
"0.7187313",
"0.7117133",
"0.71164274",
"0.7105686",
"0.7103325",
"0.70866036",
"0.70616966",
"0.7031488",
"0.7018123",
"0.7018123",
"0.69988626",
"0.6988751",
"0.69754... | 0.7317817 | 4 |
Displays the current turn and current player. | def display_current_turn
puts "Turn #{@turn + 1}, Player #{(@turn % 2) + 1}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_turn\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.move_info(@turn, @player_to_move, FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data))\n end",
"def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @boar... | [
"0.7741393",
"0.7280996",
"0.7072762",
"0.7060325",
"0.69567937",
"0.6937752",
"0.6886708",
"0.6819705",
"0.6723661",
"0.667055",
"0.66383725",
"0.66360635",
"0.6629128",
"0.6616426",
"0.65871185",
"0.6578952",
"0.6571608",
"0.65692323",
"0.65591455",
"0.6555349",
"0.65455246... | 0.8251152 | 0 |
Prompts the player until the player makes a move that is allowed Disallows playing moves on full columns. | def prompt_legal_move
col = current_player.move
while @board.col_full?(col)
display_invalid_move_error
col = current_player.move
end
return col
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt_movement\n mov = 0\n\tloop do\n\t print \"\\n#{@cur_player.name}, choose your movement (1-7): \"\n\t mov = gets.chomp.to_i\n\t if (1..7).include? mov\n\t break if @board.is_available? mov\n\t\t puts \"That column is totally full! Try other choice...\" \n\t else\n\t\tputs \"Invalid choice! Tr... | [
"0.73935777",
"0.71697634",
"0.65858984",
"0.6548148",
"0.6418025",
"0.64150894",
"0.63843864",
"0.6283386",
"0.6263231",
"0.6247459",
"0.62325007",
"0.621945",
"0.612146",
"0.611229",
"0.5971143",
"0.59565836",
"0.5955391",
"0.5907186",
"0.589948",
"0.58923227",
"0.5874767",... | 0.73054093 | 1 |
Displays an error if the column is full, redraws the board | def display_invalid_move_error
puts "That column is full."
@board.display
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_checker(color, column)\n\n if column < 0 || column > 6\n puts \"Insert a column number 0-6!\"\n return false\n end\n \n \n if color != :red && color != :black\n puts \"Color must be red or black!\"\n return false\n end\n \n 5.downto 0 do |row| #Counts down to ze... | [
"0.6586569",
"0.658574",
"0.6548218",
"0.6395221",
"0.63811237",
"0.6378894",
"0.6332703",
"0.630311",
"0.625447",
"0.6239694",
"0.6224339",
"0.6224339",
"0.61883575",
"0.6182491",
"0.6168422",
"0.6168176",
"0.6147369",
"0.61381865",
"0.6135374",
"0.61300826",
"0.61295426",
... | 0.81413305 | 0 |
GET /archives GET /archives.json | def index
@archives = Archive.all
after = "2012-11-01T13:00:00Z"
before= "2012-11-02T03:12:14-03:00"
time_span = get_time_span(after,before)
gz = open('http://data.githubarchive.org/2015-01-01-0.json.gz')
# gz = open("http://data.githubarchive.org/#{time_span}.json.gz")
js = Zlib::GzipReader.new(gz).read
# #
Yajl::Parser.parse(js) do |event|
if event["type"] == "PushEvent"
archive_params = {:user_id => event["actor"]["id"], :name => event["actor"]["login"]}
@archive = Archive.new(archive_params)
@archive.save
end
end
# Aggregate and get top
@archives = Archive.group('name').limit(42).order('count_user_id desc').count(:user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n logger.debug \"cm/archives/index - session_id: #{request.session_options[:id]}\"\n @archives = @current_user.archives\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @archives }\n end\n end",
"def index\n @archivs = Archiv.all\n\n ... | [
"0.72945553",
"0.7168367",
"0.70502347",
"0.70501184",
"0.6998091",
"0.6901087",
"0.6810743",
"0.67816174",
"0.67592233",
"0.6749067",
"0.6741819",
"0.66733754",
"0.6563189",
"0.6472267",
"0.6427908",
"0.6416785",
"0.64099044",
"0.6405682",
"0.636842",
"0.63485575",
"0.633454... | 0.6430807 | 14 |
GET /archives/1 GET /archives/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\r\n @archive = Archive.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @archive }\r\n end\r\n end",
"def index\n logger.debug \"cm/archives/index - session_id: #{request.session_options[:id]}\"\n @archives = @curre... | [
"0.72391295",
"0.7049682",
"0.7043843",
"0.6900624",
"0.68119335",
"0.67751086",
"0.67529154",
"0.6659271",
"0.66580045",
"0.6607462",
"0.65362954",
"0.65265006",
"0.6490124",
"0.64660543",
"0.6438458",
"0.63519716",
"0.63514143",
"0.6330227",
"0.62908137",
"0.62900555",
"0.6... | 0.0 | -1 |
POST /archives POST /archives.json | def create
@archive = Archive.new(archive_params)
respond_to do |format|
if @archive.save
format.html { redirect_to @archive, notice: 'Archive was successfully created.' }
format.json { render :show, status: :created, location: @archive }
else
format.html { render :new }
format.json { render json: @archive.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive\n perform_action(:post, 'archive')\n end",
"def create\n @admin_archive = Admin::Archive.new(admin_archive_params)\n\n respond_to do |format|\n if @admin_archive.save\n format.html { redirect_to @admin_archive, notice: 'Archive was successfully created.' }\n f... | [
"0.70212984",
"0.67613447",
"0.66497225",
"0.65885437",
"0.65765387",
"0.6448465",
"0.6437066",
"0.6426747",
"0.63996536",
"0.63950205",
"0.6349843",
"0.6278518",
"0.6180478",
"0.61782676",
"0.6084722",
"0.6065101",
"0.6046252",
"0.6002244",
"0.59738153",
"0.5963901",
"0.5923... | 0.70315814 | 0 |
PATCH/PUT /archives/1 PATCH/PUT /archives/1.json | def update
respond_to do |format|
if @archive.update(archive_params)
format.html { redirect_to @archive, notice: 'Archive was successfully updated.' }
format.json { render :show, status: :ok, location: @archive }
else
format.html { render :edit }
format.json { render json: @archive.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @archive = Archive.find(params[:id])\n\n respond_to do |format|\n if @archive.update_attributes(params[:archive])\n format.html { redirect_to @archive, notice: 'Archive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | [
"0.6946667",
"0.6888048",
"0.6837183",
"0.6795341",
"0.64818853",
"0.64702034",
"0.635269",
"0.6105549",
"0.60802525",
"0.60128284",
"0.59557366",
"0.5954308",
"0.59206367",
"0.58993983",
"0.5883104",
"0.5868791",
"0.58581233",
"0.5811836",
"0.580994",
"0.5800285",
"0.5796989... | 0.6893872 | 1 |
DELETE /archives/1 DELETE /archives/1.json | def destroy
@archive.destroy
respond_to do |format|
format.html { redirect_to archives_url, notice: 'Archive was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @archive = Archive.find(params[:id])\n @archive.destroy\n\n respond_to do |format|\n format.html { redirect_to archives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @archive = Archive.find(params[:id])\r\n @archive.destroy\r\n\r\n respond_t... | [
"0.7674642",
"0.7646406",
"0.7496393",
"0.7487134",
"0.7442315",
"0.7235196",
"0.71357626",
"0.7096368",
"0.7094761",
"0.69994605",
"0.6902356",
"0.688992",
"0.6868009",
"0.6841512",
"0.6785881",
"0.6738185",
"0.6700274",
"0.6687805",
"0.6685919",
"0.6679886",
"0.6646337",
... | 0.7438316 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_archive
@archive = Archive.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Returns the configuration options set up by the API DSL. | def configuration
if options[:log].nil? ||
options[:log] == false ||
empty_value?(options[:log])
Vedeu.log(type: :config,
message: 'Logging has been disabled.')
return options
end
log_options!
if options[:log] != default[:log]
Vedeu.log(message: "Switching to '#{options[:log]}' for logging.\n")
end
options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n config.options\n end",
"def options\n Hash[\n DeskApi::Configuration.keys.map do |key|\n [key, instance_variable_get(:\"@#{key}\")]\n end\n ]\n end",
"def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option... | [
"0.75072616",
"0.73980474",
"0.7162769",
"0.6967813",
"0.69397694",
"0.69337606",
"0.68845385",
"0.6839541",
"0.6839541",
"0.68365824",
"0.6836435",
"0.681744",
"0.681744",
"0.6814158",
"0.6770051",
"0.6740437",
"0.6698668",
"0.6695485",
"0.66941017",
"0.6693696",
"0.6680498"... | 0.0 | -1 |
Returns the options set via the configuration API DSL or an empty Hash when none were set. | def options
@options ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end",
"def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def options\n Hash[ * VALID_CONFIG_KEYS.map { ... | [
"0.76995134",
"0.75825864",
"0.75825864",
"0.7579396",
"0.75395936",
"0.7497548",
"0.74190676",
"0.74028426",
"0.73555547",
"0.73555547",
"0.73041546",
"0.72996",
"0.7267906",
"0.7257727",
"0.72551405",
"0.722897",
"0.7221074",
"0.7196294",
"0.71940523",
"0.7188353",
"0.71792... | 0.7166108 | 24 |
Checks that the mode provided is valid. | def valid_mode?(mode)
[:cooked, :fake, :raw].include?(mode)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_mode?\n unless self.target_mode.nil?\n !!(self.mode == (\"%o\" % self.target_mode))\n else\n return true\n end\n end",
"def modeValid(num)\n if num == 1 || num == 2 || num == 3 || num == 4\n return true \n else \n return false \n end \nend",
"def has_mode?(mod... | [
"0.7409777",
"0.6570452",
"0.6549297",
"0.6409861",
"0.6365006",
"0.6336408",
"0.6261177",
"0.6121299",
"0.60873955",
"0.59560657",
"0.59138584",
"0.5871032",
"0.584986",
"0.584695",
"0.584695",
"0.58452904",
"0.5834596",
"0.5822985",
"0.5792129",
"0.5790146",
"0.57755345",
... | 0.765895 | 0 |
GET /api/v1/users GET /api/v1/users.json | def index
@users = User.all.paginate(page: params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def list_users\n self.class.get('/users')\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/us... | [
"0.82608825",
"0.82532614",
"0.823534",
"0.80026495",
"0.7961939",
"0.7833599",
"0.77928776",
"0.7771292",
"0.773399",
"0.77230394",
"0.7712092",
"0.7627392",
"0.76154006",
"0.7597347",
"0.7587636",
"0.75763905",
"0.7546426",
"0.7539526",
"0.75372",
"0.7493484",
"0.7485239",
... | 0.0 | -1 |
POST /api/v1/users POST /api/v1/users.json | def create
@user = User.new(user_params)
if @user.save
render :show, status: :created
else
render json: { errors: @user.errors }, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.78390914",
"0.76277596",
"0.7443128",
"0.73065007",
"0.71457803",
"0.7145322",
"0.71377903",
"0.70750296",
"0.7067702",
"0.7052675",
"0.7041942",
"0.6991087",
"0.6973718",
"0.6968693",
"0.6948147",
"0.69265383",
"0.69261175",
"0.6910822",
"0.6897997",
"0.6880794",
"0.68734... | 0.0 | -1 |
PATCH/PUT /api/v1/users/1 PATCH/PUT /api/v1/users/1.json | def update
@user = User.find(params[:id])
delete_password_if_blank?
if @user.update_attributes(user_params)
render :show
else
render json: { errors: @user.errors }, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"de... | [
"0.72893524",
"0.7247642",
"0.71839464",
"0.6944086",
"0.69212854",
"0.6908286",
"0.6870837",
"0.6836403",
"0.68059564",
"0.6788472",
"0.6744813",
"0.67369354",
"0.6726304",
"0.67145914",
"0.67015016",
"0.6678625",
"0.6661589",
"0.6660037",
"0.6659795",
"0.66572565",
"0.66542... | 0.0 | -1 |
DELETE /api/v1/users/1 DELETE /api/v1/users/1.json | def destroy
@user.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def destroy\n @user = User.find_by_id_or_username p... | [
"0.82753915",
"0.7935632",
"0.7812396",
"0.7806802",
"0.78008574",
"0.77818805",
"0.775864",
"0.7716223",
"0.7700618",
"0.7692295",
"0.7692295",
"0.7686925",
"0.76847",
"0.7682701",
"0.76761824",
"0.76607054",
"0.7595786",
"0.7583825",
"0.75627106",
"0.75623715",
"0.7552018",... | 0.0 | -1 |
Called by ajax, no standalone view. | def recieve_hash
#recvd_json = params[:q_data]
#p recvd_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rendered; end",
"def render; end",
"def render; end",
"def render; end",
"def render; end",
"def render; end",
"def ajax_view\n\t\t\n\t\t@project = Project.find(params[:id])\n\t\t\n\t\trespond_to do |f|\n\t\t\tf.js { render :layout => false }\n\t\tend\n\t\t\n\tend",
"def _view; end",
"def xhr?;... | [
"0.6690121",
"0.6592628",
"0.6592628",
"0.6592628",
"0.6592628",
"0.6592628",
"0.64014584",
"0.63015425",
"0.6245408",
"0.6238792",
"0.6227963",
"0.6159451",
"0.6159451",
"0.6159451",
"0.6150232",
"0.61404324",
"0.6138704",
"0.6129733",
"0.6046752",
"0.6020289",
"0.6019263",
... | 0.0 | -1 |
O(n^2) quadratic time O(1) constant space | def two_sum?(arr, target_sum)
(0...arr.length).each do |i|
(0...arr.length).each do |j|
next if i == j
return true if arr[i] + arr[j] == target_sum
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n ... | [
"0.6619447",
"0.6348883",
"0.63056177",
"0.6272076",
"0.62075543",
"0.6203401",
"0.6125283",
"0.61078775",
"0.608317",
"0.607203",
"0.6058683",
"0.6053922",
"0.6040024",
"0.60158974",
"0.59925354",
"0.59829456",
"0.59710914",
"0.595399",
"0.5947618",
"0.59455335",
"0.5941375"... | 0.0 | -1 |
arr = [0, 1, 5, 7] p two_sum?(arr, 6) => should be true p two_sum?(arr, 10) => should be false O(nlogn) linearithmic time O(n) linear space | def two_sum1?(arr, target_sum)
sorted_arr = arr.sort
length = arr.length - 1
mid = arr.length / 2
if mid < target_sum
(0...mid).any? { |i| arr[i] + arr[i+1] == target_sum }
else
(mid...length).any? { |i| arr[i] + arr[i+1] == target_sum }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend",
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, id... | [
"0.88238335",
"0.8821176",
"0.8691647",
"0.8661616",
"0.85900646",
"0.8574698",
"0.8572501",
"0.8568893",
"0.8560614",
"0.85412925",
"0.8511847",
"0.850664",
"0.8503501",
"0.8500922",
"0.84995085",
"0.84778893",
"0.84423715",
"0.84379923",
"0.84313065",
"0.843078",
"0.8429856... | 0.82965344 | 39 |
arr = [0, 1, 5, 7] p two_sum1?(arr, 6) => should be true p two_sum1?(arr, 10) => should be false O(n) linear time O(n) linear space | def two_sum2(arr, target_sum)
hash = {}
arr.each do |el|
return true if hash[target_sum - el]
hash[el] = true
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|... | [
"0.88188547",
"0.8746783",
"0.86592215",
"0.861703",
"0.854016",
"0.8522134",
"0.8514095",
"0.8500275",
"0.8495688",
"0.8474924",
"0.84692436",
"0.84651357",
"0.8458672",
"0.84582484",
"0.8458086",
"0.84541285",
"0.84433514",
"0.8442111",
"0.8423137",
"0.84169316",
"0.8396188... | 0.0 | -1 |
Object Initialization x : window X coordinate y : window Y coordinate width : window width height : window height actor : actor object | def initialize(x, y, width, height, actor)
super(x, y, width, height)
@cCharName = CLabel.new(self, Rect.new(0,0,200,WLH), "")
@cCharName.font = Font.bold_font
@ucCharLvl = UCLabelIconValue.new(self, Rect.new(24,24,50,WLH),
Rect.new(0,24,24,24),
Rect.new(50,24,110, WLH),
Vocab::lvl_label,
MENU_CONFIG::ICON_LVL, "")
@ucCharLvl.cValue.align = 2
@ucHpStat = UCLabelIconValue.new(self, Rect.new(24,48,25,WLH),
Rect.new(0,48,24,24),
Rect.new(25,48,135, WLH),
Vocab::hp_label,
MENU_CONFIG::ICON_HP, "")
@ucHpStat.cValue.align = 2
@ucHpStatGauge = UCBar.new(self, Rect.new(0, 48+16, 162, WLH-16),
Color.hp_gauge_color1, Color.hp_gauge_color2, Color.gauge_back_color,
0, 0, 1, Color.gauge_border_color)
@ucMpStat = UCLabelIconValue.new(self, Rect.new(24,72,25,WLH),
Rect.new(0,72,24,24),
Rect.new(25,72,135, WLH),
Vocab::mp_label,
MENU_CONFIG::ICON_MP, "")
@ucMpStat.cValue.align = 2
@cMpStatGauge = UCBar.new(self, Rect.new(0, 72+16, 162, WLH-16),
Color.mp_gauge_color1, Color.mp_gauge_color2, Color.gauge_back_color,
0, 0, 1, Color.gauge_border_color)
window_update(actor)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(x, y, width)\r\n super(x, y, width, window_height)\r\n @actor = nil\r\n refresh\r\n end",
"def initialize(x, y, width, height, actors=nil)\n super(x, y, width, height, 28, 48)\n @column_max = 8\n @ucReserveActorsList = []\n window_update(actors)\n self.index = 0\n @curs... | [
"0.7318227",
"0.6772852",
"0.67486066",
"0.66927046",
"0.6659838",
"0.66378695",
"0.6507836",
"0.6499371",
"0.64447284",
"0.63915914",
"0.6360453",
"0.63550985",
"0.63517",
"0.6320773",
"0.62895703",
"0.6278781",
"0.6278287",
"0.6255408",
"0.62350446",
"0.62258357",
"0.622410... | 0.0 | -1 |
////////////////////////////////////////////////////////////////////////// Public Methods ////////////////////////////////////////////////////////////////////////// Update actor : actor object | def window_update(actor)
if actor != nil
@cCharName.text = actor.name
@ucCharLvl.cValue.text = actor.level
@ucHpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.hp, actor.maxhp)
@ucHpStatGauge.value = actor.hp
@ucHpStatGauge.max_value = actor.maxhp
if actor.hp == 0
@ucHpStat.cValue.font.color = Color.knockout_color
elsif actor.hp < actor.maxhp / 4
@ucHpStat.cValue.font.color = Color.crisis_color
else
@ucHpStat.cValue.font.color = Color.normal_color
end
@ucMpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.mp, actor.maxmp)
@cMpStatGauge.value = actor.mp
@cMpStatGauge.max_value = actor.maxmp
if actor.mp < actor.maxmp / 4
@ucMpStat.cValue.font.color = Color.crisis_color
else
@ucMpStat.cValue.font.color = Color.normal_color
end
end
refresh()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actor=(new_actor)\n return if @actor == new_actor\n\n @actor = new_actor\n refresh\n end",
"def update(actor)\n false\n end",
"def set_actor(new_actor)\n return if @actor == new_actor\n @actor = new_actor\n @last_index = 0\n deep_refresh\n self.oy = 0\n end",
"def set_actor(... | [
"0.7609755",
"0.7329467",
"0.73275244",
"0.73275244",
"0.7253327",
"0.7095407",
"0.7090661",
"0.7090661",
"0.7090661",
"0.70419794",
"0.6806354",
"0.676181",
"0.6590047",
"0.6531678",
"0.64987177",
"0.64809185",
"0.6464444",
"0.6391916",
"0.63783664",
"0.6372486",
"0.6364968"... | 0.0 | -1 |
override to enable :include action scope for fetchable attributes | def object_hash(source, include_directives)
source.context ||= {}
source.context[:action] ||= nil
action = include_directives[:include] ? :include : source.context[:action]
action_was = source.context[:action]
source.context[:action] = action if action_was != action
obj_hash = super
source.context[:action] = action_was if action_was != action
obj_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_include(params)\n # Which columns must we select?\n select = []\n # Which associations must we eager-load?\n eagers = []\n \n model.default_attrs.each do |attr|\n select += model.attr_columns[attr.to_s]\n eagers += model.attr_assoc... | [
"0.6806486",
"0.66710573",
"0.65365046",
"0.6516583",
"0.6474594",
"0.6359285",
"0.6332589",
"0.6303224",
"0.6289221",
"0.6289221",
"0.6263875",
"0.61154294",
"0.61154294",
"0.6102482",
"0.6032026",
"0.6025294",
"0.60174143",
"0.6008131",
"0.599329",
"0.59881353",
"0.59809375... | 0.0 | -1 |
disable links feature, as we do not use it at all | def relationship_links(source)
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_link\n @disable_link = true\n end",
"def ignore_links\n @link_rules.reject\n end",
"def check_only_links\n end",
"def skip_link!\n raise(SkipLink)\n end",
"def pretend_links_do_not_exist\n test_mode && remove_old_links\n end",
"def disallowNavigation\n self... | [
"0.86765105",
"0.76224715",
"0.75121313",
"0.7006984",
"0.6743204",
"0.66342205",
"0.66342205",
"0.6578404",
"0.6578404",
"0.6538638",
"0.6538638",
"0.6538638",
"0.6456816",
"0.6420284",
"0.6389987",
"0.6389987",
"0.6389987",
"0.63765854",
"0.63731635",
"0.63694054",
"0.63059... | 0.0 | -1 |
TODO: Improve this method for run server using production environment. | def start_server
init "Postview starting #{@server} on #{@options[:Host]}:#{@options[:Port]}" do
ENV['RACK_ENV'] = "production"
config = @config.to_s
@postview = eval("Rack::Builder.new{(\n#{@source}\n)}.to_app", nil, config)
@application = Rack::Builder.new do |application|
use Rack::CommonLogger, STDOUT
use Rack::ShowExceptions
run application
end.to_app
end
@server.run(@postview, @options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_server\n if ENV['RACK_ENV'] == 'production'\n run APP\n else\n Rack::Server.start(\n app: APP,\n Port: $PORT\n )\n end\nend",
"def run_worker(server_name)\n if !server_name.empty?\n %x| #{app_root}/bin/goliath s -e production -s #{server_name}|\n else\n %x| #{app_root}... | [
"0.74390876",
"0.6998383",
"0.6943775",
"0.66040206",
"0.6592376",
"0.65028423",
"0.6481217",
"0.6473492",
"0.63870704",
"0.63497937",
"0.6344411",
"0.6344215",
"0.6307915",
"0.6289664",
"0.62786686",
"0.62735605",
"0.62342584",
"0.623416",
"0.6231978",
"0.6224697",
"0.617071... | 0.7181533 | 1 |
Build a recursive method | def recursive_fib(num)
return num if num == 0 || num == 1
recursive_fib(num - 1) + recursive_fib(num - 2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive => nil",
"def recursive_solution\n\n end",
"def generate_recursive(length)\n _generate(length, 0, '')\nend",
"def build_tree(arr)\n\tend",
"def recursive_factorial(number)\n\nend",
"def recursive_factorial(number)\n\nend",
"def recursive_print(array)\n\nend",
"def to_recursive\n ... | [
"0.7135299",
"0.6831211",
"0.6098236",
"0.58437026",
"0.58026224",
"0.58026224",
"0.5733719",
"0.57082236",
"0.5679891",
"0.56568277",
"0.56568277",
"0.5617052",
"0.5577701",
"0.55678827",
"0.55470407",
"0.5546826",
"0.55180573",
"0.5509645",
"0.5506345",
"0.54837686",
"0.545... | 0.0 | -1 |
Build an iterative solution | def iterative_fib(num)
return num if num < 2
fib = [0, 1]
(2..num).each do |digit|
x = fib[digit - 1] + fib[digit - 2]
fib << x
end
return fib.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_solution\n\n end",
"def build_subsolutions\n @success_probability = Array.new(@size)\n @success_probability[@size-1] = 1.0/@size\n (@size-1).downto(1).each { |k|\n @success_probability[k-1] = 1.0/@size + @success_probability[k]*(k-1)/k\n }\n end",
"def solve\n loop { bre... | [
"0.69735295",
"0.64778966",
"0.6350523",
"0.6339724",
"0.61253005",
"0.60802174",
"0.598333",
"0.596691",
"0.59276116",
"0.59253514",
"0.59253514",
"0.59096175",
"0.5869213",
"0.5865746",
"0.57955486",
"0.5789346",
"0.57881254",
"0.5783006",
"0.5763312",
"0.571655",
"0.571344... | 0.0 | -1 |
Used for setting up cantake for exercise purposes | def set_user_cantake_own
# debugger
if authenticate_user
exam_name = params[:exam_name]
thisMasterExam = MasterExam.where(name: exam_name).where(user_id: session[:user_id]).last
# debugger
if !Cantake.exists?(master_exam_id: thisMasterExam.id, user_id: session[:user_id])
cantake = Cantake.new
cantake.master_exam_id = thisMasterExam.id
cantake.user_id = session[:user_id]
cantake.save!
end
respond_to do |format|
format.json { render json: usersFromGroups.to_json }
end
else
flash[:error] = "Acceso restringido."
redirect_to(root_path)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make; end",
"def setup\n set_name(ask_name)\n set_word\n set_guess\n end",
"def task()\n world = Robota::World\n world.read_world(\"../karel/empty.map\")\n \n karel = Question3.new(1, 1, Robota::NORTH, 1)\n karel2 = Question3.new(6, 1, Robota::EAST, 0)\n karel3 = Question3.new(6, 6, Robota:... | [
"0.60249585",
"0.5754257",
"0.5746161",
"0.5737909",
"0.5711527",
"0.5480269",
"0.5409127",
"0.5390229",
"0.53748566",
"0.53748566",
"0.53748566",
"0.53748566",
"0.53748566",
"0.53748566",
"0.53748566",
"0.5374592",
"0.5374592",
"0.5374592",
"0.5374592",
"0.5374592",
"0.53745... | 0.5397612 | 7 |
Determine if an object of any kind can be placed at the given coordinates | def can_place? x, y
x >= 0 and x < @max_x and y >= 0 and y < @max_y and !object_at?(x, y)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def over?(object=nil,width=-1,height=-1)\n return false if object.nil?\n params=self.getObjectParams(object)\n x=params[0]\n y=params[1]\n width=params[2] if width < 0\n height=params[3] if height < 0\n return true if @x >= x && @x <= (x + width) and @y >= y && @y <= (y + height)\n return f... | [
"0.71957207",
"0.7001811",
"0.6991781",
"0.6972894",
"0.6972894",
"0.69160825",
"0.6835868",
"0.6811362",
"0.66489315",
"0.66447467",
"0.66425765",
"0.6598332",
"0.6592837",
"0.6585819",
"0.6580609",
"0.653138",
"0.6519859",
"0.6492711",
"0.6466947",
"0.6466158",
"0.64657116"... | 0.75778514 | 0 |
Place an object on the board at the given coordinates and remember the state | def place_object x, y
if can_place?(x, y)
@objects << [x, y]
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_object\n @board.place_object *next_position\n end",
"def place(x, y)\n self.robot_position = {\n x: x,\n y: y\n } if valid_coordinates?(x, y)\n end",
"def move_to(x, y)\n object.x = x\n object.y = y\n end",
"def place(pos)\n @board[pos.i][pos.j] = Stone.new(curren... | [
"0.77555513",
"0.7141924",
"0.6928425",
"0.6865546",
"0.6842073",
"0.68110645",
"0.67585325",
"0.67014015",
"0.6654811",
"0.663745",
"0.6620512",
"0.65604156",
"0.6555031",
"0.6434266",
"0.6391837",
"0.6363319",
"0.6359132",
"0.6335729",
"0.6332064",
"0.63306415",
"0.6319709"... | 0.6301341 | 21 |
Print an ascii map of the current board, 0 for an empty space, X for an object in that space. | def report
ret = ''
(0 .. @max_y - 1).to_a.reverse.each do |y|
(0 .. @max_x - 1).each do |x|
ret += object_at?(x, y) ? 'X' : '0'
end
ret += "\n"
end
ret.chomp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_board\n\t\tcell_index=1\n\t\tputs \"\\n\\n\\t[A]\\t[B]\\t[C]\"\n\t\t@cell_status.each_key do |cell|\n\t\t\tcase cell\n\t\t\twhen \"A1\" \n\t\t\t\tprint \" [1]\\t #{marker_on_cell(cell)}\"\n\t\t\twhen \"B1\" \n\t\t\t\tprint \" | #{marker_on_cell(cell)}\"\n\t\t\twhen \"C1\" \n\t\t\t\tprint \" |\\... | [
"0.7452464",
"0.7436059",
"0.7387389",
"0.73349744",
"0.73151165",
"0.7266774",
"0.72461563",
"0.71802497",
"0.7174761",
"0.7160042",
"0.7157551",
"0.71012306",
"0.7087374",
"0.7050172",
"0.7041221",
"0.69990206",
"0.6992614",
"0.69833046",
"0.69687814",
"0.6954239",
"0.69459... | 0.0 | -1 |
Paint the common attributes of containers (e.g. border and background color). Any class that inherits from this one should call `super` at the start of its paint method, before painting its children. | def paint(canvas, left, top, &block)
return unless canvas.writable?
return unless needs_printing?
canvas_coords = coords(left, top)
# Paint the border, background color, and scrollbar starting from the top left
# border position, moving down row by row until we reach the bottom border
# position
stroke_left = canvas_coords.border_left
stroke_top = canvas_coords.border_top
# All strokes will have the same formatting options
formatting = [*settings.border.color, *settings.bg_color]
# Paint the top border if the settings call for it
if settings.border.top?
canvas.stroke(stroke_left, stroke_top, top_border_stroke, formatting, &block)
stroke_top += 1
end
# Precalculate the middle border container grids with more than 1 row
middle_border = dimensions.num_rows > 1 ? middle_border_stroke : ''
vert_scrollbar = settings.scrollbar.vert? ? ScrollbarHelper.vert(
dimensions.children_height + dimensions.padding_height,
dimensions.inner_grid_height,
canvas_coords.content_top - canvas_coords.offset_content_top,
) : []
# Paint each grid row by row
dimensions.num_rows.times do |row_num|
# In a grid with N rows, we will need to paint N - 1 inner horizontal borders.
# This code treats the inner horizontal border as the top of each row except for
# the first one.
if row_num > 0 && settings.border.inner_horiz?
canvas.stroke(stroke_left, stroke_top, middle_border, formatting, &block)
stroke_top += 1
end
# Paint the interior of each row (horizontal borders, veritical scroll bar and
# background color for the padding and content area)
dimensions.inner_grid_height.times do |row_within_cell|
content_line = content_line_stroke(row_within_cell, vert_scrollbar)
canvas.stroke(stroke_left, stroke_top, content_line, formatting, &block)
stroke_top += 1
end
# Paint the horizontal scroll bar is the settings call for it
if settings.scrollbar.horiz?
canvas.stroke(stroke_left, stroke_top, bottom_scroll_stroke(canvas_coords), formatting, &block)
stroke_top += 1
end
end
# Paint the bottom border if the settings call for it
if settings.border.bottom?
canvas.stroke(stroke_left, stroke_top, bottom_border_stroke, formatting, &block)
stroke_top += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setbordercolorind(*)\n super\n end",
"def draw_attributes\n draw_header\n \n change_color(system_color)\n #draw_text(5, 32, self.width, 24, \"Categoria:\")\n draw_text(5, 32, self.width, 24, \"Atributos:\")\n change_color(normal_color)\n \n 8.times do |i|\n draw_text(5,... | [
"0.5149103",
"0.50738525",
"0.50126237",
"0.4909244",
"0.48083276",
"0.47970742",
"0.47796682",
"0.4777424",
"0.47741362",
"0.47597548",
"0.47540233",
"0.4750689",
"0.47482672",
"0.47277513",
"0.47206995",
"0.47057095",
"0.4700633",
"0.46799657",
"0.4655521",
"0.46477312",
"0... | 0.411338 | 95 |
Tightly manage access to the children (rather than simply exposing the underlying array). This allows subclasses to easily modify behavior based on that element's specific settings. | def add_child(child)
children << child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n raise NotImplementedError\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
... | [
"0.752648",
"0.7520424",
"0.75146425",
"0.74765176",
"0.74765176",
"0.74765176",
"0.74765176",
"0.7396497",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7389546",
"0.7370382",... | 0.0 | -1 |
Determine if there is anything to print for the container (this does not accont for children, just the border, scrollbar, and background color) | def needs_printing?
return true if settings.bg_color
return true if settings.border.outer?
return true if dimensions.num_cols > 1 && settings.border.inner_vert?
return true if dimensions.num_rows > 1 && settings.border.inner_horiz?
settings.scrollbar.horiz? || settings.scrollbar.vert?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_print?\n !@suppress_output\n end",
"def can_print?\n ret = false\n if content_type == 'text/x-clinical'\n clinical_objects(true).each do |obj|\n ret = true if obj.can_print?\n ''\n end\n end\n return ret\n end",
"def is_reprinted?\n return false\n end",
... | [
"0.61242926",
"0.5739737",
"0.5604564",
"0.55875456",
"0.55610657",
"0.53898317",
"0.53547597",
"0.53331494",
"0.5329476",
"0.5306348",
"0.52585196",
"0.52491415",
"0.5243871",
"0.52407354",
"0.52407354",
"0.52225494",
"0.5217684",
"0.521082",
"0.52106833",
"0.51985383",
"0.5... | 0.7504051 | 0 |
Return an object that allows easy access to important coordinates within the container, e.g. the left position where the left border is printed | def coords(left, top)
ContainerCoords.new(dimensions, settings, left, top)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def container\n Coordinate.new(row.to_i, column.to_i, zoom)\n end",
"def topleft; return self[0,2].to_a; end",
"def left\n @widget.margins.left + @widget.borders.left\n end",
"def center; return self.centerx, self.centery; end",
"def get_pad_top_left\n p = @child.get_buffer()\n ... | [
"0.68038803",
"0.67645806",
"0.65683484",
"0.64560264",
"0.6440385",
"0.6432886",
"0.6414154",
"0.64057803",
"0.63733166",
"0.6322778",
"0.6315009",
"0.62780243",
"0.6265833",
"0.62648696",
"0.62573546",
"0.62226576",
"0.61846614",
"0.61846185",
"0.61825377",
"0.61751616",
"0... | 0.66490126 | 2 |
Return a stroke for one line of the container | def line_stroke(left_border, junc_border, right_border, &block)
stroke = ''
stroke += left_border if settings.border.left?
dimensions.num_cols.times do |col_num|
stroke += junc_border if col_num > 0 && settings.border.inner_vert?
stroke += yield
end
stroke += right_border if settings.border.right?
stroke
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawDashedLine(x0,y0,x1,y1,thickness=1,color=\"grey\")\n @gc.set_foreground(getColor(color)) ;\n @gc.set_line_attributes(thickness, Gdk::LINE_ON_OFF_DASH,\n\t\t\t Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER) \n\n @buffer.draw_line(@gc,valX(x0),valY(y0),valX(x1),valY(y1)) ;\n end",
"def stroke_alpha\n ... | [
"0.6979955",
"0.67499936",
"0.6660538",
"0.6654172",
"0.66114223",
"0.65873563",
"0.6556425",
"0.65366524",
"0.64987177",
"0.6497296",
"0.6458185",
"0.64526105",
"0.64516324",
"0.6435811",
"0.6365065",
"0.6336206",
"0.6329738",
"0.63088226",
"0.62764144",
"0.62557894",
"0.621... | 0.7202061 | 0 |
Return the stroke for the top border | def top_border_stroke
line_stroke(
settings.border.style.top_left,
settings.border.style.top_junc,
settings.border.style.top_right
) do
settings.border.style.top_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def border_top()\n return get_border(:top)\n end",
"def bottom_border_stroke\n line_stroke(\n settings.border.style.bottom_left,\n settings.border.style.bottom_junc,\n settings.border.style.bottom_right\n ) do\n settings.border.style.bottom_horiz * (dimen... | [
"0.7740852",
"0.71515524",
"0.70134985",
"0.6799214",
"0.6787378",
"0.64831746",
"0.6096827",
"0.60792834",
"0.60528845",
"0.59960073",
"0.5991102",
"0.5964469",
"0.5958728",
"0.59125173",
"0.590965",
"0.5905231",
"0.5869558",
"0.5854105",
"0.5835965",
"0.58254933",
"0.580571... | 0.8627915 | 0 |
Return the stroke for an inner horizontal border | def middle_border_stroke
line_stroke(
settings.border.style.left_junc,
settings.border.style.cross_junc,
settings.border.style.right_junc
) do
settings.border.style.middle_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_border_stroke\n line_stroke(\n settings.border.style.top_left,\n settings.border.style.top_junc,\n settings.border.style.top_right\n ) do\n settings.border.style.top_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))\n end\n ... | [
"0.7689102",
"0.75485665",
"0.68524694",
"0.6668248",
"0.64503616",
"0.63637877",
"0.6309175",
"0.6262423",
"0.6162286",
"0.6135493",
"0.6104968",
"0.6041272",
"0.6024591",
"0.60000294",
"0.5979723",
"0.594717",
"0.59452844",
"0.59426314",
"0.5915777",
"0.5848136",
"0.5838583... | 0.7620133 | 1 |
Return the stroke for the bottom border | def bottom_border_stroke
line_stroke(
settings.border.style.bottom_left,
settings.border.style.bottom_junc,
settings.border.style.bottom_right
) do
settings.border.style.bottom_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def border_bottom()\n return get_border(:bottom)\n end",
"def stroke_bottom(stroke_width = 0.5)\n stored_line_width = line_width\n self.line_width = stroke_width\n horizontal_line 0, bounds.width, at: 0\n self.line_width = stored_line_width\n end",
"def top_border_stroke\n line_stro... | [
"0.805308",
"0.7253892",
"0.7189078",
"0.70658267",
"0.6949482",
"0.6915735",
"0.65795994",
"0.6462396",
"0.63695824",
"0.6316476",
"0.6245049",
"0.6211284",
"0.6099328",
"0.60626346",
"0.60429555",
"0.6025295",
"0.5946929",
"0.5946603",
"0.59208494",
"0.59056693",
"0.5899573... | 0.87116045 | 0 |
Return the stroke for a grid row between any borders | def content_line_stroke(row_within_cell, vert_scrollbar)
line_stroke(
settings.border.style.left_vert,
settings.border.style.middle_vert,
settings.border.style.right_vert,
) do
if settings.scrollbar.vert?
PADDING * dimensions.inner_grid_width + vert_scrollbar[row_within_cell]
else
PADDING * dimensions.inner_grid_width
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_stroke(left_border, junc_border, right_border, &block)\n stroke = ''\n stroke += left_border if settings.border.left?\n dimensions.num_cols.times do |col_num|\n stroke += junc_border if col_num > 0 && settings.border.inner_vert?\n stroke += yield\n end\n ... | [
"0.70963",
"0.7090006",
"0.69800174",
"0.68480045",
"0.64764786",
"0.62640226",
"0.6213493",
"0.6079955",
"0.59603155",
"0.5894195",
"0.58903044",
"0.587081",
"0.5853909",
"0.58346546",
"0.5824349",
"0.5792687",
"0.5789524",
"0.5778426",
"0.5740961",
"0.57255095",
"0.57213205... | 0.7346218 | 0 |
Return the stroke for the horizontal scroll bar | def bottom_scroll_stroke(canvas_coords)
line_stroke(
settings.border.style.left_vert,
settings.border.style.middle_vert,
settings.border.style.right_vert,
) do
ScrollbarHelper.horiz(
dimensions.children_width + dimensions.padding_width,
dimensions.inner_grid_width,
canvas_coords.content_left - canvas_coords.offset_content_left
).join
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_line_stroke(row_within_cell, vert_scrollbar)\n line_stroke(\n settings.border.style.left_vert,\n settings.border.style.middle_vert,\n settings.border.style.right_vert,\n ) do\n if settings.scrollbar.vert?\n PADDING * dimensions.inner_grid_wid... | [
"0.6407238",
"0.6365955",
"0.62695724",
"0.6113696",
"0.6014218",
"0.5835918",
"0.58343804",
"0.5776868",
"0.5766785",
"0.5728691",
"0.5555855",
"0.5506988",
"0.54964894",
"0.5449431",
"0.54365766",
"0.54365766",
"0.54364574",
"0.5435693",
"0.5435693",
"0.5358668",
"0.5346556... | 0.6648583 | 0 |
GET /replies GET /replies.json | def index
@replies = @comment.replies
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @replies }\n end\n en... | [
"0.78151596",
"0.78151596",
"0.77165926",
"0.756835",
"0.75087506",
"0.75087506",
"0.75087506",
"0.75087506",
"0.7389619",
"0.72560644",
"0.7188502",
"0.7156356",
"0.71322286",
"0.7050642",
"0.70492387",
"0.70449436",
"0.70359355",
"0.70244557",
"0.7015605",
"0.6983682",
"0.6... | 0.73520356 | 9 |
GET /replies/1 GET /replies/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @replies }\n end\n en... | [
"0.75498235",
"0.75498235",
"0.7533953",
"0.73627836",
"0.73627836",
"0.73627836",
"0.73627836",
"0.73464525",
"0.7328741",
"0.72572494",
"0.7211976",
"0.7163027",
"0.7064274",
"0.7034106",
"0.7034106",
"0.70314205",
"0.7024869",
"0.6936885",
"0.6910477",
"0.68988687",
"0.687... | 0.0 | -1 |
POST /replies POST /replies.json | def create
@reply = @comment.replies.new(reply_params)
@reply.user_id = session[:user_id]
respond_to do |format|
if @reply.save
format.html { redirect_to @post, notice: 'Reply was successfully created.' }
format.json { render @post, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @reply.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @reply = @place.replies.new(reply_params)\n @reply.user = current_user\n if @reply.save\n render :show, status: :created, location: @reply\n else\n render json: @reply.errors, status: :unprocessable_entity\n end\n end",
"def reply_to_post\n puts params[:r... | [
"0.73018897",
"0.7238259",
"0.7096654",
"0.7074214",
"0.70589364",
"0.7057672",
"0.7027279",
"0.7009131",
"0.6924008",
"0.6904648",
"0.6904648",
"0.68951243",
"0.6858559",
"0.6858559",
"0.6847542",
"0.6833775",
"0.67760825",
"0.6737637",
"0.6731515",
"0.6731515",
"0.6731515",... | 0.7232087 | 2 |
PATCH/PUT /replies/1 PATCH/PUT /replies/1.json | def update
respond_to do |format|
if @reply.update(reply_params)
format.html { redirect_to @reply, notice: 'Reply was successfully updated.' }
format.json { render @post, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @reply.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @replies = args[:replies] if args.key?(:replies)\n @root_comment = args[:root_comment] if args.key?(:root_comment)\n end",
"def update\n @reply = Reply.find(params[:id])\n\n if @reply.update(params[:reply])\n head :no_content\n else\n render json:... | [
"0.7313958",
"0.7096402",
"0.7073606",
"0.7073572",
"0.70291245",
"0.7021751",
"0.7003677",
"0.6975324",
"0.6964031",
"0.6964031",
"0.6964031",
"0.6964031",
"0.6964031",
"0.69518054",
"0.6945372",
"0.69385153",
"0.69377965",
"0.67421716",
"0.67368317",
"0.6628114",
"0.660129"... | 0.69315666 | 17 |
DELETE /replies/1 DELETE /replies/1.json | def destroy
@reply.destroy
respond_to do |format|
format.html { redirect_to @post, notice: 'Reply was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @reply = @message.replies.find(params[:id])\n @reply.destroy\n\n respond_to do |format|\n format.html { redirect_to([@user,@message]) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reply.destroy\n respond_to do |format|\n format.html { redirect_to repli... | [
"0.7838313",
"0.7726106",
"0.7712503",
"0.7712503",
"0.7707096",
"0.76889896",
"0.7657401",
"0.76191044",
"0.76191044",
"0.76191044",
"0.76191044",
"0.76191044",
"0.76108134",
"0.7599225",
"0.747736",
"0.7470901",
"0.74302506",
"0.73537296",
"0.7284724",
"0.71945995",
"0.7190... | 0.7463574 | 16 |
Use callbacks to share common setup or constraints between actions. | def set_reply
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:comment_id])
@reply = @comment.replies.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 reply_params
params.require(:reply).permit(:content)
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.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
def target object.traget end | def actual
object.actual
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target; end",
"def target; end",
"def target\n __getobj__\n end",
"def target\n @target\n end",
"def target\n self['target']\n end",
"def target\n @target\n end",
"def get_target\n @target\n end",
"def target!\n @target\n end",
"def target\n self\n ... | [
"0.7789401",
"0.7789401",
"0.73160374",
"0.723947",
"0.705636",
"0.69100964",
"0.6889898",
"0.6885579",
"0.68731177",
"0.68731177",
"0.6820177",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
"0.6758474",
... | 0.0 | -1 |
Get default RightLink metadata dir location | def rightlink_metadata_dir
var_dir = File.join( RUBY_PLATFORM =~ /mswin|mingw|windows/ ? [ENV['ProgramData'],'RightScale'] : ['/', 'var'] )
metadata_dir = File.join(var_dir, 'spool','cloud','meta-data')
metadata_dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata_full_path\n @metadata_full_path ||= \"#{File.dirname(@full_path)}/#{name}\"\n end",
"def metadata_full_path\n @metadata_full_path ||= File.join(File.dirname(@full_path), name)\n end",
"def directory\n return _meta_data['directory'] if _meta_data.has_key? 'directory'\n dir\n end",
... | [
"0.7100068",
"0.69788706",
"0.67055947",
"0.6644141",
"0.6533629",
"0.653067",
"0.6443827",
"0.6436529",
"0.6339871",
"0.6308066",
"0.6274697",
"0.6274697",
"0.6228388",
"0.6181814",
"0.6142968",
"0.6142362",
"0.6142362",
"0.6142362",
"0.6142362",
"0.6142362",
"0.6142362",
... | 0.7695491 | 0 |
Searches for a file containing dhcp lease information. | def dhcp_lease_provider
logger = ::Ohai::Log
if RUBY_PLATFORM =~ /mswin|mingw|windows/
timeout = Time.now + 20 * 60 # 20 minutes
while Time.now < timeout
ipconfig_data = `ipconfig /all`
match_result = ipconfig_data.match(/DHCP Server.*\: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
unless match_result.nil? || match_result[1].nil?
return match_result[1]
end
# it may take time to resolve the DHCP Server for this instance, so sleepy wait.
logger.info("ipconfig /all did not contain any DHCP Servers. Retrying in 10 seconds...")
sleep 10
end
else
leases_file = %w{/var/lib/dhcp/dhclient.eth0.leases /var/lib/dhcp3/dhclient.eth0.leases /var/lib/dhclient/dhclient-eth0.leases /var/lib/dhclient-eth0.leases /var/lib/dhcpcd/dhcpcd-eth0.info}.find{|dhcpconfig| File.exist?(dhcpconfig)}
unless leases_file.nil?
lease_file_content = File.read(leases_file)
dhcp_lease_provider_ip = lease_file_content[/DHCPSID='(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'/, 1]
return dhcp_lease_provider_ip unless dhcp_lease_provider_ip.nil?
# leases are appended to the lease file, so to get the appropriate dhcp lease provider, we must grab
# the info from the last lease entry.
#
# reverse the content and reverse the regex to find the dhcp lease provider from the last lease entry
lease_file_content.reverse!
dhcp_lease_provider_ip = lease_file_content[/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) reifitnedi-revres-pchd/, 1]
return dhcp_lease_provider_ip.reverse unless dhcp_lease_provider_ip.nil?
end
end
# no known defaults so we must fail at this point.
raise "Cannot determine dhcp lease provider for cloudstack instance"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_guest_ip_dhcp\n mac_addr = read_mac_address.downcase\n leases_file = '/Library/Preferences/Parallels/parallels_dhcp_leases'\n leases = {}\n begin\n File.open(leases_file).grep(/#{mac_addr}/) do |line|\n _, ip, exp, dur, = line.split /([\\d.]*)=\"... | [
"0.62841165",
"0.600425",
"0.5507177",
"0.5401992",
"0.53956014",
"0.50320876",
"0.4911759",
"0.48861873",
"0.48606068",
"0.48466685",
"0.48417076",
"0.47997084",
"0.47876585",
"0.4769595",
"0.47513643",
"0.4740637",
"0.47275567",
"0.4715081",
"0.47117174",
"0.47103563",
"0.4... | 0.70743036 | 0 |
return all questions within a given dimension | def questions_4_dimension(dimension) questions.select { |question| question.dimension == dimension } end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dimensions()\r\n @dimensions ||= questions.inject([]) do |l, question|\r\n question_dimension = question.dimension\r\n l << question_dimension unless l.include?(question_dimension) or question_dimension == \"unknown\"\r\n l\r\n end\r\n end",
"def questions\n result = []\n 1.upto(@... | [
"0.6888125",
"0.6652954",
"0.6480301",
"0.6201011",
"0.60573494",
"0.6052339",
"0.602421",
"0.60171896",
"0.60077715",
"0.5979008",
"0.59432536",
"0.5932488",
"0.5910549",
"0.5887502",
"0.5878566",
"0.5878566",
"0.58726066",
"0.58535224",
"0.58484674",
"0.5838237",
"0.5823858... | 0.7982945 | 0 |
returns all dimensions of this quizze | def dimensions()
@dimensions ||= questions.inject([]) do |l, question|
question_dimension = question.dimension
l << question_dimension unless l.include?(question_dimension) or question_dimension == "unknown"
l
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dimensions\n @dimensions ||= extract_dimensions\n end",
"def dimensions\n\t\t[@n,@m]\n\tend",
"def get_dimensions\n check_attached\n\n @logger.info \"Retrieving list of dimensions\"\n @req.EnumDims do |xml|\n xml.sID @session_id\n xml.alsTbl @preferenc... | [
"0.7442119",
"0.71496516",
"0.7027107",
"0.6982708",
"0.69457555",
"0.6923088",
"0.68885076",
"0.6760185",
"0.6733663",
"0.6710231",
"0.67098784",
"0.67059976",
"0.66614",
"0.6641144",
"0.66184294",
"0.6594489",
"0.6546009",
"0.6496077",
"0.6494584",
"0.63867414",
"0.63764924... | 0.80872947 | 0 |
Helper method for file references. | def root_path(*args)
File.join(ROOT_DIR, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_reference(path); end",
"def file_references\n return unless @command == :download_file_list\n\n @file_references ||= begin\n xml = xml_doc content\n descriptors = xml.css('FileDescriptor')\n descriptors.map { |descriptor| descriptor.at('FileReference').content }\n ... | [
"0.6970369",
"0.66221905",
"0.64734167",
"0.64734167",
"0.646426",
"0.64048386",
"0.64042544",
"0.6389405",
"0.63615096",
"0.63584536",
"0.6342871",
"0.63116425",
"0.6309374",
"0.62897456",
"0.62436205",
"0.622693",
"0.622693",
"0.62163484",
"0.62081444",
"0.61555254",
"0.615... | 0.0 | -1 |
Part 1 Define a method sum(arr) that sums up the integer elements of the array. | def sum arr
arr.inject(0,:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(array_of_integers)\n # TODO\nend",
"def sum arr\n #this is slightly too easy...\n arr.sum\nend",
"def sum_array(int_array)\n int_array.reduce(:+)\nend",
"def sum (arr)\n\treturn arr.inject(0, :+)\nend",
"def sum(array)\n array.sum\nend",
"def sum arr\n sum = arr.sum\n return sum\nend... | [
"0.83480084",
"0.8194564",
"0.8091774",
"0.80501175",
"0.8032043",
"0.8012589",
"0.79682",
"0.7947857",
"0.7931114",
"0.79236037",
"0.7919648",
"0.79175955",
"0.79175955",
"0.79175955",
"0.7909171",
"0.78952026",
"0.78819567",
"0.7873365",
"0.7873365",
"0.78541696",
"0.785412... | 0.767796 | 55 |
Define a method max_2_sum(arr) that returns the sum of the largest elements in the arry. Returns zero if the arry is zero. Returns value of the element if just one element | def max_2_sum arr
if arr.empty?
0
else
arr.max(2).reduce(:+)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_2_sum arr\n if arr.empty?\n 0\n else\n arr.max(2).reduce(:+)\n end\nend",
"def max_2_sum arr\n #If the array is empty return 0\n if arr.length == 0 then\n\treturn 0\n end\n #If the array has only one element return that element\n if arr.length == 1 then \n return arr[0]\n end\n #So... | [
"0.8963982",
"0.8923322",
"0.8883403",
"0.88415873",
"0.88059795",
"0.8795317",
"0.8795317",
"0.8791468",
"0.87784165",
"0.8761157",
"0.8756363",
"0.8754423",
"0.87518764",
"0.87404907",
"0.8735426",
"0.87201613",
"0.86674595",
"0.86662966",
"0.8652348",
"0.865226",
"0.864513... | 0.8937493 | 1 |
Define a method sum_to_n?(arr, n) that takes the array of integer and n as argument and returns true when any two elements sum to the second argument. | def sum_to_n? arr, n
if arr.size>=2
for x in arr
if arr.include?(n-x) and x != n-x or arr.count(x) > 1
return true
end
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to_n?(array, n)\n return false if array.empty? || array.length == 1\n\n array.combination(2).any? { |x, y| x + y == n }\nend",
"def sum_to_n?( arr, n )\n return false if arr.nil? or arr.empty? or arr.length == 1\n arr.each do |first|\n arr.each do |second|\n return true if (first + second == ... | [
"0.86175776",
"0.8541512",
"0.85348564",
"0.8525238",
"0.8500054",
"0.84810233",
"0.84693176",
"0.8466944",
"0.8443311",
"0.8436566",
"0.83674073",
"0.8316737",
"0.8307112",
"0.8291904",
"0.8243488",
"0.82361007",
"0.8227838",
"0.82140154",
"0.8208474",
"0.8197508",
"0.819465... | 0.82128364 | 18 |
Part 2 Define the method hello(name) that returns the string with the name concatenated after hello. | def hello(name)
"Hello, #{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hello(name)\n\ts = \"Hello, \" + name\n\treturn s\nend",
"def hello(name)\n \"Hello, \".concat(name)\nend",
"def hello(name)\n\t\"Hello, \" + name\nend",
"def hello(name)\n return 'Hello, ' + name\nend",
"def hello(name) \n\t\"hello #{name}\"\nend",
"def hello (name)\n return \"Hello, \" + nam... | [
"0.8772369",
"0.866995",
"0.8650065",
"0.85860777",
"0.85604787",
"0.8549061",
"0.84995514",
"0.8479428",
"0.84456164",
"0.84456164",
"0.84456164",
"0.84456164",
"0.84155035",
"0.84056103",
"0.83951396",
"0.83877015",
"0.83877015",
"0.83813715",
"0.83813715",
"0.83589727",
"0... | 0.8138487 | 56 |
Define the method starts_with_consonant?(s) that returns true if the string starts with a consonant,otherwises returns false. It should works on empty strings and noletters. | def starts_with_consonant? s
return false if s.empty?
consonant = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
consonant.each_char{|c|
return true if s.start_with?(c)
}
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def starts_with_consonant?(s)\n return false if s.empty?\n %Q{b c d f g h j k l m q r s t v w x y z}.include? s[0].downcase\nend",
"def starts_with_consonant? s\n return false if s.empty?\n return true if s[0] =~ /[^\\Waeiou]/i\n return false\nend",
"def starts_with_consonant? s\n cond1 = /[[:alpha:]]/ ... | [
"0.86285394",
"0.84872866",
"0.8484169",
"0.8457619",
"0.84493375",
"0.8439466",
"0.84303033",
"0.842453",
"0.8412268",
"0.839653",
"0.83798623",
"0.83704937",
"0.8321774",
"0.831829",
"0.8300462",
"0.8300462",
"0.82989544",
"0.8288791",
"0.82762754",
"0.82594025",
"0.8233308... | 0.8584188 | 2 |
Define a method binary_multiple_of_4?(s) that returns true if the string represents a binary that is multiple of 4. It should return false if the string cannot represent a binary number. | def binary_multiple_of_4? s
if not s.empty? and (s.end_with?('00') or s=='0') and s.count('0-9')==(s.size)
return true
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_multiple_of_4? str\n\treturn (str =~ /\\b[01]+\\b/) != 0 ? false : str.to_i(2) % 4 == 0 ? true : false\nend",
"def binary_multiple_of_4?(s)\n\n return false if s == \"\"\n for i in 0..s.size-1\n return false unless s[i] == \"0\" || s[i] == \"1\"\n end\n s.to_i(2) % 4 == 0\nend",
"... | [
"0.8975959",
"0.89569473",
"0.893098",
"0.89028734",
"0.8889286",
"0.88761693",
"0.8805252",
"0.8801364",
"0.87981087",
"0.87867606",
"0.8767471",
"0.87405056",
"0.8720163",
"0.8696661",
"0.8694345",
"0.86919975",
"0.86851907",
"0.8676265",
"0.8632805",
"0.85884255",
"0.85720... | 0.8511247 | 26 |
^ too complex... make use of the `item_at` method... plus you can use delete because it's removing all occurrences of that OBJECT not simply objects with that title!!!!!!!!! | def remove_at(idx)
@todos.delete(item_at(idx))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(title)\n \t\tfounds = []\n\t\t(@titles.length-1).downto(0).each { |i|\n \t\t\tif @titles[i] == title\n \t\t\t\tfounds.push(i)\n\t\t\tend\n\t\t}\n\n\t\tif founds.length > 0\n\t\t\tfor i in founds\n \t\t\t\t@titleCount -= 1\n\t\t\t\t@titles.delete_at(i)\n\t\t\tend\n\t\tend\n\tend",
"def remove_item(olis... | [
"0.66131365",
"0.6198035",
"0.6180691",
"0.593711",
"0.5930216",
"0.59234893",
"0.5922097",
"0.5901169",
"0.5895947",
"0.5893112",
"0.5874745",
"0.58733",
"0.58470184",
"0.5840394",
"0.58320504",
"0.58288485",
"0.5808776",
"0.5799537",
"0.57731223",
"0.57720536",
"0.57713383"... | 0.0 | -1 |
sine, cosine, tangent, and inverses using same angle in radians and degrees | def sine(float)
Math.sin(float)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ease_in_sine(t, b, c, d)\n t = t.to_f\n b = b.to_f\n c = c.to_f\n d = d.to_f\n -c * Math.cos(t / d * (Math.PI / 2)) + c + b\n end",
"def ease_in_out_sine(t, b, c, d)\n t = t.to_f\n b = b.to_f\n c = c.to_f\n d = d.to_f\n -c / 2 * (Math.cos(Math.PI * t / d) ... | [
"0.6501843",
"0.6472968",
"0.6433016",
"0.63924944",
"0.63213795",
"0.6295614",
"0.627179",
"0.6171432",
"0.6165737",
"0.61314595",
"0.6078663",
"0.6072065",
"0.6060397",
"0.6034504",
"0.6025571",
"0.5995151",
"0.5989445",
"0.59889776",
"0.5977659",
"0.596269",
"0.5903031",
... | 0.59294724 | 20 |
calculates the dimensions of the pad which will be used when the pad refreshes, taking into account whether borders are printed or not. This must be called whenever there is a change in height or width | def __calc_dimensions
## NOTE
# ---------------------------------------------------
# Since we are using pads, you need to get your height, width and rows correct
# Make sure the height factors in the row, else nothing may show
# ---------------------------------------------------
raise " CALC inside #{@name} h or w is nil #{@height} , #{@width} " if @height.nil? or @width.nil?
@rows = @height
@cols = @width
# NOTE XXX if cols is > COLS then padrefresh can fail
@startrow = @row
@startcol = @col
unless @suppress_borders
@row_offset = @col_offset = 1
@startrow += 1
@startcol += 1
@rows -=3 # 3 is since print_border_only reduces one from width, to check whether this is correct
@cols -=3
@scrollatrows = @height - 3
else
# no borders printed
@rows -= 1 # 3 is since print_border_only reduces one from width, to check whether this is correct
## if next is 0 then padrefresh doesn't print, gives -1 sometimes.
## otoh, if we reduce 1, then there is a blank or white left at 128 since clear_pad clears 128
# but this only writes 127 2014-05-01 - 12:31 CLEAR_PAD
#@cols -=0
@cols -=1
@scrollatrows = @height - 1 # check this out 0 or 1
@row_offset = @col_offset = 0
end
@top = @row
@left = @col
@lastrow = @row + @row_offset
@lastcol = @col + @col_offset
$log.debug " CALC_DIMENSION r:#{@rows} , c:#{@cols}, h:#{@height} , w:#{@width} , top:#{@top} , left:#{@left} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pad_dimensions(t, l, h, w )\n @pad_h = h\n @pad_w = w\n @top = @orig_top = t\n @left = @orig_left = l\n create_pad\n end",
"def calculate_plot_width(num_snps, right_padding)\n return num_snps * @box_size.to_f/97 + right_padding\n end",
"def calc_height; padding * 2 + bas... | [
"0.65224814",
"0.6488085",
"0.6485795",
"0.6485795",
"0.6478294",
"0.6421347",
"0.64183134",
"0.63714707",
"0.63707477",
"0.63707477",
"0.63615423",
"0.6339148",
"0.6295237",
"0.6135166",
"0.60288596",
"0.5991779",
"0.59314144",
"0.5924989",
"0.5924989",
"0.5906096",
"0.58988... | 0.7779117 | 0 |
returns the row and col where the cursor is initially placed, and where printing starts from. | def rowcol #:nodoc:
return @row+@row_offset, @col+@col_offset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def c_topleft\n print cursor.column(0)\n print cursor.row(0)\n end",
"def c_bottomleft\n print cursor.column(0)\n print cursor.row(height)\n end",
"def cur_pos\n @cursor.pos\n end",
"def position\n [ @row_offset, @col_offset ]\n end",
"def location\n\t\... | [
"0.77327883",
"0.7579224",
"0.72315854",
"0.7189706",
"0.7064824",
"0.69827354",
"0.68776655",
"0.6852248",
"0.68503547",
"0.68503547",
"0.68111634",
"0.6786992",
"0.67103696",
"0.66389364",
"0.66347086",
"0.65288997",
"0.648845",
"0.6487291",
"0.6487291",
"0.6453981",
"0.644... | 0.620517 | 33 |
update the height This also calls fire_dimension_changed so that the dimensions can be recalculated | def height=(val)
super
fire_dimension_changed :height
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_size(width, height) \n if @vertical\n @height += height\n @width = width if width > @width\n else\n @width += width\n @height = height if height > @height\n end\n end",
"def update_heights\n\t\t@height = @tile.attributes[\"height\"]\n\t\t@waterlevel =... | [
"0.6930342",
"0.68851936",
"0.6780788",
"0.6777451",
"0.6746606",
"0.6707348",
"0.66426927",
"0.6640861",
"0.6560593",
"0.6560593",
"0.65385914",
"0.65336686",
"0.6525355",
"0.64724195",
"0.6451963",
"0.64417726",
"0.6406311",
"0.63982385",
"0.6361298",
"0.62797004",
"0.62701... | 0.7956176 | 0 |
set the width This also calls fire_dimension_changed so that the dimensions can be recalculated | def width=(val)
super
fire_dimension_changed :width
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def width(val); @width = val; self; end",
"def width=(value)\n @width = value\n end",
"def width=(value)\n\t\t\t@width = value\n\t\tend",
"def width=(value)\n\t\t\t@width = value\n\t\tend",
"def setwidth(width)\n @width = width\n end",
"def width=(new_width)\n resiz... | [
"0.74675065",
"0.7459297",
"0.7422221",
"0.7422221",
"0.7379394",
"0.7365938",
"0.7105334",
"0.6992306",
"0.6968961",
"0.6956129",
"0.68829036",
"0.6832985",
"0.6832985",
"0.68324083",
"0.6786616",
"0.6786616",
"0.6757446",
"0.6748509",
"0.6739935",
"0.66784424",
"0.66542304"... | 0.86886865 | 0 |
creates pad and sets repaint_all so populate happens FIXME earlier used to create and populate, but now i have decoupled populate since that was forcing create to happen. | def populate_pad
@_populate_needed = false
create_pad
# clearstring is the string required to clear the pad to background color
@clearstring = nil
$log.debug " populate pad color = #{@color} , bg = #{@bgcolor} "
#cp = get_color($datacolor, color(), bgcolor())
# commenting off next line meant that textdialog had a black background 2014-05-01 - 23:37
#@cp = FFI::NCurses.COLOR_PAIR(cp)
# we seem to be clearing always since a pad is often reused. so making the variable whenever pad created.
@repaint_all = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_pad\n @_populate_needed = false\n # how can we make this more sensible ? FIXME\n @renderer ||= DefaultRubyRenderer.new if \".rb\" == @filetype\n @content_rows = @content.count\n @content_cols = content_cols()\n @content_rows = @rows if @content_rows < @rows\n @conten... | [
"0.67523223",
"0.6039406",
"0.5964613",
"0.59632385",
"0.5822098",
"0.56633395",
"0.558052",
"0.5530188",
"0.5528017",
"0.5468594",
"0.5407994",
"0.5332552",
"0.533224",
"0.5290425",
"0.5275175",
"0.52727854",
"0.5270497",
"0.5269316",
"0.5234076",
"0.5211856",
"0.52107394",
... | 0.74653804 | 0 |
destroy the pad, this needs to be called from somewhere, like when the app closes or the current window closes , or else we could have a seg fault or some ugliness on the screen below this one (if nested). Now since we use get_pad from window, upon the window being destroyed, it will call this. Else it will destroy pad | def destroy
FFI::NCurses.delwin(@pad) if @pad # when do i do this ? FIXME
@pad = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n FFI::NCurses.del_panel(@panel) if @panel\n FFI::NCurses.delwin(@pointer) if @pointer\n @panel = @pointer = nil # prevent call twice\n end",
"def destroy\n # typically the ensure block should have this\n\n #$log.debug \"win destroy start\"\n\n $global_windows.delet... | [
"0.7244429",
"0.71523273",
"0.6777001",
"0.66618747",
"0.66536283",
"0.652195",
"0.64057946",
"0.6395312",
"0.6314909",
"0.61960286",
"0.60952175",
"0.60758424",
"0.60758424",
"0.5996854",
"0.59524506",
"0.59220994",
"0.58496934",
"0.5816828",
"0.58069086",
"0.5795153",
"0.57... | 0.8142336 | 1 |
length of longest string in array This will give a 'wrong' max length if the array has ansi color escape sequences in it which inc the length but won't be printed. Such lines actually have less length when printed So in such cases, give more space to the pad. | def content_cols
longest = @list.max_by(&:length)
## 2013-03-06 - 20:41 crashes here for some reason when man gives error message no man entry
return 0 unless longest
longest.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_string array\n\tarray.max_by(&:length)\nend",
"def length\n (lines.map do |line|\n Strings::Align.display_width(line)\n end << 0).max\n end",
"def longest_string(array)\n\tarray.max_by(&:length)\nend",
"def longest_string_length\n longest_string.size\n end",
... | [
"0.7242365",
"0.72412413",
"0.7204127",
"0.70563924",
"0.70004255",
"0.6954804",
"0.6925227",
"0.69201505",
"0.6840018",
"0.68315446",
"0.68233025",
"0.6782789",
"0.67374736",
"0.66715026",
"0.6663603",
"0.66598165",
"0.66591096",
"0.6651377",
"0.66338444",
"0.6625965",
"0.65... | 0.0 | -1 |
to be called with program / user has added a row or changed column widths so that the pad needs to be recreated. However, cursor positioning is maintained since this is considered to be a minor change. We do not call `init_vars` since user is continuing to do some work on a row/col. NOTE : if height and width are changed then only render_all is required not a reparse since content has not changed. | def fire_dimension_changed _method=nil
# recreate pad since width or ht has changed (row count or col width changed)
@_populate_needed = true
@repaint_required = true
@repaint_all = true
fire_handler :DIMENSION_CHANGED, _method
@__first_time = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_pad\n @_populate_needed = false\n # how can we make this more sensible ? FIXME\n @renderer ||= DefaultRubyRenderer.new if \".rb\" == @filetype\n @content_rows = @content.count\n @content_cols = content_cols()\n @content_rows = @rows if @content_rows < @rows\n @conten... | [
"0.7349195",
"0.621922",
"0.6163873",
"0.6159229",
"0.6099058",
"0.6071911",
"0.6050582",
"0.6001216",
"0.5984944",
"0.59401524",
"0.5906912",
"0.5895051",
"0.5818014",
"0.57720655",
"0.5767018",
"0.57629144",
"0.575432",
"0.57015455",
"0.56633747",
"0.5662402",
"0.56290424",... | 0.5241542 | 66 |
repaint only one row since content of that row has changed. No recreate of pad is done. | def fire_row_changed ix
return if ix >= @list.length
clear_row @pad, ix
# allow documents to reparse that line
fire_handler :ROW_CHANGED, ix
_arr = _getarray
render @pad, ix, _arr[ix]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repaint\n r,c = rowcol\n $log.debug(\"widget repaint : r:#{r} c:#{c} col:#{@color_pair}\" )\n value = getvalue_for_paint\n len = self.width || value.length\n acolor = @color_pair \n @graphic.printstring r, c, \"%-*s\" % [len, value], acolor, attr()\n end",
"def repaint\n r,c = rowco... | [
"0.6568613",
"0.64177006",
"0.6295761",
"0.61638045",
"0.6110971",
"0.609781",
"0.608366",
"0.60779506",
"0.6040805",
"0.6032259",
"0.59513044",
"0.5875968",
"0.5840153",
"0.58012146",
"0.5775229",
"0.57252675",
"0.5723791",
"0.5700972",
"0.56551045",
"0.5654499",
"0.56472075... | 0.57286775 | 15 |
supply a custom renderer that implements +render()+ | def renderer r
@renderer = r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renderer; end",
"def render opts = {}\n renderer.render opts\n end",
"def render(&block)\n self.renderer = block\n end",
"def render\n raise NotImplementedError.new \"Please override 'render' in your \"+\n \"concrete implementation\"\n end",
"def draw renderer\n ... | [
"0.8317787",
"0.8078806",
"0.8004521",
"0.77369654",
"0.77086407",
"0.77032477",
"0.76259303",
"0.76095027",
"0.7479313",
"0.7479313",
"0.7460597",
"0.7452611",
"0.74439466",
"0.74439466",
"0.7434738",
"0.74043745",
"0.73991865",
"0.7367531",
"0.7351663",
"0.7306256",
"0.7297... | 0.8193605 | 2 |
This is to render a row, for those overriding classes who have overridden render_all, but not +render+. e.g. +Table+. THis is also required for row modifications. | def render pad, lineno, text
@renderer.render pad, lineno, text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_row row\n if row == :separator\n separator\n else\n Y + row.map_with_index do |cell, i|\n render_cell(cell, row_to_index(row, i))\n end.join(Y) + Y\n end\n end",
"def rows\n render 'rows.html'\n end",
"def row\n get_row\n respond_... | [
"0.7236935",
"0.6734455",
"0.66622216",
"0.66522014",
"0.6592169",
"0.65903497",
"0.6557385",
"0.6477375",
"0.6421252",
"0.64008224",
"0.63920164",
"0.63007873",
"0.62904596",
"0.6284814",
"0.62718445",
"0.62607694",
"0.62552035",
"0.62373203",
"0.6183196",
"0.60100895",
"0.5... | 0.0 | -1 |
the next 2 methods deal with printing chunks we should put it int a common module and include it in Window and Pad stuff and perhaps include it conditionally. before updating a single row in a table we need to clear the row otherwise previous contents can show through | def clear_row pad, lineno
if @renderer and @renderer.respond_to? :clear_row
@renderer.clear_row pad, lineno
else
# need pad width not window width, the other clearstring uses width of
# widget to paint on window.
@_clearstring ||= " " * @content_cols
# what about bg color ??? XXX, left_margin and internal width
#cp = get_color($datacolor, @color, @bgcolor)
cp = @cp || FFI::NCurses.COLOR_PAIR($datacolor)
att = attr() || NORMAL
FFI::NCurses.wattron(pad,cp | att)
FFI::NCurses.mvwaddstr(pad,lineno, 0, @_clearstring)
FFI::NCurses.wattroff(pad,cp | att)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buffer_preparation(op_count,op_in_cell_lysate,op_wash_amount, op_out_protein)\r\n op_table =[[\"Falcon tube ID\",\"Purification buffer volume\",\"Imidazole volume\"]]\r\n \r\n for i in 0..(op_count-1)\r\n #if !op_wash_amount[i]\r\n #op_wash_amount[i] = 5\r\n #end\r\n ro... | [
"0.61745614",
"0.60299903",
"0.60110855",
"0.5994544",
"0.5935721",
"0.593195",
"0.58820355",
"0.58757484",
"0.58017737",
"0.57848555",
"0.5741897",
"0.571831",
"0.5690334",
"0.5676682",
"0.56711465",
"0.5664892",
"0.56638384",
"0.56605965",
"0.5651302",
"0.5624326",
"0.55928... | 0.5413158 | 62 |
print footer containing line and position | def print_foot #:nodoc:
return unless @print_footer
return unless @suppress_borders
footer = "R: #{@current_index+1}, C: #{@curpos+@pcol}, #{@list.length} lines "
@graphic.printstring( @row + @height -1 , @col+2, footer, @color_pair || $datacolor, @footer_attrib)
=begin
if @list_footer
if false
# if we want to print ourselves
footer = @list_footer.text(self)
footer_attrib = @list_footer.config[:attrib] || Ncurses::A_REVERSE
#footer = "R: #{@current_index+1}, C: #{@curpos+@pcol}, #{@list.length} lines "
$log.debug " print_foot calling printstring with #{@row} + #{@height} -1, #{@col}+2"
@graphic.printstring( @row + @height -1 , @col+2, footer, @color_pair || $datacolor, footer_attrib)
end
# use default print method which only prints on left
@list_footer.print self
end
=end
@repaint_footer_required = false # 2010-01-23 22:55
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_footer\n # TODO: Design footers.\n mvaddstr(@lines - 1, 10, 'sample footer')\n end",
"def print_foot\n return unless @print_footer\n ha = @_header_adjustment\n # ha takes into account whether there are headers or not\n footer = \"#{@current_index+1-ha} of #{@list.length... | [
"0.82970476",
"0.7710086",
"0.7375752",
"0.7195686",
"0.7099708",
"0.6965797",
"0.69484055",
"0.6790024",
"0.6790024",
"0.6790024",
"0.6759881",
"0.67541194",
"0.6728356",
"0.66131496",
"0.65913385",
"0.6527684",
"0.65121496",
"0.65121496",
"0.64909697",
"0.64709127",
"0.6453... | 0.7452485 | 2 |
NOTE this breaks widgets and everyone's text which returns text of object also list by itself should return the list as in listbox, not just set Supply an array of string to be displayed This will replace existing text display text given in an array format. This is the principal way of giving content to a textpad, other than filename(). | def text(*val)
if val.empty?
return @list
end
$log.debug " TEXTPAD inside text() with #{val.class} "
case val
when Array
# either its an array of strings
# or its an array, and val[0] is an array of strings, and val[1] is a hash / symbol TODO
case val[0]
when String
# This is the usual simple case of an array of strings
@list = val
$log.debug " creating TEXTDOC 0 with String"
when TextDocument
# this is repeating it seems FIXME
$log.debug " creating TEXTDOC 04 with TextDocu #{val[0].content_type} "
@document = val[0]
@document.source ||= self
@document.parse_required # added 2014-09-03 - 17:54
@list = @document.text
when Array
# This is the complex case which i would like to phase out.
# Earlier this was what was used where the second arg was an optional hash
@list = val[0]
if val[1].is_a? Symbol
content_type = val[1]
hsh = { :text => @list, :content_type => content_type }
$log.debug " creating TEXTDOC 1 with #{content_type} "
@document = TextDocument.new hsh
@document.source = self
elsif val[1].is_a? Hash
# this is hack for those cases where ct is there, but the caller may not
# pass it in config
if val[1].key? :content_type and val[1][:content_type].nil?
;
else
# content type comes nil from viewer/help which sets it later using block yield
content_type = val[1][:content_type]
stylesheet = val[1][:stylesheet]
@title = val[1][:title] if val[1].key? :title
$log.debug " creating TEXTDOC 2 with ct=#{content_type}, #{val[1]} "
@document = TextDocument.new val[1]
@document.text = @list
@document.source = self
end
else
#raise "val_1 Unable to do anything with #{val[1].class} "
$log.debug " val_1 Unable to do anything with #{val[1].class} in textpad text()"
end
else
raise "val_0 Unable to do anything with #{val[0].class} "
end
when Hash
$log.debug " creating TEXTDOC 3 with #{val[:content_type]} "
@document = TextDocument.new val
@document.source ||= self
@list = @document.text
when TextDocument
$log.debug " creating TEXTDOC 4 with TextDocu #{val.content_type} "
@document = val
@document.source ||= self
@document.parse_required # added 2014-09-03 - 17:54
@list = @document.text
end
@_populate_needed = true
@repaint_all = true
@repaint_required = true
init_vars
# i don't want the whole thing going into the event 2014-06-04
fire_property_change :text, "dummmy", "text has changed"
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def texts; end",
"def texts=(texts); end",
"def texts=(texts); end",
"def text text\n end",
"def show_prince_file name\n if(text = read_file name)\n prince_text = @texts[0]\n if prince_text == nil\n @number_of_texts += 1\n build_table(@number_of_texts)\n prince_text = @... | [
"0.62396526",
"0.6117915",
"0.6117915",
"0.5919493",
"0.58641875",
"0.5821248",
"0.57858264",
"0.57858264",
"0.57858264",
"0.57643944",
"0.57641715",
"0.57517695",
"0.5731611",
"0.5731611",
"0.5723429",
"0.566349",
"0.56553674",
"0.5649418",
"0.56047577",
"0.56031394",
"0.558... | 0.5821291 | 5 |
this is returning the original content Who is using this, should it return native ? | def content
raise "content is nil " unless @list
return @list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw\n\t\treturn @content\n\tend",
"def raw\n\t\treturn @content\n\tend",
"def original_content\n Thread.current[:__cms_original_content]\n end",
"def contents\n self.content\n end",
"def get_content()\n return super()\n end",
"def content\n return @raw if @raw\n\n ... | [
"0.73933756",
"0.73933756",
"0.69581777",
"0.6890967",
"0.6681767",
"0.66289115",
"0.6549741",
"0.64581513",
"0.64581513",
"0.64581513",
"0.64581513",
"0.64581513",
"0.64581513",
"0.64343613",
"0.64343613",
"0.6396129",
"0.6396129",
"0.6387765",
"0.63868296",
"0.6379485",
"0.... | 0.0 | -1 |
internal method to return the correct list. Rather than trying to synch list and native text for those who do not use the latter let us just use the correct array NOTE there are some cases where document can return a nil since native_text has not been calculated yet. Happens in back button of help. Earlier preprocess was done from +text+ not it is only done from +repaint+ NOTE: native_text is currently Chunklines chunks of text with information of color, whereas list contains whatever the user set, which can include markup for coloring (ansi/tmux). | def _getarray
if @document.nil?
return @list
else
return @document.native_text
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_supporting_document_list\n return if application_type == 'LO-WD'\n\n @display_supporting_document_list = []\n documents_ref_hash = ReferenceData::ReferenceValue.lookup(\"DOCUMENTS-#{application_type}\", 'SLFT', 'RSTU')\n @supporting_document_list.each_with_index do |checked_... | [
"0.63507485",
"0.6065671",
"0.60082954",
"0.56666076",
"0.55889684",
"0.5470101",
"0.54615545",
"0.5447444",
"0.5447444",
"0.53323764",
"0.52682215",
"0.5247789",
"0.5225042",
"0.5223624",
"0.510538",
"0.510538",
"0.5086288",
"0.50768954",
"0.50751936",
"0.5069035",
"0.505871... | 0.6265292 | 1 |
returns focussed value (what cursor is on) This may not be a string. A tree may return a node, a table an array or row | def current_value
# many descendants do not set native_text - note that list and tree and table use just @list.
#@native_text[@current_index]
_getarray[@current_index]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TreeView_GetSelection(hwnd) TreeView_GetNextItem(hwnd, NULL, TreeViewGetNextItem[:CARET]) end",
"def getSelectedItem()\n # ennek mindig az elso oszlop itemjet kell visszaadni\n #midx = @tv.selectionModel.currentIndex\n mi = @treeview.selectionModel.selectedRows.first\n ... | [
"0.6734349",
"0.584872",
"0.58303607",
"0.58116126",
"0.57534224",
"0.5705288",
"0.56984586",
"0.5620686",
"0.56168026",
"0.5609679",
"0.5605597",
"0.55971646",
"0.55971646",
"0.55971646",
"0.5575405",
"0.5530615",
"0.5520486",
"0.5515295",
"0.550363",
"0.550363",
"0.5484872"... | 0.58037025 | 4 |
NOTE : 20140409 14:05 i think this does not have line wise operations since we deal with formatting of data But what if data is not formatted. This imposes a severe limitation. listbox does have linewise operations, so lets try them append a row to the list | def append text
raise "append: deprecated pls use << or push as per Array semantics"
@list ||= []
@list.push text
fire_dimension_changed :append
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list\n @linkedList.append(cols/2, lines/2)\n @linkedList.append(cols/2 - 1, lines/2)\n @linkedList.append(cols/2 - 2, lines/2)\n # @linkedList.print\n end",
"def repaint #:nodoc:\n #safe_create_buffer # 2010-01-04 12:36 BUFFERED moved here 2010-01-05 18:07 \n return unless @repa... | [
"0.5722962",
"0.56242317",
"0.56179106",
"0.55994374",
"0.5559155",
"0.55201447",
"0.5518948",
"0.54415596",
"0.5414668",
"0.53966564",
"0.5362023",
"0.53529596",
"0.5307785",
"0.52726346",
"0.521965",
"0.5163375",
"0.5160069",
"0.51385385",
"0.5135427",
"0.513052",
"0.510958... | 0.48491886 | 54 |
clear all items in the object. NOTE: requires to be separate since init_vars is called to reset index of focus etc. Also, listbox will extend this to clear selected_indices | def clear
return unless @list
@list.clear
@native_text.clear if @native_text # check this line, should it be removed 2014-08-27 - 20:54
fire_dimension_changed :clear
init_vars
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_selection\n return if @selected_indices.nil? || @selected_indices.empty?\n arr = @selected_indices.dup # to un highlight\n @selected_indices.clear\n arr.each {|i| @obj.fire_row_changed(i) }\n @selected_index = nil\n @old_selected_index = nil\n # User should ignore firs... | [
"0.7242692",
"0.71160847",
"0.68570596",
"0.6813393",
"0.6735421",
"0.6714645",
"0.6696401",
"0.6679069",
"0.65000415",
"0.64552677",
"0.64064384",
"0.63865954",
"0.6356768",
"0.6346704",
"0.62739086",
"0.624713",
"0.62205535",
"0.62200785",
"0.6214491",
"0.61880165",
"0.6134... | 0.7018351 | 2 |
update the value at index with given value, returning self | def []=(index, val)
@list[index]=val
fire_row_changed index
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_value_in_index(index, value)\n if value.respond_to? :update_index\n value.update_index(index, self)\n elsif value.is_a?(Hash) && value['version']\n update_value_in_index(index, value['value'])\n else\n index\n end\n end",
"def set( index , va... | [
"0.735736",
"0.7232897",
"0.7162839",
"0.7116047",
"0.71126413",
"0.71103406",
"0.70584816",
"0.7054499",
"0.7044157",
"0.70373565",
"0.70059365",
"0.70049113",
"0.69789845",
"0.6849794",
"0.68191993",
"0.67835367",
"0.67510366",
"0.6738469",
"0.67183024",
"0.67157876",
"0.67... | 0.65567046 | 26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.