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
called when we create a new status request
def newstatus @post = Post.new @post.body = params[:body] Chatter.set_my_user_status(@post) redirect_to my_chatter_home_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @request_status = RequestStatus.new(params[:request_status])\n\n respond_to do |format|\n if @request_status.save\n format.html { redirect_to @request_status, notice: 'Request status was successfully created.' }\n format.json { render json: @request_status, status: :created, l...
[ "0.73411363", "0.7109078", "0.69636625", "0.68620855", "0.684182", "0.68417925", "0.6839015", "0.68042886", "0.68042886", "0.6793406", "0.6756788", "0.6746642", "0.6714731", "0.6714731", "0.6666365", "0.66577464", "0.6630521", "0.6611924", "0.653337", "0.6525466", "0.65149605...
0.0
-1
Returns a list of all possible input sequencesof length +length+.
def sequences_of_length(length) VALID_INPUT.combination(length).to_a.reject do |sequence| sequence.each_cons(2).any? do |a, b| a == b.sub("'", '') || b == a.sub("'", '') end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slices(length)\n last = length - 1\n\t\tfirst = 0\n\n if last > sequence.length - 1\n raise ArgumentError, \"Sub-sequence length must be <= given sequence\"\n end\n\n sub_sequences = []\n\t\twhile last < sequence.length\n sub_sequences << sequence.slice(first..last)\n first += 1\n ...
[ "0.70254266", "0.6976147", "0.679361", "0.668013", "0.6679694", "0.6650579", "0.66400284", "0.65626377", "0.6472248", "0.6396035", "0.6333723", "0.63312984", "0.62991065", "0.62960607", "0.62932193", "0.62134546", "0.62113094", "0.6189521", "0.6128758", "0.6121018", "0.607361...
0.69070995
2
Returns the number of times +sequence+ must be input on a rubik's cube before the cube returns to its solved state.
def repeat_sequence_until_solved(sequence) cube = RubiksCube::Cube.new cube.perform! sequence repetitions = 1 until cube.solved? cube.perform! sequence repetitions += 1 end repetitions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_and_say(sequence)\n\treturn 0 if sequence == nil\n\tsequence = sequence.to_s\n\tn = sequence.to_s.size\n result = ''\n\ti = 1\n\trepeat = sequence[0]\n\ttimes = 1\n\twhile (i<=n) do\n\t\tif sequence[i] == repeat\n\t\t\ttimes += 1\n else\n \tresult += times.to_s + repeat.to_s\n \tt...
[ "0.63312143", "0.6146185", "0.60215783", "0.59849024", "0.58610976", "0.58583635", "0.58257335", "0.57228297", "0.57089317", "0.56598604", "0.5642714", "0.5565444", "0.5546269", "0.5468809", "0.54518676", "0.542781", "0.54089135", "0.5407938", "0.53951836", "0.538938", "0.535...
0.7004776
0
to display favicon image in site. Usage: need to call inside of tag in layout
def display_favicon if !self.favicon_file_name.blank? return "<link rel='shortcut icon' href='#{self.favicon.url}'/>" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favicon_tag(name = 'favicon.ico')\n content_tag :link, nil, rel: %w(shortcut icon), href: image_path(name)\n end", "def favicon #google has an api that fetches favicons. :-)\n \"https://plus.google.com/_/favicon?domain=#{self.feed.html_url}\"\n end", "def favicon\n \"hammer/hammer.png\"\n e...
[ "0.7704699", "0.7613737", "0.75322556", "0.73790145", "0.71790636", "0.7140256", "0.7133364", "0.71311504", "0.71288466", "0.71189415", "0.70651984", "0.706078", "0.69613314", "0.694441", "0.6909124", "0.6791751", "0.6757064", "0.6754922", "0.6726217", "0.6616027", "0.6524112...
0.81375265
0
The method extracted only for specs because RSpec doesn't allow expect the result for several instances of the same class.
def finish_sync(sync) sync.finish! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result_class\n expect :result\n\n self[2]\n end", "def expect cl\n @expected_class = cl\n end", "def spec; end", "def spec; end", "def module\n expect :result\n\n self[1]\n end", "def call\n expect :result\n\n self.last\n end", "def test_get_class\n\t\t@new_driver.class 1\n...
[ "0.70697683", "0.6664465", "0.64465153", "0.64465153", "0.6282157", "0.6128067", "0.6110319", "0.58430505", "0.57666135", "0.57502043", "0.5745179", "0.5744176", "0.57012975", "0.5680647", "0.56483936", "0.56483936", "0.56483936", "0.56483936", "0.5630226", "0.56222904", "0.5...
0.0
-1
The method extracted only for specs because RSpec doesn't allow expect the result for several instances of the same class.
def skip_property(sync, property_id, message) sync.skip_property(property_id, message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result_class\n expect :result\n\n self[2]\n end", "def expect cl\n @expected_class = cl\n end", "def spec; end", "def spec; end", "def module\n expect :result\n\n self[1]\n end", "def call\n expect :result\n\n self.last\n end", "def test_get_class\n\t\t@new_driver.class 1\n...
[ "0.7070101", "0.6665808", "0.64461726", "0.64461726", "0.6281822", "0.6126869", "0.6112044", "0.58442956", "0.5768315", "0.57496756", "0.5745184", "0.5744603", "0.5701233", "0.56828165", "0.5647371", "0.5647371", "0.5647371", "0.5647371", "0.56324214", "0.5622052", "0.5616046...
0.0
-1
Creates a new sprite. Parameters: [x] The xcoordinate in the screen (or map) where the sprite will be drawn. This can be modified later via the +x+ attribute. [y] The ycoordinate in the screen (or map) where the sprite will be drawn. This can be modified later via the +y+ attribute. [img] The path to a PNG image or spritesheet, following the MiniGL convention: images must be inside a 'data/img' directory, relative to the code file, and you must only provide the file name, without extension, in this case. If the image is inside a subdirectory of 'data/img', you must prefix the file name with each subdirectory name, followed by an underscore (so the file and directories names must not contain underscores). For example, if your image is 'data/img/sprite/1.png', you must provide "sprite_1" or +:sprite_1+. [sprite_cols] The number of columns in the spritesheet. Use +nil+ if the image is not a spritesheet. [sprite_rows] The number of rows in the spritesheet. Use +nil+ if the image is not a spritesheet.
def initialize(x, y, img, sprite_cols = nil, sprite_rows = nil, retro = nil) @x = x; @y = y retro = Res.retro_images if retro.nil? @img = if sprite_cols.nil? [Res.img(img, false, false, '.png', retro)] else Res.imgs img, sprite_cols, sprite_rows, false, '.png', retro end @anim_counter = 0 @img_index = 0 @index_index = 0 @animate_once_control = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createSprite(*args, **kwargs)\n addSprite Sprite.new(*args, **kwargs, context: self)\n end", "def draw_tile(sprite, mapx, mapy)\n $temp_bitmaps ||= {}\n # Reset the sprite to a blank tilesprite\n sprite.clear\n sprite.mapx = mapx\n sprite.mapy = mapy\n # Reconfigure if i...
[ "0.70432645", "0.6285953", "0.6080569", "0.5972322", "0.5960092", "0.5940288", "0.58611155", "0.57970893", "0.57521695", "0.57427275", "0.5741529", "0.56547344", "0.5649641", "0.5531271", "0.55261844", "0.5415677", "0.5414733", "0.53466976", "0.53223425", "0.53194827", "0.531...
0.6583135
1
Performs time checking to update the image index according to the sequence of indices and the interval. Parameters: [indices] The sequence of image indices used in the animation. The indices are determined from left to right, and from top to bottom, inside the spritesheet. All indices must be in the interval 0..(sprite_cols sprite_rows). [interval] The amount of frames between each change in the image index. A frame will usually represent 1/60 second (roughly 17 milliseconds).
def animate(indices, interval) @animate_once_control = 0 if @animate_once_control != 0 @anim_counter += 1 if @anim_counter >= interval @index_index += 1 @index_index = 0 if @index_index >= indices.length @img_index = indices[@index_index] @anim_counter = 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def animate_once(indices, interval)\n if @animate_once_control == 2\n return if indices == @animate_once_indices && interval == @animate_once_interval\n @animate_once_control = 0\n end\n\n unless @animate_once_control == 1\n @anim_counter = 0\n @img_index = indices[0]\n ...
[ "0.67932165", "0.5850745", "0.537532", "0.5158806", "0.51509875", "0.50027746", "0.4999628", "0.49868363", "0.4882532", "0.48782784", "0.48545107", "0.4789278", "0.4789278", "0.46963447", "0.46810278", "0.46705323", "0.46287847", "0.45982212", "0.45975378", "0.45791647", "0.4...
0.7632635
0
Causes the sprite to animate through the +indices+ array exactly once, so that the animation stops once it reaches the last index in the array. Subsequent calls with the same parameters will have no effect, but if the index or interval changes, or if +set_animation+ is called, then a new animation cycle will begin. Parameters: [indices] The sequence of image indices used in the animation. See +animate+ for details. [interval] The amount of frames between each change in the image index. See +animate+ for details.
def animate_once(indices, interval) if @animate_once_control == 2 return if indices == @animate_once_indices && interval == @animate_once_interval @animate_once_control = 0 end unless @animate_once_control == 1 @anim_counter = 0 @img_index = indices[0] @index_index = 0 @animate_once_indices = indices @animate_once_interval = interval @animate_once_control = 1 return end @anim_counter += 1 return unless @anim_counter >= interval if @index_index == indices.length - 1 @animate_once_control = 2 yield if block_given? else @index_index += 1 @img_index = indices[@index_index] @anim_counter = 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def animate(indices, interval)\n @animate_once_control = 0 if @animate_once_control != 0\n\n @anim_counter += 1\n if @anim_counter >= interval\n @index_index += 1\n @index_index = 0 if @index_index >= indices.length\n @img_index = indices[@index_index]\n @anim_counter = 0...
[ "0.8123561", "0.5603129", "0.5060874", "0.4986917", "0.47035712", "0.45703468", "0.453749", "0.4506747", "0.445484", "0.4313996", "0.42830867", "0.41924006", "0.41918364", "0.41903386", "0.41644084", "0.4143785", "0.41248417", "0.40977767", "0.40961343", "0.4092348", "0.40905...
0.7864943
1
Resets the animation timer and immediately changes the image index to the specified value. Parameters: [index] The image index to be set.
def set_animation(index) @anim_counter = 0 @img_index = index @index_index = 0 @animate_once_control = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def animate(indices, interval)\n @animate_once_control = 0 if @animate_once_control != 0\n\n @anim_counter += 1\n if @anim_counter >= interval\n @index_index += 1\n @index_index = 0 if @index_index >= indices.length\n @img_index = indices[@index_index]\n @anim_counter = 0...
[ "0.61681664", "0.59582156", "0.5815606", "0.57679814", "0.5756334", "0.57385564", "0.5715919", "0.5653273", "0.5650426", "0.56498456", "0.5583458", "0.55641055", "0.5514039", "0.5502628", "0.54915655", "0.5491464", "0.54582906", "0.54329467", "0.5432337", "0.5417815", "0.5402...
0.8521929
0
Draws the sprite in the screen Parameters: [map] A Map object, relative to which the sprite will be drawn (the x and y coordinates of the sprite will be changed according to the position of the camera). [scale_x] A scale factor to be applied horizontally to the image. [scale_y] A scale factor to be applied vertically to the image. [alpha] The opacity with which the image will be drawn. Valid values vary from 0 (fully transparent) to 255 (fully opaque). [color] A color filter to apply to the image. A white (0xffffff) filter will keep all colors unchanged, while a black (0x000000) filter will turn all colors to black. A red (0xff0000) filter will keep reddish colors with slight or no change, whereas bluish colors will be darkened, for example. [angle] A rotation, in degrees, to be applied to the image, relative to its center. [flip] Specify +:horiz+ to draw the image horizontally flipped or +:vert+ to draw it vertically flipped. [z_index] The zorder to draw the object. Objects with larger zorders will be drawn on top of the ones with smaller zorders. [round] Specify whether the drawing coordinates should be rounded to an integer before drawing, to avoid little distortions of the image. Only applies when the image is not rotated. Obs.: This method accepts named parameters.
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0, round = false) if map.is_a? Hash scale_x = map.fetch(:scale_x, 1) scale_y = map.fetch(:scale_y, 1) alpha = map.fetch(:alpha, 0xff) color = map.fetch(:color, 0xffffff) angle = map.fetch(:angle, nil) flip = map.fetch(:flip, nil) z_index = map.fetch(:z_index, 0) round = map.fetch(:round, false) map = map.fetch(:map, nil) end color = (alpha << 24) | color if angle @img[@img_index].draw_rot @x - (map ? map.cam.x : 0) + @img[0].width * scale_x * 0.5, @y - (map ? map.cam.y : 0) + @img[0].height * scale_y * 0.5, z_index, angle, 0.5, 0.5, (flip == :horiz ? -scale_x : scale_x), (flip == :vert ? -scale_y : scale_y), color else x = @x - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @img[0].width : 0) y = @y - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @img[0].height : 0) @img[@img_index].draw (round ? x.round : x), (round ? y.round : y), z_index, (flip == :horiz ? -scale_x : scale_x), (flip == :vert ? -scale_y : scale_y), color end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0, round = false)\n if map.is_a? Hash\n scale_x = map.fetch(:scale_x, 1)\n scale_y = map.fetch(:scale_y, 1)\n alpha = map.fetch(:alpha, 0xff)\n color = map.fetch(:color,...
[ "0.74931526", "0.692015", "0.6474601", "0.643925", "0.6372235", "0.6344919", "0.6114015", "0.6050976", "0.6043528", "0.6022657", "0.5971904", "0.5958954", "0.595464", "0.5929252", "0.59070486", "0.59025466", "0.58909833", "0.5888217", "0.58242387", "0.58221126", "0.58148956",...
0.7725769
0
Returns whether this sprite is visible in the given map (i.e., in the viewport determined by the camera of the given map). If no map is given, returns whether the sprite is visible on the screen.
def visible?(map = nil) r = Rectangle.new @x, @y, @img[0].width, @img[0].height return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil? map.cam.intersect? r end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visible?(map = nil)\n r = Rectangle.new @x.round + @img_gap.x, @y.round + @img_gap.y, @img[0].width, @img[0].height\n return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil?\n map.cam.intersect? r\n end", "def in_world_map?\n worldmap_id == $game_map.map_id;\...
[ "0.8107721", "0.63565135", "0.6168141", "0.61618966", "0.59793663", "0.5869703", "0.5829974", "0.5827169", "0.5813481", "0.5789108", "0.57382315", "0.56923515", "0.55797946", "0.5542954", "0.55360955", "0.5498238", "0.5491193", "0.5491193", "0.5465914", "0.545443", "0.5453632...
0.8288609
0
Creates a new game object. Parameters: [x] The xcoordinate of the object's bounding box. This can be modified later via the +x+ attribute. [y] The ycoordinate of the object's bounding box. This can be modified later via the +y+ attribute. [w] The width of the object's bounding box. [h] The height of the object's bounding box. [img] The image or spritesheet for the object. [img_gap] A Vector object representing the difference between the top left corner of the bounding box and the coordinates of the image. For example, an object with x = 100, y = 50 and img_gap = Vector.new(5, 5) will be drawn at position (95, 45) of the screen. [sprite_cols] The number of columns in the spritesheet. Use +nil+ if the image is not a spritesheet. [sprite_rows] The number of rows in the spritesheet. Use +nil+ if the image is not a spritesheet. [mass] The mass of the object. Details on how it is used can be found in the Movement module.
def initialize(x, y, w, h, img, img_gap = nil, sprite_cols = nil, sprite_rows = nil, mass = 1.0, retro = nil) super x, y, img, sprite_cols, sprite_rows, retro @w = w; @h = h @img_gap = if img_gap.nil? Vector.new 0, 0 else img_gap end @mass = mass @speed = Vector.new 0, 0 @max_speed = Vector.new 15, 15 @stored_forces = Vector.new 0, 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(x, y, w, h)\r\n @x = x\r\n @y = y\r\n @w = w\r\n @h = h\r\n end", "def initialize(x, y, w, h)\n @x = x; @y = y; @w = w; @h = h\n end", "def initialize(x, y, img, sprite_cols = nil, sprite_rows = nil, retro = nil)\n @x = x; @y = y\n retro = Res.retro_images if retro...
[ "0.5437306", "0.5428086", "0.54248554", "0.52787316", "0.52528024", "0.5133702", "0.5126961", "0.51115865", "0.504736", "0.5019972", "0.5013972", "0.50000995", "0.49725556", "0.49542212", "0.49483132", "0.4947888", "0.49439082", "0.4936233", "0.49021056", "0.4890714", "0.4888...
0.72775155
0
Draws the game object in the screen. Parameters: [map] A Map object, relative to which the object will be drawn (the x and y coordinates of the image will be changed according to the position of the camera). [scale_x] A scale factor to be applied horizontally to the image. [scale_y] A scale factor to be applied vertically to the image. [alpha] The opacity with which the image will be drawn. Valid values vary from 0 (fully transparent) to 255 (fully opaque). [color] A color filter to apply to the image. A white (0xffffff) filter will keep all colors unchanged, while a black (0x000000) filter will turn all colors to black. A red (0xff0000) filter will keep reddish colors with slight or no change, whereas bluish colors will be darkened, for example. [angle] A rotation, in degrees, to be applied to the image, relative to its center. [flip] Specify +:horiz+ to draw the image horizontally flipped or +:vert+ to draw it vertically flipped. [z_index] The zorder to draw the object. Objects with larger zorders will be drawn on top of the ones with smaller zorders. [round] Specify whether the drawing coordinates should be rounded to an integer before drawing, to avoid little distortions of the image. Only applies when the image is not rotated. Obs.: This method accepts named parameters.
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0, round = false) if map.is_a? Hash scale_x = map.fetch(:scale_x, 1) scale_y = map.fetch(:scale_y, 1) alpha = map.fetch(:alpha, 0xff) color = map.fetch(:color, 0xffffff) angle = map.fetch(:angle, nil) flip = map.fetch(:flip, nil) z_index = map.fetch(:z_index, 0) round = map.fetch(:round, false) map = map.fetch(:map, nil) end color = (alpha << 24) | color img_gap_scale_x = scale_image_gap? ? scale_x : 1 img_gap_scale_y = scale_image_gap? ? scale_y : 1 if angle center_x = @x + @w * 0.5 center_y = @y + @h * 0.5 o_x = center_x - @x - @img_gap.x * img_gap_scale_x o_y = center_y - @y - @img_gap.y * img_gap_scale_y @img[@img_index].draw_rot @x + (flip == :horiz ? -1 : 1) * (@img_gap.x * img_gap_scale_x + o_x) - (map ? map.cam.x : 0), @y + (flip == :vert ? -1 : 1) * (@img_gap.y * img_gap_scale_y + o_y) - (map ? map.cam.y : 0), z_index, angle, o_x.to_f / (@img[0].width * scale_x), o_y.to_f / (@img[0].height * scale_y), (flip == :horiz ? -scale_x : scale_x), (flip == :vert ? -scale_y : scale_y), color else x = @x + (flip == :horiz ? -1 : 1) * @img_gap.x * img_gap_scale_x - (map ? map.cam.x : 0) + (flip == :horiz ? @w : 0) y = @y + (flip == :vert ? -1 : 1) * @img_gap.y * img_gap_scale_y - (map ? map.cam.y : 0) + (flip == :vert ? @h : 0) @img[@img_index].draw (round ? x.round : x), (round ? y.round : y), z_index, (flip == :horiz ? -scale_x : scale_x), (flip == :vert ? -scale_y : scale_y), color end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0, round = false)\n if map.is_a? Hash\n scale_x = map.fetch(:scale_x, 1)\n scale_y = map.fetch(:scale_y, 1)\n alpha = map.fetch(:alpha, 0xff)\n color = map.fetch(:color,...
[ "0.8430109", "0.6266536", "0.6140498", "0.6000023", "0.59707093", "0.59111613", "0.58751583", "0.5780143", "0.5763302", "0.5628909", "0.5627975", "0.5623518", "0.5613192", "0.5603382", "0.5600094", "0.558437", "0.55763775", "0.5570321", "0.55095863", "0.548523", "0.5480727", ...
0.8170172
1
Returns whether this object is visible in the given map (i.e., in the viewport determined by the camera of the given map). If no map is given, returns whether the object is visible on the screen.
def visible?(map = nil) r = Rectangle.new @x.round + @img_gap.x, @y.round + @img_gap.y, @img[0].width, @img[0].height return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil? map.cam.intersect? r end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visible?(map = nil)\n r = Rectangle.new @x, @y, @img[0].width, @img[0].height\n return Rectangle.new(0, 0, G.window.width, G.window.height).intersect? r if map.nil?\n map.cam.intersect? r\n end", "def in_world_map?\n worldmap_id == $game_map.map_id;\n end", "def visible\n return ...
[ "0.80681723", "0.62258744", "0.60435814", "0.5960403", "0.5943564", "0.5889114", "0.57549244", "0.56922704", "0.5668801", "0.55619466", "0.5498186", "0.5497328", "0.54925233", "0.5466244", "0.5414353", "0.53651494", "0.53651494", "0.5325944", "0.530811", "0.53016657", "0.5276...
0.7868873
1
override this if you don't want the image_gap to be scaled when drawing the object scaled.
def scale_image_gap? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setscale(*)\n super\n end", "def scale\n scale_factor = 20 # template.png height divided by canvas height\n self.image_x *= scale_factor\n self.image_y *= scale_factor\n self.height *= scale_factor\n self.width *= scale_factor\n self.rotation *= 180 / Math::PI\n end", "def scales...
[ "0.60154223", "0.59893703", "0.5810581", "0.5712202", "0.56933093", "0.568321", "0.5650084", "0.5644999", "0.5644999", "0.55733305", "0.55439556", "0.55172795", "0.5455107", "0.54243296", "0.54128546", "0.5396739", "0.53789335", "0.5375571", "0.535862", "0.5353535", "0.534919...
0.71711046
0
Creates a new Effect. Parameters: [x] The xcoordinate in the screen (or map) where the effect will be drawn. This can be modified later via the +x+ attribute. [y] The ycoordinate in the screen (or map) where the effect will be drawn. This can be modified later via the +y+ attribute. [img] The image or spritesheet to use for this effect (see Sprite for details on spritesheets). [sprite_cols] (see Sprite) [sprite_rows] (see Sprite) [interval] The interval between steps of the animation, in updates. [indices] The indices to use in the animation. See Spriteanimate for details. If +nil+, it will be the sequence from 0 to sprite_cols sprite_rows 1. [lifetime] The lifetime of the effect, in updates. After +update+ is called this number of times, the effect will no longer be visible, even when +draw+ is called, and the +dead+ flag will be set to +true+, so you get to know when to dispose of the Effect object. If +nil+, it will be set to
def initialize(x, y = nil, img = nil, sprite_cols = nil, sprite_rows = nil, interval = 10, indices = nil, lifetime = nil, sound = nil, sound_ext = '.wav', sound_volume = 1) if x.is_a? Hash y = x[:y] img = x[:img] sprite_cols = x.fetch(:sprite_cols, nil) sprite_rows = x.fetch(:sprite_rows, nil) interval = x.fetch(:interval, 10) indices = x.fetch(:indices, nil) lifetime = x.fetch(:lifetime, nil) sound = x.fetch(:sound, nil) sound_ext = x.fetch(:sound_ext, '.wav') sound_volume = x.fetch(:sound_volume, 1) x = x[:x] end super x, y, img, sprite_cols, sprite_rows @elapsed_time = 0 if indices @indices = indices else @indices = *(0..(@img.length - 1)) end @interval = interval if lifetime @lifetime = lifetime else @lifetime = @indices.length * interval end Res.sound(sound, false, sound_ext).play(sound_volume) if sound end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(x, y, img, sprite_cols = nil, sprite_rows = nil, retro = nil)\n @x = x; @y = y\n retro = Res.retro_images if retro.nil?\n @img =\n if sprite_cols.nil?\n [Res.img(img, false, false, '.png', retro)]\n else\n Res.imgs img, sprite_cols, sprite_rows, false, ...
[ "0.545789", "0.5209705", "0.5082415", "0.50494367", "0.49363676", "0.49205846", "0.49144953", "0.48887473", "0.48088175", "0.47962973", "0.47874418", "0.47817492", "0.47757638", "0.47635645", "0.45964244", "0.45897523", "0.4561154", "0.45496482", "0.44745898", "0.44731206", "...
0.67705256
0
Updates the effect, animating and counting its remaining lifetime.
def update return if @dead animate(@indices, @interval) @elapsed_time += 1 @dead = true if @elapsed_time == @lifetime end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n update_animation\n end", "def update\n super\n if @_whiten_duration > 0\n @_whiten_duration -= 1\n self.color.alpha = 128 - (16 - @_whiten_duration) * 10\n end\n if @_appear_duration > 0\n @_appear_duration -= 1\n self.opacity = (16 - @_appear_...
[ "0.6806101", "0.6717676", "0.66653746", "0.65925425", "0.6332518", "0.62422377", "0.6241056", "0.6009155", "0.59651685", "0.5822414", "0.5769646", "0.5752033", "0.5746992", "0.57161814", "0.5701114", "0.5700119", "0.56729305", "0.5622045", "0.56091565", "0.5598358", "0.559835...
0.6448586
4
The remaining number of calls to +update+ until the effect is marked +dead+.
def time_left @lifetime - @elapsed_time end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n return if @dead\n\n animate(@indices, @interval)\n @elapsed_time += 1\n @dead = true if @elapsed_time == @lifetime\n end", "def dead\n @dead ||= count('dead')\n end", "def dead!\n @state_mutex.synchronize do\n @dead = true\n ...
[ "0.6823394", "0.64638925", "0.6378035", "0.6181562", "0.61020434", "0.60740733", "0.60661167", "0.5945667", "0.5914682", "0.5914682", "0.58969676", "0.5792545", "0.5780272", "0.57650024", "0.5738494", "0.57311344", "0.57311344", "0.5724066", "0.5703746", "0.569178", "0.568879...
0.0
-1
GET /tasks GET /tasks.json
def index @tasks = Task.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def tasks\n @todos = Todo.all\n render json: @todos\n end", "def index\n render json: {\n tasks: tasks.map(&:to_hash)\n }\n end", "def index\n @tasks = Task.all\n\n render json: @tasks\n end", "...
[ "0.7889543", "0.7751927", "0.7619872", "0.75984913", "0.75936216", "0.7505406", "0.7464987", "0.74337274", "0.7383206", "0.7344766", "0.7322099", "0.7322099", "0.7322099", "0.7303383", "0.7263056", "0.72467685", "0.72430325", "0.7233159", "0.7165631", "0.7160025", "0.713756",...
0.69545823
53
GET /tasks/1 GET /tasks/1.json
def show @users = User.all find_ranking(@task) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @task = Task.find(params[:id])\n\n render json: @task\n end", "def task(name)\n get \"#{base_url}/tasks/#{name}\"\n end", "def show\n render :json => Project.find(params[:project_id]).tasks.find(params[:id])\n end", "def show\n \n @task = @project.tasks.find(params[:i...
[ "0.76096785", "0.7555889", "0.7456459", "0.74471563", "0.73451596", "0.7336069", "0.7332103", "0.72564024", "0.7243799", "0.72252154", "0.72077334", "0.72030824", "0.72028416", "0.72028416", "0.72028416", "0.72028416", "0.72028416", "0.72028416", "0.72028416", "0.72028416", "...
0.0
-1
POST /tasks POST /tasks.json
def create @task = Task.new(task_params) respond_to do |format| if @task.save @users = User.all @users.each do |user| user.tasks << @task end format.html { redirect_to @task, notice: 'Task was successfully created.' } format.json { render :show, status: :created, location: @task } else format.html { render :new } format.json { render json: @task.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end", "def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, status: :created\n else\n render json: @task.errors, status: :unprocessable_entit...
[ "0.7529737", "0.74976224", "0.7411092", "0.7389878", "0.7261207", "0.72587913", "0.7183996", "0.7147952", "0.71120256", "0.70759165", "0.70639485", "0.70576006", "0.70294535", "0.7016957", "0.7012058", "0.70110804", "0.7009976", "0.6993863", "0.69896185", "0.69874805", "0.697...
0.70560944
12
PATCH/PUT /tasks/1 PATCH/PUT /tasks/1.json
def update respond_to do |format| if @task.update(task_params) format.html { redirect_to @task, notice: 'Task was successfully updated.' } format.json { render :show, status: :ok, location: @task } else format.html { render :edit } format.json { render json: @task.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end", "def update\n task = Task.find(params[:id])\n if task.update(t...
[ "0.7446407", "0.72926295", "0.7265538", "0.7265538", "0.7139364", "0.70770514", "0.7025478", "0.6965281", "0.69626737", "0.69527304", "0.6910656", "0.6906986", "0.6906986", "0.6906986", "0.68968856", "0.68968856", "0.68968856", "0.68968856", "0.68968856", "0.68968856", "0.689...
0.6712811
72
DELETE /tasks/1 DELETE /tasks/1.json
def destroy @task.destroy respond_to do |format| format.html { redirect_to tasks_url, notice: 'Task was successfully destroyed.' } format.json { head :no_content } end destroy_todos end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_task id\n request :delete, \"tasks/#{id}\"\n nil\n end", "def delete_task\n @task = Task.find_by(id: params[:id])\n @task.destroy\n render :json => @task.as_json(:only => [:id])\n end", "def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\n respond_to do |f...
[ "0.783128", "0.758814", "0.7564727", "0.7563992", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.7530271", "0.74891233", "0.74891233", "0.74891233", "0.74891233", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_task @task = Task.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def task_params params.require(:task).permit(:title, :photo, :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.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
using a attr macro use a setter/getter method || reader/writer setter method / writer
def name=(name_to_be_set) @name = name_to_be_set end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer(sym, *more) end", "def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter = match[1], !match[2].blank?\n if setter\n write_attribute(attribute, args.first)\n else\n read...
[ "0.7881115", "0.77442163", "0.7528443", "0.7346653", "0.73397803", "0.7198357", "0.7146539", "0.71263576", "0.7097561", "0.7085349", "0.7083117", "0.7072821", "0.70680285", "0.70030534", "0.6993473", "0.69707364", "0.69220525", "0.6911302", "0.6854419", "0.6849556", "0.682422...
0.0
-1
getter method / reader method
def name @name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reader; end", "def getters; end", "def read\n raise NotImplementedError\n end", "def value_read; end", "def custom_reader(key); end", "def read\nend", "def read\n end", "def read\n end", "def read\n end", "def read\n end", "def read\n end", "def read; end", "def rea...
[ "0.7603005", "0.7255067", "0.7237808", "0.72242737", "0.71812576", "0.71484613", "0.70865655", "0.70632446", "0.70632446", "0.70632446", "0.70632446", "0.6973736", "0.6973736", "0.6973736", "0.6973736", "0.6973736", "0.6973736", "0.6973736", "0.69529206", "0.69525605", "0.689...
0.0
-1
Return a list of matching nodes
def find(*queryKeyValueList) results = [] queryKeyValueList = queryKeyValueList.map { |kv| kv = [kv] if not kv.is_a?(Array) kv.map { |a| a.to_s } } # Of node's children, return the matches helper = lambda { |node,i| results << node if i == queryKeyValueList.size # For each children node of node queryKey, queryValue = queryKeyValueList[i] node[2..-1].each { |childNode| # Skip children that don't match next if not (queryKey == nil || queryKey == childNode[0]) next if not (queryValue == nil || queryValue == childNode[1]) helper.call(childNode, i+1) } } helper.call(@root, 0) results end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ret_matching_nodes(parent_idh)\n if parent_idh[:model_name] == :node\n return [parent_idh]\n end\n filter = [:eq, :assembly_id, parent_idh.get_id()]\n if node_filter = ret_filter(pattern, :node)\n filter = [:and, filter, node_filter]\n end\n sp_hash =...
[ "0.72054785", "0.68032295", "0.6681784", "0.6629291", "0.66020656", "0.65455943", "0.65157765", "0.6511836", "0.6456211", "0.6441955", "0.6401519", "0.6391465", "0.634339", "0.6328192", "0.6316508", "0.6316508", "0.6200367", "0.61932087", "0.6166497", "0.6161318", "0.61529654...
0.0
-1
Create an image tag using a CMS image
def cms_image_tag(img_key, options = {}) image_tag cms_image_url(img_key), options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_image_tag(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def create_image_object(obj)\n return content_tag(:div, tag(:img, :src => obj.link), :style => \"position:absolute; top: #{obj.y}px; left: #{obj.x}p...
[ "0.6842782", "0.67244256", "0.65069664", "0.65015787", "0.6480616", "0.6463281", "0.6448653", "0.63864076", "0.63692224", "0.6312855", "0.6305681", "0.63027495", "0.6290837", "0.62865555", "0.6267463", "0.62654066", "0.6238592", "0.62341255", "0.62283593", "0.61913055", "0.61...
0.6842794
0
Get the URL for a CMS image
def cms_image_url(img_key) cms_host = 'http://local.amaysim2.com.au/' #TODO load from compass.yml "#{cms_host}#{CMS_IMAGES[img_key]}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_url\n return unless image.attached?\n\n url_for(image)\n end", "def image_url\n rails_blob_url(object.image)\n # This helper gets the URL from the file we pass to it\n end", "def image_url\n # It's just stored in public/data/slug.jpg or whatever the relevant file\n # extension is\...
[ "0.76803344", "0.7617381", "0.756387", "0.75256824", "0.7515508", "0.7498853", "0.74586", "0.7450049", "0.7444413", "0.74399376", "0.742541", "0.742541", "0.73239076", "0.72990835", "0.728202", "0.72617894", "0.72122866", "0.7210961", "0.71911246", "0.7187627", "0.71841884", ...
0.80574447
0
Create a link to a CMS page
def link_to_cms(text, page_key, html_options = {}) cms_host = 'http://local.amaysim2.com.au/' #TODO load from compass.yml link_to(text, "#{cms_host}#{CMS_PAGES[page_key]}", html_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link\n\t\tpage_id.present? ? short_page_path(Page.find(page_id)) : href\n\tend", "def link_to_page(name)\n page = StaticPage.find_by_name(name)\n page = StaticPage.create!(:name => name) unless page\n static_page_path(page)\n end", "def link(link, title, content)\n\t \"<u><link href='#{link}'>#...
[ "0.7000083", "0.6885987", "0.6783044", "0.67136425", "0.67068034", "0.662032", "0.6592625", "0.6592625", "0.65571064", "0.6469533", "0.6403383", "0.6403383", "0.63746876", "0.6360959", "0.63596815", "0.6355907", "0.63102543", "0.62793565", "0.6277532", "0.62706345", "0.626878...
0.7775213
0
the desired result. To check your work, run this file by entering the following command in your terminal: `ruby section2/exercises/methods.rb` Example: Write a method that when called will print your name:
def print_name p "Chris" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_name\n puts \"Will Meighan\"\nend", "def print_name(name)\nputs \"Name: #{name}\"\nend", "def print_name\n p \"Alexander Mathieu\"\nend", "def print_name\r\nputs \"Person called #{@name}\"\r\nend", "def print_name\n puts \"Person called #{@name}\" \n end", "def print_name(name)\n p \"#{nam...
[ "0.797948", "0.7957922", "0.7926663", "0.7919581", "0.785807", "0.7833971", "0.7833971", "0.7833971", "0.7833971", "0.7833971", "0.7804437", "0.78043246", "0.78019506", "0.78019506", "0.78019506", "0.7794831", "0.77932703", "0.7787219", "0.77848923", "0.77848047", "0.7781644"...
0.7854998
5
Write a method that takes a name as an argument and prints it:
def print_name(name) puts name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n puts \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(name)\n p \"#{name}\"\nend", "def print_name(nam...
[ "0.8686641", "0.8686641", "0.8686641", "0.86739975", "0.86739975", "0.86739975", "0.86739975", "0.86739975", "0.8567322", "0.8561365", "0.85212", "0.8520563", "0.8504922", "0.850404", "0.850404", "0.850404", "0.850404", "0.850404", "0.850404", "0.850404", "0.850404", "0.850...
0.8691205
18
Write a method that takes in 2 numbers as arguments and prints their sum. Then call your method three times with different arguments passed in: def find_sum(num1, num2)
def find_sum(num1, num2) puts num1 + num2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_finder(num_1, num_2)\n p num_1 + num_2\nend", "def sum_nums(num1, num2)\n puts num1 + num2\nend", "def get_sum(num1, num2)\n puts num1 + num2\nend", "def sum(num1, num2)\n puts num1 + num2\nend", "def sum_these_numbers(num1,num2)\n p num1 + num2\nend", "def sum_these_numbers(num1, num2)\n n...
[ "0.84927404", "0.80532575", "0.8038269", "0.79111606", "0.78716236", "0.7864373", "0.78119504", "0.77689624", "0.77525085", "0.77327144", "0.77202815", "0.77113235", "0.77060896", "0.7660259", "0.7657359", "0.7648487", "0.763613", "0.76117635", "0.76093984", "0.76064634", "0....
0.84406096
1
Write a method that takes in two strings as arguments and prints a concatenation of those two strings. Example: The arguments could be (man, woman) and the end result might output: "When Harry Met Sally". Then call your method three times with different arguments passed in.
def string_concat(name_1, name_2) puts "I went to the concert with " +name_1 + " and " + name_2 + "." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concatenation(word1, word2)\n puts \"Artist #{word1} just released their newest album, titled #{word2}.\"\nend", "def two_strings(man, woman)\n p \"When \" + man + \" Met \" + woman\nend", "def concatenation (blow_dryer_setting, male_first_name)\n puts \"but my friends call me #{blow_dryer_setting} #{ma...
[ "0.784094", "0.7593754", "0.74772567", "0.741101", "0.73758084", "0.7316279", "0.7307053", "0.7301557", "0.72806114", "0.7259849", "0.72506607", "0.7204356", "0.7182326", "0.7169341", "0.71501356", "0.71481013", "0.7142423", "0.7101015", "0.70815766", "0.7074061", "0.70639867...
0.7905186
0
Builds following: saveMMS my_key tatango_test Hello Hello
def build_save_mms(subject, text, fallback_text, attachments) api_key = @api_key x = Builder::XmlMarkup.new x.instruct! x.REQUEST { x.ACTION "saveMMS" x.API_KEY api_key x.NAME "tatango_test" x.FALLBACKSMSTEXT fallback_text x.SUBJECT subject if subject x.SLIDE { x.TEXT text attachments.each do |attachment| x.tag!(attachment[:type]) do x.URL attachment[:url] end end } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_send_saved_mms(from, to, mms_id, fallbacksmstext, operator_id, subject=nil, content=nil)\n x = Builder::XmlMarkup.new\n x.instruct!\n x.REQUEST {\n x.ACTION \"sendSavedMMS\"\n x.API_KEY @api_key\n x.MMSID mms_id\n x.TO to\n x.FALLBACKSMSTEXT fallbacksmste...
[ "0.5744665", "0.5669326", "0.534049", "0.52799803", "0.5216046", "0.51862437", "0.51826835", "0.51109374", "0.50432795", "0.50246716", "0.49805236", "0.49757338", "0.49686345", "0.49628747", "0.4954416", "0.49391353", "0.4908906", "0.49015215", "0.49004042", "0.4880895", "0.4...
0.5782054
0
sendSavedMMS qTFkykO9JTfahCOqJ0V2Wf5Cg1t8iWlZ 16501234123 60856 35674 4
def build_send_saved_mms(from, to, mms_id, fallbacksmstext, operator_id, subject=nil, content=nil) x = Builder::XmlMarkup.new x.instruct! x.REQUEST { x.ACTION "sendSavedMMS" x.API_KEY @api_key x.MMSID mms_id x.TO to x.FALLBACKSMSTEXT fallbacksmstext x.OPERATORID(operator_id) if operator_id x.FROM from x.CUSTOMSUBJECT(subject) if subject if content x.CUSTOMTEXT { x.VALUE content x.SLIDE 1 } end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_saved_mms(to, mms_id, fallback_text, options={})\n operator_id = options[:operator_id]\n subject = options[:subject]\n content = options[:content]\n do_request builder.build_send_saved_mms(@shortcode, to, mms_id, fallback_text,\n operator_id, subject,...
[ "0.67924803", "0.5563968", "0.55501753", "0.5491202", "0.5488196", "0.54737896", "0.54700184", "0.54636914", "0.54561436", "0.5352455", "0.5352455", "0.53460187", "0.53324324", "0.5330045", "0.532578", "0.532541", "0.531131", "0.531131", "0.5273244", "0.5262171", "0.52585995"...
0.6148387
1
GET /links/1 GET /links/1.json
def link_through @link.increment_uses! redirect_to(@link.url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: @links\n end", "def index\n links = all_links\n render json: { success: true, links: links }\n end", "def index\n @links = Link.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @links }\n end\n end", "def sho...
[ "0.7350112", "0.7120274", "0.7025738", "0.6990482", "0.69635993", "0.6938119", "0.6838034", "0.6833723", "0.6815706", "0.68135786", "0.6781963", "0.6781963", "0.6624377", "0.65752435", "0.6487915", "0.6386929", "0.6386929", "0.6386929", "0.6386929", "0.6386929", "0.6386929", ...
0.0
-1
POST /links POST /links.json
def create @link = Link.new(link_params) respond_to do |format| if @link.save format.html { redirect_to edit_link_url(@link), notice: 'Link was successfully created.' } format.json { render :edit, status: :created, location: edit_link_url(@link) } else format.html { render :new } format.json { render json: @link.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if @link.save\n render json: @link, status: :created, location: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end", "def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n ...
[ "0.7279239", "0.7042173", "0.6892667", "0.6849184", "0.67824477", "0.67146206", "0.6708206", "0.66861737", "0.66628766", "0.66427463", "0.66249496", "0.65540344", "0.64941686", "0.6478123", "0.6459337", "0.64366543", "0.64365256", "0.6423571", "0.64210635", "0.6417331", "0.63...
0.6506658
12
DELETE /links/1 DELETE /links/1.json
def expire @link.expire! respond_to do |format| format.html { redirect_to root_url, notice: 'Link was successfully expired.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.json { head :ok }\n end\n end", "def destroy\n @link = Link.find(params[:id])\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format....
[ "0.75310004", "0.74690264", "0.74529105", "0.74529105", "0.74529105", "0.73705393", "0.73705393", "0.73637277", "0.7292658", "0.7263792", "0.7260787", "0.72489226", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_link @link = Link.find_by(slug: params[:slug]) if bad_link? raise ActionController::RoutingError.new('Not Found') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def link_params params.require(:link).permit(:url) 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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_party @party = Party.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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def party_params params.require(:party).permit(:name, candidates_attributes: [:first_name, :last_name, :party_id], elections_attributes: [:state_id, :candidate_id, :party_id, :percent, :regs, :supers, :updated_at], state_attributes: [:name, :p_or_c, :dem_date, :gop_date]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Draw Actor's Current Equipment and Parameters
def draw_actor_parameter_change(actor, x, y) return if @item.is_a?(RPG::Item) enabled = actor.equippable?(@item) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x, y, 200, WLH, actor.name) if @item.is_a?(RPG::Weapon) item1 = weaker_weapon(actor) elsif actor.two_swords_style and @item.kind == 0 item1 = nil else item1 = actor.equips[1 + @item.kind] end if enabled if @item.is_a?(RPG::Weapon) atk1 = item1 == nil ? 0 : item1.atk atk2 = @item == nil ? 0 : @item.atk change = atk2 - atk1 else def1 = item1 == nil ? 0 : item1.def def2 = @item == nil ? 0 : @item.def change = def2 - def1 end if change > 0 # If increase status elsif change < 0 # If decrease status self.contents.font.color.alpha = 128 else # if not change status self.contents.font.color.alpha = 128 end self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_actor_equip_info(x, y, actor)\n if !actor.equippable?(@item)\n draw_icon(UNEQUIPPABLE_ICON_INDEX, x, y)\n elsif actor.equipped?(@item)\n draw_icon(EQUIPPED_ICON_INDEX, x, y)\n else\n old_stat = actor.param(param_id)\n new_stat = get_new_stat(actor)\n if old_stat < new_sta...
[ "0.72518516", "0.6877727", "0.6722774", "0.6689965", "0.6651183", "0.652726", "0.6495308", "0.6403955", "0.6318245", "0.6308162", "0.62909675", "0.6245975", "0.6184896", "0.6139024", "0.60752505", "0.6037921", "0.60336846", "0.6028193", "0.60168886", "0.6004937", "0.59816957"...
0.65947956
5
Style/ZeroLengthPredicate: Description: 'Use empty? when testing for objects of length 0.' Enabled: true Safe: false VersionAdded: '0.37' VersionChanged: '0.39'
def all_cops @all_cops ||= `#{options[:cmd]} --show-cops --force-default-config`.lines.select { |l| l.match(/^\w/) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty()\n \n end", "def empty?\n `self.length === 0`\n end", "def empty?\n @length == 0\n end", "def empty?\n `return self.length == 0 ? Qtrue : Qfalse;`\n end", "def empty?\n `return self.length == 0 ? Qtrue : Qfalse;`\n end", "def empty?\n self.length == 0\n end", ...
[ "0.68812793", "0.66780996", "0.6619045", "0.65940386", "0.65940386", "0.6578923", "0.65752167", "0.655625", "0.6500957", "0.6500957", "0.6500957", "0.6500957", "0.647684", "0.64714545", "0.6470014", "0.6448993", "0.6382468", "0.6382468", "0.6363346", "0.6340658", "0.6333268",...
0.0
-1
this will take two parameters call the first parament first_number and the second second_number use the return keyword invoke the function add(2, 3)
def add(first_number, second_number) return first_number + second_number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add (first_number , second_number)\n return first_number + second_number\nend", "def add( first_number, second_number )\n return first_number + second_number\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def add(first_number, second_number)\n return fir...
[ "0.8311812", "0.8126601", "0.8116768", "0.8110892", "0.789023", "0.7620656", "0.76157457", "0.7595512", "0.7511536", "0.7506176", "0.7501186", "0.74888575", "0.74874854", "0.74841255", "0.74650687", "0.74436486", "0.74436486", "0.74436486", "0.74436486", "0.7426183", "0.74194...
0.8116551
5
2. Create a population_density function this will take two parameters call the first parameter population and the second area calculate the population dencsity invoke the function using the population and area of Mauritus: population = 5373000 area = 77933
def population_density(population, area) return population / area end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def population_density(population,area)\n return population/area\nend", "def pop_density(population, area)\n return population/area\nend", "def density(population, area)\nreturn population/area\nend", "def population_density; end", "def calc_density(percent)\n (@population * percent).floor\n\n end", ...
[ "0.8557744", "0.8448417", "0.82101345", "0.7941175", "0.71072197", "0.69958514", "0.66791564", "0.6655806", "0.6654687", "0.65963125", "0.6426667", "0.641325", "0.6411375", "0.63754517", "0.6300871", "0.6293564", "0.6279479", "0.6276193", "0.6249926", "0.62451583", "0.6243774...
0.8607622
0
Read the options from the config file. cfg_file is the default config file. If local_cfg_file exists, the options specified there overrides those in cfg_file. If :config_file is specified, it is used in place of local_cfg_file. If :environment is specified, the options in the corresponding environment is loaded and merged with those in 'default'.
def read_options args={}, update_options={} args = {:environment => nil, :config_file => nil, :verbose => 'silent' }.update(args) options = {} if File.exists? @cfg_file vputs "Loading '#{@cfg_file}'", args[:verbose] options = load_file @cfg_file end if args[:config_file] if !File.exists? args[:config_file] vputs "ERROR: Config file '#{args[:config_file]}' not found!", args[:verbose] exit end vputs "Loading '#{args[:config_file]}'", args[:verbose] update_options(args[:config_file], options) elsif @persistent_local_cfg_file && File.exists?(@persistent_local_cfg_file) vputs "Loading '#{@persistent_local_cfg_file}'", args[:verbose] update_options(@persistent_local_cfg_file, options) elsif @local_cfg_file && File.exists?(@local_cfg_file) vputs "Loading '#{@local_cfg_file}'", args[:verbose] update_options(@local_cfg_file, options) end if args[:environment] vputs "Using environment '#{args[:environment]}'", args[:verbose] options = (options['default']||{}).deep_merge!(options[args[:environment]]||{}) end options.update(update_options) options['environment'] = 'development' if options['environment'].nil? options['verbose'] = false if options['verbose'].nil? if args[:verbose] == true len = options.keys.map { |k| k.size }.sort.last vputs "Loaded options:", args[:verbose] options.each { |k, v| puts " #{k.ljust(len)} => #{v}" } end options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_opts(file_path=nil)\n begin\n default_opts.merge!(\n deep_symbolize(YAML.load_file(file_path || config_file_path))[environment.to_sym])\n rescue Errno::ENOENT => e\n p \"[warning] config file not read, using default options\"\n default_opts\n end\n end", "...
[ "0.7672195", "0.6985589", "0.6737311", "0.6601434", "0.6513327", "0.63935447", "0.6361566", "0.6260328", "0.6207645", "0.61617625", "0.61595476", "0.61593837", "0.6149265", "0.6102959", "0.6041439", "0.60373455", "0.6022779", "0.6014515", "0.5992297", "0.59893703", "0.5977371...
0.7238134
1
Allows retrieval of option value (i.e. options.option_name) that matches the key name in the config file.
def method_missing method_name, *arg if method_name.to_s =~ /(.*)=$/ key = $1 if @options.has_key? key @options[key] = arg[0] return @options[key] end else key = method_name.to_s if @options.has_key? key return @options[key] end end raise NoMethodError.new("undefined method `#{key}' for Options:Class", "unknown_key") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def [](key_name)\n return @options[key_name.to_s()]\n end", "def retrieve_option(name)\n if options['user-data']\n retrieve_from_userdata(name, options['user-data-type'], options['user-data-source'])\n else\n options[name] || name\n end\n end", "def option(key)\n op...
[ "0.736649", "0.71383786", "0.7067204", "0.7043778", "0.7034749", "0.70125884", "0.70088816", "0.6915307", "0.6909973", "0.6891488", "0.6863003", "0.6845746", "0.68118644", "0.6750573", "0.67394364", "0.6737242", "0.67233855", "0.6683743", "0.665308", "0.6640629", "0.657425", ...
0.0
-1
Merge options with content of .
def update_options file, options options.deep_merge!(load_file(file)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options(opts)\n opts.each { |k,v| merge_options(k, v) }\n end", "def options!(**opts)\n options.merge!(opts)\n end", "def options(opt); end", "def options(opt); end", "def merged_options\n subset.merge(@options)\n end", "def merge(opts); end", "def options(value)\n ...
[ "0.67452043", "0.67216426", "0.65879756", "0.658691", "0.65771794", "0.6558387", "0.6550461", "0.65314585", "0.6531365", "0.64406455", "0.6439268", "0.6433802", "0.6432807", "0.6430744", "0.6430744", "0.63969755", "0.639092", "0.63805443", "0.63134456", "0.63007855", "0.62998...
0.61821216
34
list tweets from user one follows
def index @following_user_ids = @user.following.pluck(:id) @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user) json_response(@tweets) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users yo...
[ "0.7486539", "0.7172651", "0.7087626", "0.7067915", "0.70504427", "0.69788396", "0.6975338", "0.6959728", "0.6959313", "0.6949565", "0.6932882", "0.6932882", "0.6932882", "0.6932882", "0.6932882", "0.6932882", "0.6932882", "0.6932882", "0.6932168", "0.6929759", "0.6929392", ...
0.7318694
1
get user for listing tweets
def set_user @user ||= User.find(params[:user_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n []\n end\nend", "def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n [] # \"magic\" return value\n end\nend", "def user_tweets(user_id)\n twitter.user_timeline(user_id)\n end", "def index\n\t\t...
[ "0.7795582", "0.7550091", "0.73972666", "0.735464", "0.7301642", "0.72319263", "0.72235614", "0.7211359", "0.71847755", "0.7086747", "0.70566463", "0.70436853", "0.7030025", "0.6992378", "0.6982317", "0.6956708", "0.69545305", "0.6905479", "0.68983746", "0.6898069", "0.689741...
0.0
-1
GET /users GET /users.json
def index @recipes = Recipe.all @recipe = Recipe.new @user = User.find_by_id(current_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n para...
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.73...
0.0
-1
GET /users/1 GET /users/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.8104698", "0.7702126", "0.77007926", "0.762504", "0.75819093", "0.7480423", "0.7460564", "0.7446216", "0.73049676", "0.729887", "0.7288292", "0.72757125", "0.7234221", "0.7232001", "0.7232001", "0.7232001", "0.7232001", "0.7232001", "0.7232001", "0.7232001", "0.72237396", ...
0.0
-1
POST /users POST /users.json
def create @user = User.new(user_params) respond_to do |format| if @user.save format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render :show, status: :created, location: @user } else format.html { render :new } format.json { render json: @user.errors, status: :unprocessable_entity } end 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.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update respond_to do |format| if @user.update(user_params) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { render :show, status: :ok, location: @user } else format.html { render :edit } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.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", "de...
[ "0.7225089", "0.71287596", "0.70036054", "0.6903269", "0.68219566", "0.68156385", "0.67085004", "0.66934854", "0.6681138", "0.66734326", "0.6672101", "0.6664205", "0.6664205", "0.6659583", "0.6659583", "0.6655003", "0.6648765", "0.66436005", "0.66416174", "0.6635357", "0.6618...
0.0
-1
Note: nil will be sorted towards the bottom (regardless if :asc or :desc)
def multi_sort(items, order) items.sort do |this, that| order.reduce(0) do |diff, order| next diff if diff != 0 # this and that have differed at an earlier order entry key, direction = order # deal with nil cases next 0 if this[key].nil? && that[key].nil? next 1 if this[key].nil? next -1 if that[key].nil? # do the actual comparison comparison = this[key] <=> that[key] next comparison * DIRECTION_MULTIPLIER[direction] end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_order\n 0\n end", "def sort_by_default\n 1\n end", "def default_sort\n { order: :created_at, direction: :desc }\n end", "def sort_entries; end", "def top_sort\n top_sort_visit([]).reverse\n end", "def default_sort\n 'created_at desc'\n end", "def sort\n @pokers.sort....
[ "0.7182477", "0.69713306", "0.6895104", "0.68552786", "0.68443185", "0.665728", "0.665405", "0.66044647", "0.66025746", "0.66017675", "0.6593381", "0.6593381", "0.6576955", "0.65521145", "0.6442761", "0.6430678", "0.6414082", "0.63694495", "0.63615197", "0.6330332", "0.630760...
0.0
-1
consider the proper place for this method
def cart_subtotal order = current_order ? current_order : new_order_from_cookies order.order_items.each { |item| item.send(:update_price)} order.send(:update_subtotal) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def schubert; end", "def private_method\n end", "def probers; end", "def processor; end", "def handle; end", "def refutal()\n end", "def strategy; end", "def perform\n \n end", "def suivre; end", "def ...
[ "0.7452824", "0.6688556", "0.6688556", "0.6441768", "0.6371735", "0.63154984", "0.6306325", "0.6253394", "0.62205243", "0.62201875", "0.6213839", "0.6163872", "0.6161386", "0.6092756", "0.6092756", "0.60511005", "0.6025914", "0.598507", "0.5977933", "0.5977933", "0.5977933", ...
0.0
-1
consider the proper place for this method
def cart_total_quantity order = current_order ? current_order : new_order_from_cookies order.order_items.collect { |item| item.quantity }.sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def schubert; end", "def private_method\n end", "def probers; end", "def processor; end", "def handle; end", "def refutal()\n end", "def strategy; end", "def perform\n \n end", "def suivre; end", "def ...
[ "0.7452824", "0.6688556", "0.6688556", "0.6441768", "0.6371735", "0.63154984", "0.6306325", "0.6253394", "0.62205243", "0.62201875", "0.6213839", "0.6163872", "0.6161386", "0.6092756", "0.6092756", "0.60511005", "0.6025914", "0.598507", "0.5977933", "0.5977933", "0.5977933", ...
0.0
-1
consider the proper place for this method
def new_order_from_cookies order = Order.new order.order_items = read_from_cookies order end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def schubert; end", "def private_method\n end", "def probers; end", "def processor; end", "def handle; end", "def refutal()\n end", "def strategy; end", "def perform\n \n end", "def suivre; end", "def ...
[ "0.7452824", "0.6688556", "0.6688556", "0.6441768", "0.6371735", "0.63154984", "0.6306325", "0.6253394", "0.62205243", "0.62201875", "0.6213839", "0.6163872", "0.6161386", "0.6092756", "0.6092756", "0.60511005", "0.6025914", "0.598507", "0.5977933", "0.5977933", "0.5977933", ...
0.0
-1
For simplicity we are using id as the short url, we can change this field to be a randomly generated string
def create_short_url if self.short_url.nil? self.short_url = self.id self.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_short_url\n # encode base 10 id as base 62 string as seen here https://gist.github.com/zumbojo/1073996\n i = id\n return Constants::ALPHABET[0] if i.zero?\n s = ''\n base = Constants::ALPHABET.length\n while i > 0\n s << Constants::ALPHABET[i.modulo(base)]\n ...
[ "0.82112753", "0.79606307", "0.7811464", "0.75999683", "0.758209", "0.75525725", "0.75509703", "0.7527498", "0.7527498", "0.75138426", "0.74889225", "0.7484784", "0.7453364", "0.7287543", "0.7254317", "0.7253613", "0.7246158", "0.7191457", "0.715653", "0.70685923", "0.706089"...
0.70386934
21
Delete Type By Id
def service_boards_id_types_type_id_delete(id, type_id, opts = {}) service_boards_id_types_type_id_delete_with_http_info(id, type_id, opts) return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_by_type_and_id(type, id)\n delete(resource_path_for_entity_type(type) + \"/#{id}\")\n end", "def delete(session, id)\n write_task('rvpe.vmtype.delete', session, true) do\n type = VMType.find_by_id(id)[0]\n raise \"VMType[#{id}] does not exist.\" unless type\n\n ty...
[ "0.8097651", "0.74415386", "0.74363726", "0.70715237", "0.70297086", "0.7014583", "0.70071304", "0.6967145", "0.6966397", "0.69492763", "0.69393307", "0.69179356", "0.68902063", "0.68707925", "0.68624777", "0.68348175", "0.6814171", "0.6781141", "0.6779629", "0.6778306", "0.6...
0.0
-1
Delete Type By Id
def service_boards_id_types_type_id_delete_with_http_info(id, type_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: BoardTypesApi.service_boards_id_types_type_id_delete ..." end # verify the required parameter 'id' is set fail ArgumentError, "Missing the required parameter 'id' when calling BoardTypesApi.service_boards_id_types_type_id_delete" if id.nil? # verify the required parameter 'type_id' is set fail ArgumentError, "Missing the required parameter 'type_id' when calling BoardTypesApi.service_boards_id_types_type_id_delete" if type_id.nil? # resource path local_var_path = "/service/boards/{id}/types/{typeId}".sub('{format}','json').sub('{' + 'id' + '}', id.to_s).sub('{' + 'typeId' + '}', type_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) local_header_accept = [] local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' local_header_content_type = [] header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['BasicAuth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardTypesApi#service_boards_id_types_type_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_by_type_and_id(type, id)\n delete(resource_path_for_entity_type(type) + \"/#{id}\")\n end", "def delete(session, id)\n write_task('rvpe.vmtype.delete', session, true) do\n type = VMType.find_by_id(id)[0]\n raise \"VMType[#{id}] does not exist.\" unless type\n\n ty...
[ "0.8097651", "0.74415386", "0.74363726", "0.70715237", "0.70297086", "0.7014583", "0.70071304", "0.6967145", "0.6966397", "0.69492763", "0.69393307", "0.69179356", "0.68902063", "0.68707925", "0.68624777", "0.68348175", "0.6814171", "0.6781141", "0.6779629", "0.6778306", "0.6...
0.0
-1
Get Type By Id
def service_boards_id_types_type_id_get(id, type_id, opts = {}) data, _status_code, _headers = service_boards_id_types_type_id_get_with_http_info(id, type_id, opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(id)\n response = RestClient.get(\"#{@type.Resource}/#{id}\")\n @type.from_json response['data']\n end", "def by_type(id)\n DB_TYPE[id]\n end", "def lookup(type_name, id)\n return unless type_name.starts_with?(namespace)\n types.each_pair do |type, graph_t...
[ "0.79167455", "0.78973544", "0.75973237", "0.71819276", "0.7163599", "0.70293283", "0.69477385", "0.68388855", "0.68154734", "0.67969507", "0.6791716", "0.67583597", "0.67583597", "0.67434543", "0.6665519", "0.6649719", "0.6611705", "0.6539581", "0.65192264", "0.6457479", "0....
0.0
-1
Get Type By Id
def service_boards_id_types_type_id_get_with_http_info(id, type_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: BoardTypesApi.service_boards_id_types_type_id_get ..." end # verify the required parameter 'id' is set fail ArgumentError, "Missing the required parameter 'id' when calling BoardTypesApi.service_boards_id_types_type_id_get" if id.nil? # verify the required parameter 'type_id' is set fail ArgumentError, "Missing the required parameter 'type_id' when calling BoardTypesApi.service_boards_id_types_type_id_get" if type_id.nil? # resource path local_var_path = "/service/boards/{id}/types/{typeId}".sub('{format}','json').sub('{' + 'id' + '}', id.to_s).sub('{' + 'typeId' + '}', type_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) local_header_accept = ['application/json'] local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' local_header_content_type = [] header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['BasicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Type') if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardTypesApi#service_boards_id_types_type_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(id)\n response = RestClient.get(\"#{@type.Resource}/#{id}\")\n @type.from_json response['data']\n end", "def by_type(id)\n DB_TYPE[id]\n end", "def lookup(type_name, id)\n return unless type_name.starts_with?(namespace)\n types.each_pair do |type, graph_t...
[ "0.79167455", "0.78973544", "0.75973237", "0.71819276", "0.7163599", "0.70293283", "0.69477385", "0.68388855", "0.68154734", "0.67969507", "0.6791716", "0.67583597", "0.67583597", "0.67434543", "0.6665519", "0.6649719", "0.6611705", "0.6539581", "0.65192264", "0.6457479", "0....
0.0
-1
Get Sub Type Association
def service_boards_id_types_type_id_sub_type_association_get(id, type_id, opts = {}) data, _status_code, _headers = service_boards_id_types_type_id_sub_type_association_get_with_http_info(id, type_id, opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subtype\n return nil if @values[:subtype].nil?\n self.class.subtype @values[:subtype].to_sym\n end", "def sub_type\n @sub_type || parse_and_return(:@sub_type)\n end", "def association\n @association\n end", "def subclass_assoc_name\n if type_name = send(self.type_...
[ "0.6484568", "0.6394323", "0.6164243", "0.6147553", "0.6118972", "0.6117649", "0.6053121", "0.6035347", "0.59918433", "0.5961737", "0.5956942", "0.5917647", "0.5881999", "0.5843298", "0.57926935", "0.5752598", "0.5751529", "0.5750728", "0.56585574", "0.5614666", "0.56040275",...
0.0
-1
Get Sub Type Association
def service_boards_id_types_type_id_sub_type_association_get_with_http_info(id, type_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: BoardTypesApi.service_boards_id_types_type_id_sub_type_association_get ..." end # verify the required parameter 'id' is set fail ArgumentError, "Missing the required parameter 'id' when calling BoardTypesApi.service_boards_id_types_type_id_sub_type_association_get" if id.nil? # verify the required parameter 'type_id' is set fail ArgumentError, "Missing the required parameter 'type_id' when calling BoardTypesApi.service_boards_id_types_type_id_sub_type_association_get" if type_id.nil? # resource path local_var_path = "/service/boards/{id}/types/{typeId}/subTypeAssociation".sub('{format}','json').sub('{' + 'id' + '}', id.to_s).sub('{' + 'typeId' + '}', type_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) local_header_accept = ['application/json'] local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' local_header_content_type = [] header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['BasicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Integer') if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardTypesApi#service_boards_id_types_type_id_sub_type_association_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subtype\n return nil if @values[:subtype].nil?\n self.class.subtype @values[:subtype].to_sym\n end", "def sub_type\n @sub_type || parse_and_return(:@sub_type)\n end", "def association\n @association\n end", "def subclass_assoc_name\n if type_name = send(self.type_...
[ "0.6484568", "0.6394323", "0.6164243", "0.6147553", "0.6118972", "0.6117649", "0.6053121", "0.6035347", "0.59918433", "0.5961737", "0.5956942", "0.5917647", "0.5881999", "0.5843298", "0.57926935", "0.5752598", "0.5751529", "0.5750728", "0.56585574", "0.5614666", "0.56040275",...
0.0
-1
GET /api/v1/followers GET /api/v1/followers.json
def index head 404 # @api_v1_followers = Api::V1::Follower.all # render json: @api_v1_followers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_followers\n HTTParty.post(\"#{@api_path}/users/followers/#{@handle}/#{@password}\")\n end", "def followers\n begin\n @followers = current_user.twitter.get(\"/statuses/followers?page=#{params[:page] || 1}\")\n rescue TwitterAuth::Dispatcher::Error\n @followers = []\n end\n\n ...
[ "0.83787376", "0.8377479", "0.83689487", "0.827333", "0.80514", "0.7906128", "0.79016715", "0.78946525", "0.788456", "0.7873392", "0.7834916", "0.7830415", "0.78069794", "0.7794262", "0.7793506", "0.775343", "0.7738676", "0.7709325", "0.7659209", "0.76468205", "0.7634979", ...
0.7677996
18
GET /api/v1/followers/1 GET /api/v1/followers/1.json
def show user = Api::V1::User.find(params[:id]) unless user.nil? render json: user.followings.all end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follower\n @users = User.find(params[:id]).followers\n render json: @users\n end", "def get_followers\n HTTParty.post(\"#{@api_path}/users/followers/#{@handle}/#{@password}\")\n end", "def followers\n begin\n @followers = current_user.twitter.get(\"/statuses/followers?page=#{params[:...
[ "0.8193586", "0.8054325", "0.80440086", "0.7956711", "0.7843377", "0.78206664", "0.76897913", "0.7659652", "0.7653935", "0.7648591", "0.7643746", "0.7638499", "0.7576578", "0.75579256", "0.7523056", "0.7499779", "0.74944425", "0.74871284", "0.74830264", "0.748165", "0.7470403...
0.74394244
24
POST /api/v1/followers POST /api/v1/followers.json
def create follow_exists = Api::V1::Follower.where('follower_id =? and user_id =?', @current_user.id, params[:user_id]).first if follow_exists.nil? # Follower doesn't exists @api_v1_follower = Api::V1::Follower.new(api_v1_follower_params) @api_v1_follower.follower_id = @current_user.id @api_v1_follower.user_id = params[:user_id] if @api_v1_follower.save # create new notification notification = Api::V1::Notification.new notification.user_id = @api_v1_follower.user_id notification.event_type = Api::V1::Notification::TYPE_NEW_FOLLOWER notification.content = { :event_user_id => @current_user.id, :event_user_name => @current_user.first_name + ' ' + @current_user.last_name, :event_user_avatar => @current_user.formated_avatar }.to_json notification.event_object_id = @api_v1_follower.user_id notification.save render json: @api_v1_follower, status: :created, location: @api_v1_follower else render json: @api_v1_follower.errors, status: :unprocessable_entity end else render json: { error: 'already following' }, status: 401 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @user=User.find(params[:user_id])\n @follower = @user.followers.create(follower_params)\n if @follower.save\n render json: @follower, status: :created\n else\n render json: @follower.errors, status: :unprocessable_entity\n end\n end", "def get_followers\n HTTParty.post...
[ "0.77887774", "0.74616194", "0.7369939", "0.7294781", "0.711071", "0.7103522", "0.70984364", "0.70471436", "0.701086", "0.69519913", "0.6939163", "0.6912909", "0.68772656", "0.6850885", "0.68160295", "0.67895234", "0.67845535", "0.6772142", "0.67566246", "0.67562735", "0.6751...
0.64795715
57
PATCH/PUT /api/v1/followers/1 PATCH/PUT /api/v1/followers/1.json
def update head 404 # @api_v1_follower = Api::V1::Follower.find(params[:id]) # if @api_v1_follower.update(api_v1_follower_params) # head :no_content # else # render json: @api_v1_follower.errors, status: :unprocessable_entity # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @follower.update(follower_params)\n head :no_content\n else\n render json: @follower.errors, status: :unprocessable_entity\n end\n end", "def update_followers *args\n options = args.extract_options!\n UserFollowersCollect.perform user: self, options: options\n end", "...
[ "0.69468665", "0.6869916", "0.68608594", "0.68559045", "0.653335", "0.65204394", "0.6452869", "0.6432579", "0.6416491", "0.6343508", "0.6268268", "0.6254943", "0.62230366", "0.62230366", "0.62182444", "0.6212376", "0.61784023", "0.6177524", "0.61666095", "0.6159654", "0.61157...
0.7654998
0
DELETE /api/v1/followers/1 DELETE /api/v1/followers/1.json
def destroy @api_v1_follower = Api::V1::Follower.where('follower_id =? and user_id =?', @current_user.id, params[:id]).first if @api_v1_follower.destroy head :no_content else render json: { error: 'not allowed' }, status: 401 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n head 404\n # @api_v1_following = Api::V1::Follower.where('following_id =? and user_id =?', @current_user.id, params[:id]).first\n # if @api_v1_following.destroy\n # head :no_content\n # else \n # render json: { error: 'not allowed' }, status: 401\n # end\n end", "def dest...
[ "0.8107075", "0.7648032", "0.7645662", "0.76407444", "0.75544685", "0.75002396", "0.7424155", "0.7384159", "0.73713124", "0.7350932", "0.7291361", "0.72784495", "0.7275318", "0.7235957", "0.7202853", "0.7191051", "0.71871114", "0.718419", "0.7098072", "0.7098072", "0.7092212"...
0.8155492
0
GET /contacts GET /contacts.json
def index @contacts = current_user.contacts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end", "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Ent...
[ "0.80651945", "0.7942857", "0.78436047", "0.7802116", "0.77277195", "0.76782286", "0.7592066", "0.74919254", "0.7467012", "0.73504406", "0.7329629", "0.73074734", "0.71978635", "0.71872765", "0.71866214", "0.7176661", "0.7168481", "0.71074116", "0.71074116", "0.7098688", "0.7...
0.6784987
59
GET /contacts/1 GET /contacts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @contact = Contact.find(params[:id])\n\n render json: @contact\n end", "def index\n @contacts = Contact.all\n render json: @contacts\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n en...
[ "0.7592076", "0.7569956", "0.75495976", "0.7539084", "0.74656665", "0.7330573", "0.7311667", "0.7311667", "0.7311667", "0.7286782", "0.7257982", "0.7174953", "0.71124715", "0.7112357", "0.71117723", "0.7109009", "0.7109009", "0.7105762", "0.7093646", "0.7065573", "0.70368207"...
0.0
-1
POST /contacts POST /contacts.json
def create @contact = Contact.new(contact_params) @contact.user_id = current_user.id respond_to do |format| if @contact.save format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' } format.json { render :show, status: :created, location: @contact } else format.html { render :new } format.json { render json: @contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end", "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def ...
[ "0.75767535", "0.7489912", "0.73792636", "0.72857213", "0.71954143", "0.7163311", "0.71241444", "0.70903546", "0.7083217", "0.7067553", "0.7018867", "0.7013148", "0.6966274", "0.69249797", "0.69042265", "0.6890879", "0.68734777", "0.686979", "0.6859895", "0.6859895", "0.68598...
0.65764964
41
PATCH/PUT /contacts/1 PATCH/PUT /contacts/1.json
def update respond_to do |format| if @contact.update(contact_params) format.html { redirect_to contacts_path, notice: 'Contact was successfully updated.' } format.json { render :show, status: :ok, location: @contact } else format.html { render :edit } format.json { render json: @contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end", "def update\n if @contact.update(contact_params)\n fresh_when(@contact)\n render json: @contact, status: :ok, location: @contact\n else\n render json: { errors: @contact.err...
[ "0.70585597", "0.6981436", "0.6936487", "0.69234896", "0.6881166", "0.6825044", "0.6790831", "0.6788466", "0.67777395", "0.6750384", "0.6750384", "0.6750384", "0.6717664", "0.6675204", "0.6673585", "0.66734314", "0.66554683", "0.6621908", "0.6594704", "0.65783536", "0.6568851...
0.6619594
18
DELETE /contacts/1 DELETE /contacts/1.json
def destroy @contact.destroy respond_to do |format| format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contact.destroy\n render json: {status: 204}\n end", "def delete(contactname)\n\n end", "def destroy\n @contact.destroy\n #Contact.delete(@contact.id)\n respond_to do |format|\n format.html { redirect_to contacts_path }\n format.json { head :no_content }\n end\n en...
[ "0.7692505", "0.7681699", "0.76096106", "0.75637853", "0.75455976", "0.75426126", "0.75426126", "0.75426126", "0.75274014", "0.75274014", "0.75274014", "0.75274014", "0.7427848", "0.74231184", "0.74073875", "0.739963", "0.7388033", "0.73524195", "0.7331634", "0.7321653", "0.7...
0.72476834
51
POST /contacts/1/call POST /contacts/1/call.json
def call puts "!!!!!!!!!!!!!!!!" respond_to do |format| @contact.call if @contact.save format.html { redirect_to contacts_path, notice: 'Contact was successfully called.' } format.json { render :show, status: :ok, location: @contact } else format.html { render :edit } format.json { render json: @contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @call = Call.new(params[:call])\n \n respond_to do |format|\n if @call.save\n \n result = OutgoingCallerId.find(:last)\n twcall = @twilio_client.account.calls.create(\n from: result.phone_number,\n to: @call.to, \n url: \"#{url_for(@call)}/...
[ "0.71793747", "0.7038815", "0.6991744", "0.6948673", "0.6815599", "0.67360896", "0.6686091", "0.66618145", "0.66128457", "0.6503975", "0.6496445", "0.6490749", "0.6479721", "0.64737713", "0.6467043", "0.6460369", "0.6457435", "0.6452084", "0.6449614", "0.6429503", "0.6416282"...
0.72335863
0
Use callbacks to share common setup or constraints between actions.
def set_contact @contact = Contact.find_by_id(params[:id]) raise ActionController::RoutingError.new('Not Found') unless @contact if not @contact render(:file => File.join(Rails.root, 'public/404.html'), :status => 404, :layout => false) elsif @contact.user != current_user render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def contact_params params.require(:contact).permit(:name, :phone, :email) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Public: Returns the raw response data Returns Hash
def to_h @data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data\n @raw_response.body\n end", "def response_data\n @_response_data ||= Hash.new.with_indifferent_access\n end", "def raw_response\n @raw_response\n end", "def response_data\n unless response.media_type.to_s =~ /^application\\/(.+)/\n raise \"Unexpected resp...
[ "0.7514405", "0.72159284", "0.7153388", "0.71448207", "0.70950055", "0.700044", "0.6839473", "0.6782568", "0.6745546", "0.6720848", "0.6707519", "0.66759986", "0.66521406", "0.66437745", "0.6631601", "0.66300166", "0.6609873", "0.65930575", "0.65802044", "0.6574132", "0.64880...
0.6328092
29
This is the LC Control Panel
def draft_preview @league = League.find_by_id(params[:id]) # # This is to update the :contestant_pool attribute for the draft # @hash = {} # @contestants = Contestant.all # @contestants.each do |x| # @hash.merge!(x.name => x.survive) # end # @hash = @hash.delete_if{|key, value| value == false} # @league.update_attributes(:contestant_pool => @hash) @users = @league.users @user = current_user @ncontestants = @league.contestant_pool.length @nusers = @users.count @nrounds = @league.teamsize @narray = @nusers * @nrounds # This is how we will set up the array that basically is the draft pick-list and assign it to the league's :draft_order attribute. @pick_list = [] for i in 1..@nrounds if i.odd? @array = @users.shuffle n = @array.length for i in 0...n @pick_list << @array[i] end else index = @pick_list.length - 1 for n in 0...@nusers @pick_list << @pick_list[index-n] end end end @draft_order = [] @pick_list.each do |x| @draft_order << x.username end @league.update_attributes(:draft_order => @draft_order) # This is just used to redirect people if they try to access this page and they aren't the lc for this league. if @user == nil redirect_to log_in_path else unless @user.lc == true && @user.league_id == params[:id].to_i # unless @user.league_id == @id redirect_to user_path(@user) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_status_controls\n @control_help_window.add_control(Vocab::MODIFY, Input::Keys::A) \n @control_help_window.add_control(Vocab::BACK, Input::Keys::B)\n @control_help_window.add_control(Vocab::CHANGE_ACTOR, Input::Keys::L, Input::Keys::R)\n end", "def set_status_controls\n @control...
[ "0.6285162", "0.6284582", "0.61502844", "0.612305", "0.60499686", "0.6008037", "0.59655815", "0.5949858", "0.58819056", "0.5821607", "0.5809796", "0.57785624", "0.5755065", "0.5722106", "0.5667611", "0.5658426", "0.5627632", "0.56064534", "0.5591983", "0.5585895", "0.5571336"...
0.0
-1
Instantiate a new Etherpad Lite Client. You may pass a full url or just a port number. The api key may be a string or a File object. If you do not specify an API version, it will default to the latest version.
def initialize(url_or_port, api_key_or_file, api_version=nil) url_or_port = "http://localhost:#{url_or_port}" if url_or_port.is_a? Integer @uri = URI.parse(url_or_port) @api_key = api_key_or_file.is_a?(IO) ? api_key_or_file.read : api_key_or_file @api_version = api_version ? api_version.to_s : current_api_version.to_s @ssl_verify = OpenSSL::SSL::VERIFY_PEER end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(api_key, url='http://localhost:9001/api')\n @uri = URI.parse(url)\n raise ArgumentError, \"#{url} is not a valid url\" unless @uri.host and @uri.port\n @api_key = api_key\n connect!\n end", "def initialize(api_key:, read_timeout: 60, open_timeout: 30, api_base: 'https://api....
[ "0.6559601", "0.64430875", "0.6420582", "0.62729454", "0.61267424", "0.6081212", "0.60260683", "0.60042477", "0.59996283", "0.5980371", "0.59723735", "0.5955311", "0.594817", "0.5944447", "0.5939122", "0.5903424", "0.5879142", "0.582383", "0.5815118", "0.5812349", "0.58057016...
0.6603005
0
Whether peer must be verified if the API URL is SSL
def ssl_verify(mode) @ssl_verify = mode end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ssl_required?\r\n true\r\n end", "def verify_ssl\n true\n end", "def ssl?\n @api_scheme == 'https'\n end", "def ssl_required?\n HTTPS_ON\n end", "def ssl_required?\n true\n end", "def ssl?\n @url.scheme == 'https'\n end", "def ssl?\n uri_endpoint.sch...
[ "0.81372917", "0.8111334", "0.8074013", "0.8048578", "0.80364555", "0.7910751", "0.7871547", "0.7865919", "0.7835425", "0.78283054", "0.78283054", "0.78161305", "0.78161305", "0.7789531", "0.7789531", "0.777676", "0.77597445", "0.7745489", "0.77454525", "0.7727207", "0.772638...
0.6758983
95
Call an API method
def method_missing(method, params={}) call(method, params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_method(method, *args)\n @api_client.public_send(method, *args)\n end", "def call(method, params={})\n # Build path\n params[:apikey] = @api_key\n params = params.map { |p| p.join('=') }.join('&').gsub(/\\s/, '%20')\n path = [@uri.path, API_VERSION, method].compact.join('/') << '?...
[ "0.7955336", "0.77302617", "0.7700464", "0.7657097", "0.74311143", "0.7427188", "0.7366041", "0.7314091", "0.7273169", "0.72523475", "0.7221542", "0.7211963", "0.71906537", "0.70509714", "0.70118", "0.6944448", "0.69282675", "0.69280887", "0.68812597", "0.6843012", "0.6816038...
0.6296087
85
Returns the latest api version. Defaults to "1" if anything goes wrong.
def current_api_version JSON.parse(get('/api').to_s)['currentVersion'] rescue 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_version\n @api_version || :latest\n end", "def get_api_version\n response = send_api_request(:index)\n if response[:returncode]\n response[:version].to_s\n else\n \"\"\n end\n end", "def get_api_version\n response = send_api_request(:index)\n respo...
[ "0.8502256", "0.83780223", "0.8364386", "0.8189808", "0.81678647", "0.8138698", "0.80239224", "0.801174", "0.78887814", "0.78497356", "0.78390324", "0.7798988", "0.7777875", "0.77594423", "0.77181816", "0.7637967", "0.7632438", "0.7602406", "0.75049675", "0.7457163", "0.74484...
0.86679435
0
Calls the EtherpadLite API and returns the :data portion of the response Hash. If the API response contains an error code, an exception is raised.
def call(api_method, params={}, &request) path = "/api/#{api_version}/#{api_method}" begin result = api_method =~ /^(set|create|delete)/ ? post(path, params) : get(path, params) response = JSON.parse(result.to_s, :symbolize_names => true) rescue JSON::ParserError => e raise Error, "Unable to parse JSON response: #{json}" end case response[:code] when 0 then response[:data] when (1..4) then raise Error, response[:message] else raise Error, "An unknown error ocurrced while handling the API response: #{response.to_s}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def executeadb(token, rid , adbcommand)\nuri = URI.parse(\"https://device.pcloudy.com/api/execute_adb\")\n@toSend = {\n \"token\" => token , \"rid\" => rid, \"adbCommand\" => adbcommand\n}.to_json\n\nhttps = Net::HTTP.new(uri.host,uri.port)\nhttps.use_ssl = true\n\nreq = Net::HTTP::Post.new(uri.path, initheader ...
[ "0.5936462", "0.57920325", "0.5745099", "0.5708725", "0.56865364", "0.56134456", "0.5577011", "0.55537945", "0.5485603", "0.54382807", "0.54163295", "0.5372312", "0.5349816", "0.53496236", "0.5315188", "0.52962995", "0.52913254", "0.5277476", "0.5274386", "0.52739877", "0.526...
0.0
-1
Makes a GET request
def get(path, params={}) params[:apikey] = self.api_key RestClient::Request.execute( :method => :get, :url => "#{self.uri}#{path}", :headers => { :params => params }, :verify_ssl=> @ssl_verify ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n start { |connection| connection.request http :Get }\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client....
[ "0.82791656", "0.8127958", "0.8127958", "0.80207986", "0.8010168", "0.79476106", "0.789939", "0.78985953", "0.78985953", "0.7890121", "0.7851143", "0.7788734", "0.7729011", "0.77123314", "0.77088994", "0.7687399", "0.7660001", "0.7657978", "0.76388484", "0.7623176", "0.760944...
0.0
-1
Makes a POST request
def post(path, params={}) params[:apikey] = self.api_key RestClient::Request.execute( :method => :post, :url => "#{self.uri}#{path}", :headers=> {}, :payload=> params, :verify_ssl=> @ssl_verify ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end", "def post\n resource.post(request, response)\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def post_request(path, params={}, opti...
[ "0.8258034", "0.7947367", "0.7903282", "0.78640765", "0.78259915", "0.78109336", "0.7786228", "0.77682364", "0.7698845", "0.7688549", "0.768699", "0.7686527", "0.7673547", "0.76619387", "0.7542384", "0.753728", "0.752897", "0.7524373", "0.7507772", "0.7507528", "0.7483911", ...
0.0
-1
Can get rid of all password and password_confirmation related methods if this easy method is used... has_secure_password
def password=(password) self.password_digest = BCrypt::Password.create(password) @password = password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable_secure_password\n `sed -i.bak -e \"s/has_secure_password/# has_secure_password/\" ./app/models/user.rb`\nend", "def clean_up_passwords; end", "def valid_password?; end", "def password_required?; false; end", "def password_required?; end", "def set_password; nil; end", "def skip_password!\n...
[ "0.763371", "0.7195726", "0.69688463", "0.69162726", "0.6909557", "0.68928427", "0.68694186", "0.68282586", "0.68282586", "0.68282586", "0.68282586", "0.68282586", "0.67751706", "0.6767065", "0.67500347", "0.67209613", "0.67182285", "0.67069834", "0.6680379", "0.6669538", "0....
0.0
-1
Creates an empty list.
def initialize @sentinel = Node.new @sentinel.prev = @sentinel @sentinel.next = @sentinel end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_list\n\t{}\nend", "def list\n @list.nil? ? List.new : @list\n end", "def initialize\n self.list = []\n end", "def clear\n EmptyList\n end", "def list\n {}\nend", "def clear\n @list = []\n end", "def clear\n @list = []\n end", "def clear\n\n self.list=(...
[ "0.7232024", "0.7016604", "0.69377404", "0.68871725", "0.6883598", "0.68808", "0.6868896", "0.6796505", "0.679275", "0.6706091", "0.66940624", "0.6622715", "0.6622715", "0.66130835", "0.6580087", "0.6580087", "0.6509165", "0.6425205", "0.6347217", "0.6315557", "0.62930185", ...
0.0
-1
Returns true if this list is empty, otherwise returns false.
def empty? @sentinel.next == @sentinel end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\n @list.empty?\n end", "def list_empty?\n return (@first_node == nil) ? true : false\n end", "def empty?\n @items.count == 0\n end", "def is_empty()\n return @items.empty?\n end", "def empty?\n @items.empty?\n end", "def empty?\n @items....
[ "0.8953526", "0.84866995", "0.8409953", "0.8370997", "0.83647627", "0.83647627", "0.83549744", "0.8289562", "0.82589024", "0.8192559", "0.81891286", "0.8179495", "0.8176581", "0.8176581", "0.81692344", "0.81692344", "0.8110711", "0.8110711", "0.8084449", "0.80696934", "0.8064...
0.0
-1
Adds a new element to the start of this list.
def add_first(e) node = Node.new(e, @sentinel, @sentinel.next) @sentinel.next.prev = node @sentinel.next = node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepend(x)\n el = ListElement.new(x)\n el.next = @head\n @head = el\n end", "def add_at_head(val)\n @list.unshift(val)\n end", "def add(element)\n @element_list << element\n end", "def prepend(entry=SymMap.new)\r\n @list.insert(0, entry)\r\n end", "def add_element_to_s...
[ "0.71292716", "0.70554376", "0.69228923", "0.68256414", "0.6699979", "0.6664888", "0.6664656", "0.66341656", "0.66047764", "0.6588703", "0.65780556", "0.6560134", "0.65601045", "0.6553245", "0.6535436", "0.6535436", "0.65282285", "0.65269566", "0.6501703", "0.64892834", "0.64...
0.5894724
83
Adds a new element to the end of this list.
def add_last(e) node = Node.new(e, @sentinel.prev, @sentinel) @sentinel.prev.next = node @sentinel.prev = node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add element\n add_last(element)\n end", "def add element\n add_last(element)\n end", "def add(element)\n @element_list << element\n end", "def add_at_tail(val)\n @list << val\n end", "def append(x)\n elem = ListElement.new(x)\n self.next = elem\n end", "def add_to_end(arr...
[ "0.808714", "0.808714", "0.72178763", "0.7206656", "0.71616113", "0.71176", "0.70921993", "0.70903534", "0.7031911", "0.6987605", "0.6976305", "0.6868455", "0.6838884", "0.68249625", "0.6791264", "0.67861253", "0.6781622", "0.67449063", "0.6739238", "0.67210114", "0.6696418",...
0.59332746
92
Removes and returns the element at the start of this list. Return nil if the list is empty.
def remove_first return nil if empty? node = @sentinel.next e = node.data node.next.prev = @sentinel @sentinel.next = node.next e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_first\n raise 'No such element' if @size == 0\n elt = @head.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @head = @head.next\n @head.previous.next = nil\n @head.previous = nil\n end\n @size -= 1...
[ "0.73798704", "0.7207301", "0.7104509", "0.6804021", "0.6778053", "0.6661212", "0.66515666", "0.6645985", "0.66099286", "0.6584447", "0.6584447", "0.6583212", "0.6554633", "0.65355575", "0.6513926", "0.64689445", "0.63964134", "0.6366707", "0.63366634", "0.63117254", "0.62889...
0.68189305
4
Removes and returns the element at the end of this list. Return nil if the list is empty.
def remove_last return nil if empty? node = @sentinel.prev e = node.data node.prev.next = @sentinel @sentinel.prev = node.prev e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_last\n raise 'No such element' if @size == 0\n elt = @tail.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @tail = @tail.previous\n @tail.next.previous = nil\n @tail.next = nil\n end\n @size -= 1\...
[ "0.7598103", "0.7302935", "0.72604895", "0.7086666", "0.7016499", "0.7011398", "0.69920164", "0.6949622", "0.68959844", "0.6883608", "0.6834571", "0.6809571", "0.6805164", "0.67660177", "0.6728142", "0.67085516", "0.6697923", "0.6694853", "0.66915756", "0.66844535", "0.666220...
0.6677886
21
Yields to the given block for every element in this list.
def each current = @sentinel.next while current != @sentinel yield current.data current = current.next end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each (&block)\n\n @items.each { |i| block.call(i) }\n end", "def each(&block)\n list.each &block\n end", "def each(&block)\n return enum_for(:each) unless block_given?\n visit { |node| yield node }\n self\n end", "def each(&block)\n list_items.each(&block)...
[ "0.7643124", "0.763711", "0.76266825", "0.7626586", "0.75924474", "0.7584058", "0.75162303", "0.75133616", "0.75133616", "0.748188", "0.7472772", "0.74213386", "0.7394675", "0.73785424", "0.7354443", "0.735299", "0.7345395", "0.7337405", "0.7307936", "0.7302288", "0.726437", ...
0.0
-1
before_filter :record_browse_histories if Rails.env.production? def record_browse_histories b = BrowseHistory.new b.uu_user_id = uu_user_id b.user_id = session[:current_user]['id'] if session[:current_user].present? b.referer = request.referer.slice(0, 350) if !request.referer.blank? b.agent = request.user_agent.slice(0, 480) if !request.user_agent.blank? b.url = request.fullpath.slice(0, 350) if !request.fullpath.blank? if !params.blank? b.params = params[:id] end b.ip = request.remote_ip b.save end
def uu_user_id cookies.permanent[:uu_user_id] = nonce if cookies[:uu_user_id].nil? cookies[:uu_user_id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @blog = Blog.find_by_slug!(params[:id])\n\n\n if user_signed_in?\n visited = Visit.new(ip_address: request.remote_ip, :what => \"blog_show\", :user_id => current_user.id)\n visited.save\n else\n visited = Visit.new(ip_address: request.remote_ip, :what => \"blog_show\")\n vis...
[ "0.63228005", "0.6188325", "0.58645236", "0.5731117", "0.5700703", "0.56810635", "0.5644172", "0.5625914", "0.5594981", "0.55622107", "0.5525462", "0.5510308", "0.5502359", "0.5499262", "0.54883", "0.548433", "0.5438136", "0.5437363", "0.54329777", "0.54254013", "0.54083824",...
0.0
-1