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 |
|---|---|---|---|---|---|---|
this will determine if the box is allowed to be moved, which will ultimately determine if the player is allowed to move | def moveBox(oldX,oldY,newX,newY)
xDirection=newX-oldX
yDirection=newY-oldY
proposedBoxPos=@levelArr[newY+yDirection][newX+xDirection]
case(proposedBoxPos)
when ' ','.'
#this will run when the next possible position of the box is a blank space(' ') or is a box goal ('.')
@levelArr[newY][newX]=' '
@levelArr[newY+yDirection][newX+xDirection]='$'
moveMan(oldX,oldY,newX,newY)
else
#otherwise, abort the process
return
end
replenishBoxGoals
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_move x,y\n return false unless (0..3) === x\n return false unless (0..3) === y\n return @field[x][y].player == 0\n end",
"def is_move_allowed(to_x,to_y) #Checks to see if the move is allowed based on the pieces 'rule'\n allowed=false\n \n x_diff=(to_x-@x).abs\n ... | [
"0.7199138",
"0.7148825",
"0.7042504",
"0.6999087",
"0.6953574",
"0.685911",
"0.6841494",
"0.6837268",
"0.68134755",
"0.6741231",
"0.67260826",
"0.67047095",
"0.6675688",
"0.6666348",
"0.66641533",
"0.6645274",
"0.65765107",
"0.6572021",
"0.656637",
"0.6547304",
"0.65370315",... | 0.0 | -1 |
creating an array for locateMan, where the 0th element is x across, and the 1st element is y down | def locateMan
yDown=0
@levelArr.each do |y|
xCount=1
y.each do |x|
if x == '@'
return xCount,yDown
end
xCount+=1
end
yDown+=1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location\n [@posX, @posY, @facing]\n end",
"def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end",
"def get_cell_at_xy(input_array)\n input_array.map do |coord|\n x = coord[0]\n y = coord[1]\n at_coord... | [
"0.6381427",
"0.6282143",
"0.62155336",
"0.6201006",
"0.6173462",
"0.6138358",
"0.6096959",
"0.6088362",
"0.6043062",
"0.60320646",
"0.5939095",
"0.5936157",
"0.5900313",
"0.5886333",
"0.58730876",
"0.58582896",
"0.585681",
"0.5854415",
"0.58192456",
"0.58101594",
"0.5802714"... | 0.6663756 | 0 |
GET /traces/1 GET /traces/1.xml | def show
@trace = Trace.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @trace }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @traces = Trace.all\n\n render json: @traces\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n ... | [
"0.6214823",
"0.6100431",
"0.6033639",
"0.56212276",
"0.55663943",
"0.55239695",
"0.5498872",
"0.54892373",
"0.54737365",
"0.5434124",
"0.5434124",
"0.5401129",
"0.53968227",
"0.53658843",
"0.5344298",
"0.5342842",
"0.53344697",
"0.53060704",
"0.5285319",
"0.52768576",
"0.526... | 0.6564382 | 0 |
GET /traces/new GET /traces/new.xml | def new
@trace = Trace.new(params[:trace])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @trace }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n format.html { redirect_to(@trace, :notice... | [
"0.733107",
"0.6416524",
"0.6407681",
"0.62683946",
"0.6206989",
"0.6154043",
"0.6154043",
"0.61399186",
"0.6129796",
"0.6114777",
"0.6091656",
"0.60756296",
"0.60152227",
"0.60088545",
"0.60088545",
"0.6006569",
"0.5967345",
"0.5965664",
"0.59655195",
"0.59530616",
"0.595298... | 0.727908 | 1 |
POST /traces POST /traces.xml | def create
@trace = Trace.new(params[:trace])
respond_to do |format|
if @trace.save
format.html { redirect_to(@trace, :notice => 'Trace was successfully created.') }
format.xml { render :xml => @trace, :status => :created, :location => @trace }
else
format.html { render :action => "new" }
format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def test_post_sample_tr... | [
"0.6692415",
"0.6669374",
"0.6325361",
"0.5938512",
"0.5909333",
"0.57289594",
"0.57259846",
"0.56932604",
"0.56564623",
"0.5651693",
"0.5634122",
"0.553403",
"0.54249704",
"0.5368843",
"0.5315113",
"0.5280669",
"0.51258254",
"0.5042592",
"0.5033409",
"0.5029465",
"0.5018457"... | 0.65364623 | 2 |
PUT /traces/1 PUT /traces/1.xml | def update
@trace = Trace.find(params[:id])
respond_to do |format|
if @trace.update_attributes(params[:trace])
format.html { redirect_to(@trace, :notice => 'Trace was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{conte... | [
"0.6835423",
"0.60055846",
"0.5863916",
"0.55920285",
"0.558591",
"0.55336314",
"0.55016124",
"0.54899234",
"0.54840225",
"0.53827286",
"0.5276518",
"0.52729386",
"0.52646047",
"0.51118666",
"0.5062133",
"0.50550354",
"0.5046644",
"0.5031522",
"0.5015565",
"0.49722326",
"0.49... | 0.61566895 | 1 |
DELETE /traces/1 DELETE /traces/1.xml | def destroy
@trace = Trace.find(params[:id])
@trace.destroy
respond_to do |format|
format.html { redirect_to(traces_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.... | [
"0.70515364",
"0.63895845",
"0.60920775",
"0.60506153",
"0.60361624",
"0.60091126",
"0.59992844",
"0.59912455",
"0.5844168",
"0.58360606",
"0.57954866",
"0.5791484",
"0.57795537",
"0.57717574",
"0.5738916",
"0.57241696",
"0.57216364",
"0.5721081",
"0.5709976",
"0.56974405",
"... | 0.71903116 | 1 |
GET /studenttests GET /studenttests.json | def index
@studenttests = Studenttest.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def my_students(query={})\n self.simple_client.get(\"/api/v1/students?#{query.to_query}\")\n end",
"def index\n ... | [
"0.7342745",
"0.6774699",
"0.6741088",
"0.67029816",
"0.66744035",
"0.66239357",
"0.65891767",
"0.6573441",
"0.65558666",
"0.6547281",
"0.64935964",
"0.64917266",
"0.64917266",
"0.64890325",
"0.64645094",
"0.64582145",
"0.6453144",
"0.634893",
"0.632752",
"0.6314565",
"0.6306... | 0.7141873 | 1 |
GET /studenttests/1 GET /studenttests/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def get_student\n @student = Student.find(params[:std_id])\n render json: @student\n end",
"def index\n @st... | [
"0.75577104",
"0.69995546",
"0.69687235",
"0.6698824",
"0.6685507",
"0.66854626",
"0.6656588",
"0.6654055",
"0.659521",
"0.65585995",
"0.6549385",
"0.6519743",
"0.6498389",
"0.6468148",
"0.6468148",
"0.64577466",
"0.64571905",
"0.6453235",
"0.6426115",
"0.64200556",
"0.639512... | 0.0 | -1 |
POST /studenttests POST /studenttests.json | def create
@studenttest = Studenttest.new(studenttest_params)
respond_to do |format|
if @studenttest.save
format.html { redirect_to @studenttest, notice: 'Studenttest was successfully created.' }
format.json { render :show, status: :created, location: @studenttest }
else
format.html { render :new }
format.json { render json: @studenttest.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @student_test = StudentTest.new(params[:student_test])\n\n respond_to do |format|\n if @student_test.save\n format.html { redirect_to @student_test, notice: 'Student test was successfully created.' }\n format.json { render json: @student_test, status: :created, location: @stud... | [
"0.7313287",
"0.65778613",
"0.64818156",
"0.6481537",
"0.637193",
"0.6324752",
"0.63236153",
"0.6302043",
"0.61968744",
"0.618197",
"0.6168903",
"0.6164026",
"0.61461747",
"0.61207753",
"0.6107524",
"0.6096397",
"0.6054729",
"0.603553",
"0.6033991",
"0.6025285",
"0.6025285",
... | 0.7105652 | 1 |
PATCH/PUT /studenttests/1 PATCH/PUT /studenttests/1.json | def update
respond_to do |format|
if @studenttest.update(studenttest_params)
format.html { redirect_to @studenttest, notice: 'Studenttest was successfully updated.' }
format.json { render :show, status: :ok, location: @studenttest }
else
format.html { render :edit }
format.json { render json: @studenttest.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n if @student_test.update_attributes(params[:student_test])\n format.html { redirect_to @student_test, notice: 'Student test was successfully updated.' }\n format.json { head :ok }\n else\n fo... | [
"0.72673965",
"0.6570896",
"0.65522385",
"0.64222735",
"0.6384512",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.6357426",
"0.63539463",
"0.6352404",
"0.63210696",
"0.63210696",
"0.63161266",
"0.631607",
"0.630436",
"0.6... | 0.6956709 | 1 |
DELETE /studenttests/1 DELETE /studenttests/1.json | def destroy
@studenttest.destroy
respond_to do |format|
format.html { redirect_to studenttests_url, notice: 'Studenttest was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |... | [
"0.79265225",
"0.7243113",
"0.72413415",
"0.7187567",
"0.7187567",
"0.70800036",
"0.7045642",
"0.7038258",
"0.70323914",
"0.70323914",
"0.70323914",
"0.70323914",
"0.7028767",
"0.7025695",
"0.7012168",
"0.6995361",
"0.6992316",
"0.6985116",
"0.69729567",
"0.69553304",
"0.6955... | 0.75891656 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_studenttest
@studenttest = Studenttest.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 studenttest_params
params.require(:studenttest).permit(:name, :lastname, :birthday)
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 |
This method is called by the specialized implementations upon tree creation. Initialization parameters can include: an array of branches to add one or several trees to copy (will be merged if multiple) | def initialize(*params)
super(*params) # Delegates to Plexus.
@_options = (params.pop if params.last.is_a? Hash) || {}
_delay { alias has_branch? has_edge? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_branch\n @tree_class.new\n end",
"def branches\n @branches ||= build_branches\n end",
"def build_branches\n branches_collection(coverage[:branches] || {})\n end",
"def build_tree(arr)\n\tend",
"def initialize(height, branching_factor, approx)\n @height = height #ge... | [
"0.691574",
"0.6246609",
"0.61717546",
"0.61243355",
"0.60841304",
"0.59614336",
"0.59594506",
"0.59445596",
"0.5912075",
"0.5849564",
"0.5803994",
"0.5802572",
"0.57915556",
"0.57899034",
"0.57891446",
"0.57454455",
"0.5689306",
"0.56851363",
"0.5685125",
"0.568016",
"0.5655... | 0.0 | -1 |
Checks whether the tree is really a valid tree, that is if the following conditions are fulfilled: undirected acyclic connected | def valid?
super && !directed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_tree?\n true\n end",
"def valid_tree?\n false\n end",
"def valid_tree?\n true\n end",
"def valid_tree?\n true\n end",
"def tree_nodes_valid?\n (root_tree_node.present? || top_nav_node_info_cd.zero?) &&\n (branch_tree_node.present? || sub_nav_node_info_cd.zero?)... | [
"0.81485015",
"0.7981112",
"0.7959057",
"0.7959057",
"0.7629024",
"0.71501994",
"0.69527376",
"0.6856072",
"0.66898006",
"0.66111857",
"0.65457964",
"0.6363072",
"0.6257565",
"0.62017035",
"0.6181386",
"0.6147313",
"0.6130815",
"0.6113278",
"0.61035365",
"0.610086",
"0.608394... | 0.6481792 | 11 |
show method is default | def destroy
@my_posting = Posting.find(params[:id])
@my_posting.destroy
redirect_to "/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n\t\t end",
"def show ; end",
"def show\n end",
"def show\n end"... | [
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.87746966",
"0.86819065",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
... | 0.0 | -1 |
include devise helper methods | def setup
@admin = users(:admin)
@user = users(:user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_controller?; end",
"def devise_mappings; end",
"def devise_modules_hook!; end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def devise_parameter_sanitizer; end",
"def devise_scope(scope); end",
"def user_authentication\n end",
"de... | [
"0.7576859",
"0.7219472",
"0.7157984",
"0.6675184",
"0.6668521",
"0.6640306",
"0.66053385",
"0.6424436",
"0.62998796",
"0.62998796",
"0.62998796",
"0.62581426",
"0.6153387",
"0.6149502",
"0.6124568",
"0.61117995",
"0.6107976",
"0.6087983",
"0.60797405",
"0.6054703",
"0.603841... | 0.0 | -1 |
Parses the commandline arguments and runs the executable. Calls `Kernelexit` at the end, so it never returns. | def parse!
begin
@opts = OptionParser.new(&method(:set_opts))
@opts.parse!(@args)
@options
rescue Exception => e
raise e if e.is_a?(SystemExit)
$stderr.puts e.message
exit 1
end
exit 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n re... | [
"0.68332916",
"0.66638947",
"0.6479788",
"0.64607114",
"0.6454007",
"0.6442641",
"0.64321524",
"0.64225435",
"0.6417517",
"0.63770175",
"0.6362033",
"0.63367075",
"0.632113",
"0.63196343",
"0.63014275",
"0.6293867",
"0.62918633",
"0.6280793",
"0.6280793",
"0.6280793",
"0.6280... | 0.5775854 | 59 |
Tells optparse how to parse the arguments available for all executables. This is meant to be overridden by subclasses so they can add their own options. | def set_opts(opts)
opts.on_tail("-?", "-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "Print version") do
puts("TXPRails #{::TXPRails.version[:string]}")
exit
end
opts.on('--rails RAILS_DIR', "Install TXPRails from the Gem to a Rails project") do |dir|
original_dir = dir
dir = File.join(dir, 'vendor', 'plugins')
unless File.exists?(dir)
puts "Directory #{dir} doesn't exist"
exit
end
dir = File.join(dir, 'txprails')
if File.exists?(dir)
print "Directory #{dir} already exists, overwrite [y/N]? "
exit if gets !~ /y/i
FileUtils.rm_rf(dir)
end
begin
Dir.mkdir(dir)
rescue SystemCallError
puts "Cannot create #{dir}"
exit
end
File.open(File.join(dir, 'init.rb'), 'w') do |file|
file << File.read(File.dirname(__FILE__) + "/../init_rails.rb")
end
puts "Haml plugin added to #{original_dir}"
exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_opts\n option_parser.parse(@argv)\n end",
"def parse_opts\n if parse_argv\n apply_options\n true\n end\n end",
"def parse_options(opts, args); end",
"def optparse_args\n if short\n [\"--#{name}\", \"-#{short}\", desc, :REQUIRED]\n ... | [
"0.7472496",
"0.7272251",
"0.726024",
"0.70750475",
"0.7013277",
"0.6992019",
"0.69448227",
"0.693979",
"0.69206727",
"0.6917643",
"0.6903173",
"0.6861814",
"0.68046296",
"0.67599016",
"0.67599016",
"0.67512107",
"0.6736139",
"0.67022526",
"0.6683321",
"0.6647732",
"0.6639775... | 0.0 | -1 |
Depth first search for the longest simple path starting from 'node' Simple path means a path that doesn't contain any duplicate edges Note: I'm not suing the definition of simply connected based on no duplicate nodes | def search(node)
longest_path = 0
if (@paths[node])
@paths[node].each_index do |next_idx|
next_node = @paths[node][next_idx]
@paths[node].delete_at(next_idx)
tmp = 1 + search(next_node)
@paths[node].insert(next_idx,next_node)
if (longest_path < tmp)
longest_path = tmp
end
end
end
return longest_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend",
"def depth_first_search!(node)\n node.marked = true\n node.type = \"M\"\n node.adj.each do |n|\n if n.marked == false\n depth_f... | [
"0.6996769",
"0.6797798",
"0.6789873",
"0.6686385",
"0.6575007",
"0.65383977",
"0.64992005",
"0.64012295",
"0.63809913",
"0.6352742",
"0.62899816",
"0.6271176",
"0.62113756",
"0.62113756",
"0.6207053",
"0.619099",
"0.6189835",
"0.6187292",
"0.6179531",
"0.6177912",
"0.6144253... | 0.6577683 | 5 |
find whether there is a path from node start to last | def find(start,last)
next_nodes = Array.new
next_nodes << start
visited = {}
while (not next_nodes.empty?)
next_node = next_nodes.shift
next if visited[next_node]
visited[next_node] = true
return true if next_node == last
@paths[next_node].map do |x| next_nodes << x end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed_path?\n path.size == nodes.size - 1\n end",
"def has_path_to?(end_node)\n @visited.include?(end_node)\n end",
"def path_exists?(edges, start, finish) \n nodes = edges[start].keys\n touchedNodes = nodes + [start]\n newNodes = nodes\n\n until newNodes.length == 0\n return t... | [
"0.7689254",
"0.7613609",
"0.73372984",
"0.68381256",
"0.68094456",
"0.67136925",
"0.66374946",
"0.6562556",
"0.6544726",
"0.65369296",
"0.65261626",
"0.6514396",
"0.6495075",
"0.64752203",
"0.64050233",
"0.6394061",
"0.6357536",
"0.6310814",
"0.63036186",
"0.62605834",
"0.62... | 0.7417204 | 2 |
Flood fill to find the largest strongly connected component starting from node Strongly connected means that there is a path from u>v and from v>u | def fill(node)
filled_so_far = Array.new
nodes_hash = Hash.new
already_seen = Hash.new
queue = [node]
while (not queue.empty?)
next_node = queue.shift
next if already_seen[next_node]
already_seen[next_node] = true
@paths[next_node].each do |next_next_node|
if (next_next_node == next_node)
# special case. we consider a node connected to itself to be strongly connected
nodes_hash[next_node] = true
elsif (find(next_next_node,next_node))
# make sure there is a reverse path
queue << next_next_node
nodes_hash[next_node] = true
nodes_hash[next_next_node] = true
end
end
end
nodes = nodes_hash.keys
@paths.each do |k,v|
if nodes.include?(k)
v.each do |v|
if nodes.include?(v)
filled_so_far << [k,v]
end
end
end
end
return filled_so_far
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findShortest(graph_nodes, graph_from, graph_to, ids, val)\n return -1 if ids.count(val)<=1 # no two nodes with color val\n dmin = graph_nodes\n num_edges = graph_from.length\n neighbors = {}\n 0.upto(num_edges-1) do |i|\n if neighbors[graph_from[i]]\n neighbors[graph_from[i]] << grap... | [
"0.61022514",
"0.5984173",
"0.58644605",
"0.58266485",
"0.5819249",
"0.58173627",
"0.58066255",
"0.5785303",
"0.5783612",
"0.5778778",
"0.5766235",
"0.57561964",
"0.57544965",
"0.5744193",
"0.5743905",
"0.5739453",
"0.56765485",
"0.5663361",
"0.56591034",
"0.56219923",
"0.555... | 0.56913644 | 17 |
Bug found using this test case | def test_05
@dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])
@paths = Hash.new
@paths[0] = [7]
@paths[1] = [9,4]
@paths[7] = [4,0,9]
@paths[3] = [7]
@paths[9] = [4,7,9]
@paths[4] = [1,4,7]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(0);
filled_dg = DiGraph.new(*fill(0));
if (not filled_dg.equal?(received_dg))
puts "test_05 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 0"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schuber... | [
"0.6767296",
"0.62264943",
"0.600941",
"0.5921807",
"0.58881867",
"0.58881867",
"0.58881867",
"0.58881867",
"0.5798754",
"0.5798754",
"0.57515544",
"0.57446426",
"0.5731531",
"0.56717753",
"0.55894893",
"0.5568649",
"0.55508506",
"0.5546685",
"0.5544533",
"0.5512657",
"0.5504... | 0.0 | -1 |
Bug found using this test case | def test_06
@dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])
@paths = Hash.new
@paths[5] = [9]
@paths[0] = [3]
@paths[3] = [8]
@paths[8] = [9]
@paths[9] = [0]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(0);
filled_dg = DiGraph.new(*fill(0));
if (not filled_dg.equal?(received_dg))
puts "test_06 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 0"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schuber... | [
"0.6766784",
"0.62270457",
"0.6009193",
"0.5921741",
"0.58877975",
"0.58877975",
"0.58877975",
"0.58877975",
"0.5798168",
"0.5798168",
"0.5750772",
"0.5744431",
"0.57310957",
"0.5671328",
"0.5589977",
"0.5568493",
"0.55509824",
"0.55467534",
"0.5543746",
"0.551302",
"0.550397... | 0.0 | -1 |
Bug found using this test case | def test_07
@dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])
@paths = Hash.new
@paths[0] = [0]
@paths[6] = [0,8]
@paths[2] = [6]
@paths[8] = [8]
@paths[3] = [4,2,9]
@paths[9] = [4,6]
@paths[4] = [3,8]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(6);
filled_dg = DiGraph.new(*fill(6));
if (not filled_dg.equal?(received_dg))
puts "test_07 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 6"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schuber... | [
"0.6766784",
"0.62270457",
"0.6009193",
"0.5921741",
"0.58877975",
"0.58877975",
"0.58877975",
"0.58877975",
"0.5798168",
"0.5798168",
"0.5750772",
"0.5744431",
"0.57310957",
"0.5671328",
"0.5589977",
"0.5568493",
"0.55509824",
"0.55467534",
"0.5543746",
"0.551302",
"0.550397... | 0.0 | -1 |
Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. | def longest_word(sen)
words = sen.split
words.map! { |word| word.delete('^A-Za-z1-9_\'') }
longest = words.first
words.each_with_index do |word, idx|
next if idx >= words.size - 1
longest = longest.size < words[idx + 1].size ? words[idx + 1] : longest
end
longest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LongestWord(sen)\n str = sen.split(\" \")\n longest_word = str[0]\n str.each do |word|\n word.sub(/[\\w\\s]/, '')\n if longest_word.length < word.length\n longest_word = word\n end\n end\n longest_word\nend",
"def LongestWord(sen)\n arr = sen.split(' ')\n longest = arr[0]\n arr.each do ... | [
"0.896335",
"0.8898313",
"0.88247263",
"0.87739486",
"0.8490838",
"0.84627956",
"0.837038",
"0.8263723",
"0.8261048",
"0.8164274",
"0.8097665",
"0.80245733",
"0.79955196",
"0.7969295",
"0.79236513",
"0.7911946",
"0.7903026",
"0.7902575",
"0.7897251",
"0.78526926",
"0.78202397... | 0.8614654 | 4 |
add some books into inventory | def purchase_books(newbooks)
newbooks.each {|book, number| inventory[book] = number}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend",
"def add_book(book)\n current_item = line_items.find_by(book_id: book.id)\n if current_item\n current_item.quantity +=1\n else\n current_item = line_items.build(book_id: book.id)\n end\n ... | [
"0.7751378",
"0.75770247",
"0.7140081",
"0.71239245",
"0.70976305",
"0.70146227",
"0.70124143",
"0.6956679",
"0.69466984",
"0.69409853",
"0.6938078",
"0.6936585",
"0.6927334",
"0.6874041",
"0.68431854",
"0.6842158",
"0.6809074",
"0.67954046",
"0.67708445",
"0.67566246",
"0.67... | 0.7760547 | 0 |
A user can only borrow one for each kind of books. | def lend_books(books, user)
if @users.include? user then
books.uniq.each do |book|
if inventory[book] > 0 then
inventory[book] -= 1
add_a_record(user, book)
else
puts "Sorry, <#{book.title}> is unavailable."
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def borrow(book_id, user_id)\r\n @@books.each do |book|\r\n @@users.each do |user|\r\n if book.bookID == book_id && user.userID == user_id\r\n if book.status == \"available\"\r\n book.borrower = (user.fname+\" \"+user.lname)\r\n book.status = \"borrowed\"\r\n ... | [
"0.71628296",
"0.68416333",
"0.6751122",
"0.6643782",
"0.65890825",
"0.6433646",
"0.64299554",
"0.63787955",
"0.63297313",
"0.62262493",
"0.6147137",
"0.61120266",
"0.60172224",
"0.60103166",
"0.6007617",
"0.5996478",
"0.5983993",
"0.5955166",
"0.5933927",
"0.5920414",
"0.591... | 0.0 | -1 |
Return a book to the library. | def return_books(books, user)
if @users.include? user then
(@records.select {|record| !record.has_return && record.user_id.eql?(user.id)}).each do |record|
books.uniq.each do |book|
if book.isbn == record.book_isbn then
inventory[book] += 1
record.has_return = true
puts "Successfully return <#{book.title}> to the library"
end
end
end
check_records(user)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book\n fetch('harry_potter.books')\n end",
"def return_book\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t\tb = Book.find(select)\n\t\tpatron_id = nil\n\t\tb.update_attributes(patron_id: patron_id)\nend",
"def book\n sql = \"SELECT * FROM books WHERE books... | [
"0.77180934",
"0.7081529",
"0.7010487",
"0.68856025",
"0.67969453",
"0.67892164",
"0.67892164",
"0.6716013",
"0.6636221",
"0.6635891",
"0.66128635",
"0.65825385",
"0.6545766",
"0.65425885",
"0.6538816",
"0.6533374",
"0.65168685",
"0.6478277",
"0.6473248",
"0.64567584",
"0.645... | 0.0 | -1 |
Create a new record for current transaction One record is created for one book. Every user can only borrow a book for 60 days. | def add_a_record(user, book)
now = DateTime.now.to_date
borrow_days = 60
due = now + borrow_days
@records << Record.new(user.id, book.isbn, now, due)
puts "Successfully lend <#{book.title}> to #{user.name}. Due:#{due}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n book_id = params[:book_id]\n book_title = params[:book_title]\n borrowerid = params[:borrowerid]\n borrowdate = params[:borrow_date]\n returndate = params[:return_date]\n @borrowtable = Borrowtable.new(:bookid => book_id, :bookname => book_title, :borrowerid => borrowerid,\n ... | [
"0.69769645",
"0.69267875",
"0.6913721",
"0.65632766",
"0.6509955",
"0.6485653",
"0.64737046",
"0.64623195",
"0.6437323",
"0.6433015",
"0.6413216",
"0.6384438",
"0.63746494",
"0.6355107",
"0.6324764",
"0.6317695",
"0.6309435",
"0.63090104",
"0.6304816",
"0.63032097",
"0.62798... | 0.71910864 | 0 |
Print out the inventory | def inventory_to_s
puts "------------------inventory----------------"
inventory.each {|book, number| puts "Remain #{number} for <#{book.title}>"}
puts "-------------------------------------------"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if @inventory.empty?\n print \"#{@name}'s inventory is empty!\\n\\n\"\n return\n end\n\n puts \"#{@name}'s inventory:\"\n @inventory.each do |couple|\n puts \"* #{couple.first.name} (#{couple.se... | [
"0.8691387",
"0.850271",
"0.83751404",
"0.83042043",
"0.81267023",
"0.81070507",
"0.8087145",
"0.79579186",
"0.79470086",
"0.7941801",
"0.7832741",
"0.7729665",
"0.75657713",
"0.7492231",
"0.7403818",
"0.739407",
"0.7339213",
"0.7316211",
"0.7301596",
"0.72886515",
"0.7209996... | 0.8147413 | 4 |
Check records of a user. | def check_records(user)
@records.select{|record| !record.has_return && record.user_id == user.id}.each do |record|
@inventory.each do |book,value|
if book.isbn == record.book_isbn then
puts "=> Warning! \n"
puts "#{user.name} borrowed <#{book.title}> on #{record.borrow_date}, #{user.name} has to return it before #{record.due}."
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_check(resource)\n return true unless self[:name] == \"user\"\n return true unless self[:unless_system_user]\n\n resource[:audit] = :uid\n\n return false if system_users.include?(resource[:name])\n\n current_values = resource.retrieve_resource\n current_values[resource.property(:uid)] > s... | [
"0.63647467",
"0.63553554",
"0.6290373",
"0.61673236",
"0.615817",
"0.6141064",
"0.61370826",
"0.611401",
"0.6047428",
"0.6017651",
"0.6003659",
"0.6002102",
"0.599394",
"0.59900594",
"0.5970619",
"0.5958268",
"0.59244865",
"0.5921791",
"0.5911777",
"0.59102124",
"0.58602285"... | 0.6952754 | 0 |
Write a method, is_prime? You have to determine what are the arguments required for is_prime The method should be used to determine if a number is a prime number recursively. | def is_prime?
#Your code here
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime?(num)\nend",
"def is_prime?(num)\n\nend",
"def is_prime?(number)\n\nend",
"def is_prime?(number)\n\nend",
"def is_prime?(num)\n # Write your code here\nend",
"def is_prime?(n)\n end",
"def prime?(arg)\n Prime.prime?(arg)\nend",
"def prime?(int)\n \nend",
"def is_prime(x)\n retur... | [
"0.83943486",
"0.836582",
"0.83246696",
"0.83246696",
"0.8283293",
"0.82549274",
"0.8091258",
"0.80871874",
"0.80385745",
"0.79345393",
"0.7886125",
"0.7881939",
"0.78589314",
"0.7831226",
"0.7829843",
"0.7825355",
"0.7824195",
"0.7797287",
"0.77783936",
"0.7771088",
"0.77648... | 0.80926824 | 6 |
GET /comments/1 GET /comments/1.json | def show
@idea = Idea.find(params[:idea_id])
@comments = @idea.comments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_... | [
"0.8281809",
"0.7442966",
"0.7442966",
"0.7435585",
"0.74057704",
"0.7305289",
"0.7283902",
"0.7258409",
"0.7255485",
"0.72482485",
"0.7243032",
"0.72200114",
"0.72188604",
"0.7218659",
"0.7174758",
"0.71585846",
"0.7157486",
"0.7119247",
"0.7116642",
"0.7101369",
"0.71012545... | 0.0 | -1 |
POST /comments POST /comments.json | def create
@idea = Idea.find(params[:idea_id])
@comment = @idea.comments.new(comment_params)
@comment.user_id = current_user.id
@comment.user = current_user
if
@comment.save
redirect_to @idea
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
... | [
"0.7513323",
"0.7423756",
"0.7375538",
"0.72369885",
"0.72065747",
"0.70876884",
"0.7068213",
"0.7055196",
"0.7050029",
"0.6991239",
"0.69830215",
"0.69673634",
"0.69590974",
"0.6911419",
"0.6910673",
"0.6874636",
"0.687359",
"0.6824285",
"0.6813097",
"0.6789313",
"0.67860657... | 0.0 | -1 |
PATCH/PUT /comments/1 PATCH/PUT /comments/1.json DELETE /comments/1 DELETE /comments/1.json | def destroy
@comment = Comment.find(params[:id])
@comment.destroy
respond_to do |format|
format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_comment1\n params[:comment].each { |key, value|\n comment=Comment.find(key)\n if !comment.nil?\n k comment.destroy\n end\n ... | [
"0.6488403",
"0.6398444",
"0.63851017",
"0.6352142",
"0.6344028",
"0.6324272",
"0.63089526",
"0.630499",
"0.6295087",
"0.6268955",
"0.6251883",
"0.62483746",
"0.62459433",
"0.6244871",
"0.6228032",
"0.61714435",
"0.61684746",
"0.6163004",
"0.6163004",
"0.6163004",
"0.6140432"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between action Never trust parameters from the scary internet, only allow the white list through. | def comment_params
params.require(:comment).permit(:body, :parent_id, :user_id, :idea_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_setup; end",
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def before_action \n end",
"def before_setup\n # do nothing by default\n end",
"def before_filter; end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"de... | [
"0.6105329",
"0.5951854",
"0.5890952",
"0.587356",
"0.5622538",
"0.5599444",
"0.5599444",
"0.55656695",
"0.5533773",
"0.55317533",
"0.5505655",
"0.5471736",
"0.5467662",
"0.54446685",
"0.54280174",
"0.5415846",
"0.5412756",
"0.5409124",
"0.53936976",
"0.53926057",
"0.53926057... | 0.0 | -1 |
save new status of event order | def update_status
authorize @event_order
begin
raise "Please enter the transaction id." unless params[:transaction_id].present? if (@event_order.pending? || @event_order.failure?)
ApplicationRecord.transaction do
update_event_order_status(params[:status])
@event_order.after_manual_status_update(params[:transaction_id])
@event_order.update_columns(reg_ref_number: "manual_"+@event_order.reg_ref_number) if @event_order.success?
end
rescue SyException, AASM::InvalidTransition => e
@message = e.message
if @event_order.errors.present?
error = @event_order.errors.messages.first
@message = error.is_a?(Array) ? error.flatten.join(' ') : error
end
rescue Exception => e
@message = e.message
end
@message.present? ? flash[:error] = @message : flash[:success] = "Status Updated Successfully."
respond_to do |format|
format.js
format.html{ redirect_back(fallback_location: proc { root_path }) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(event)\n data = {\n agenda: Agenda.file,\n owner: @owner,\n text: @text,\n pmc: @pmc,\n date: @date,\n status: @status\n }\n\n @disabled = true\n post 'status', data do |pending|\n jQuery('#updateStatusForm').modal(:hide)\n @disabled = false\n Pendi... | [
"0.71798056",
"0.71562916",
"0.6654894",
"0.6650511",
"0.6606601",
"0.64902574",
"0.64076",
"0.6342702",
"0.63323057",
"0.6280147",
"0.6255709",
"0.6254433",
"0.6253874",
"0.62392217",
"0.62138253",
"0.61581093",
"0.6150423",
"0.609832",
"0.6088951",
"0.6060743",
"0.60460055"... | 0.6182471 | 15 |
Use callbacks to share common setup or constraints between actions. | def set_event_order
@event_order = EventOrder.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def event_order_params
params.require(:event_order).permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
'eventsdestroy' (still needs testing) | def destroy
@event = Event.find(params[:id])
@event.destroy
redirect_to '/events'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_events\n @events.destroy_all\n end",
"def destroy\r\n @event.destroy\r\n end",
"def reset!\n @events = nil\n end",
"def destroy\n @clock_event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.des... | [
"0.75859725",
"0.7464302",
"0.7444678",
"0.7233316",
"0.7232815",
"0.7232815",
"0.7232815",
"0.71593434",
"0.70242894",
"0.69922",
"0.6950243",
"0.69470793",
"0.6945672",
"0.6735936",
"0.6680631",
"0.6668398",
"0.6634904",
"0.6612553",
"0.6602262",
"0.6592811",
"0.65802115",
... | 0.0 | -1 |
GET /admin/funcionarios/1 GET /admin/funcionarios/1.json | def show
@funcionario = Funcionario.find(params[:id])
respond_with @funcionario, :location => admin_funcionario_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def... | [
"0.7249679",
"0.70558417",
"0.70558417",
"0.70295674",
"0.6838803",
"0.68160063",
"0.6718118",
"0.66828966",
"0.6593217",
"0.6485803",
"0.645231",
"0.6447877",
"0.63661695",
"0.62970614",
"0.6265304",
"0.623989",
"0.6210647",
"0.6198975",
"0.6187996",
"0.6182959",
"0.6152777"... | 0.7101302 | 1 |
GET /admin/funcionarios/new GET /admin/funcionarios/new.json | def new
@funcionario = Funcionario.new
@funcionario.contato_telefones.build
respond_with @funcionario, :location => new_admin_funcionario_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def create\n @tipo_funcionario = TipoFuncionario.new(tipo_funcionario_params)\n\n respond_to do |format|\n if @tipo_funcionari... | [
"0.79055303",
"0.7298924",
"0.72745794",
"0.7200279",
"0.7192419",
"0.7169684",
"0.71055186",
"0.6987913",
"0.696834",
"0.69390494",
"0.68903315",
"0.68157226",
"0.6777903",
"0.67569673",
"0.6734827",
"0.6729333",
"0.67257786",
"0.67065614",
"0.6702373",
"0.66999155",
"0.6692... | 0.7700561 | 1 |
POST /admin/funcionarios POST /admin/funcionarios.json | def create
@funcionario = Funcionario.new(params[:funcionario])
if current_user.is_role?(:administrador)
else
@funcionario.user = current_user
end
flash[:notice] = "Funcionario salvo com sucesso!" if @funcionario.save
# respond_with @funcionario, :location => [:admin, @funcionario]
redirect_to admin_funcionarios_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @funcionario = Funcionario.new(funcionario_params)\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionário cadastrado com sucesso' }\n format.json { render :show, status: :created, location: @funcionario }\n else\n ... | [
"0.7517975",
"0.7343464",
"0.73300046",
"0.7211747",
"0.7053303",
"0.6952806",
"0.6943883",
"0.6917097",
"0.6854856",
"0.6790179",
"0.66772604",
"0.6671857",
"0.66379964",
"0.6604357",
"0.64879626",
"0.6470288",
"0.6452992",
"0.63931334",
"0.63716483",
"0.6287675",
"0.6243014... | 0.65966755 | 14 |
PUT /admin/funcionarios/1 PUT /admin/funcionarios/1.json | def update
@funcionario = Funcionario.find(params[:id])
respond_to do |format|
if @funcionario.update_attributes(params[:funcionario])
format.html { redirect_to [:admin, @funcionario], notice: 'Funcionario Atualizado com sucesso.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @funcionario.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @funcao.update(funcao_params)\n format.html { redirect_to @funcao, notice: 'Funcao was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcao }\n else\n format.html { render :edit }\n format.json { rend... | [
"0.7178259",
"0.7031",
"0.6980899",
"0.69224733",
"0.69187415",
"0.6802858",
"0.65889907",
"0.65432143",
"0.649853",
"0.6391254",
"0.6331525",
"0.61915946",
"0.6183542",
"0.6161192",
"0.6077309",
"0.60569197",
"0.60550284",
"0.60549605",
"0.60524046",
"0.6028754",
"0.6028754"... | 0.72757894 | 0 |
DELETE /admin/funcionarios/1 DELETE /admin/funcionarios/1.json | def destroy
@funcionario = Funcionario.find(params[:id])
@funcionario.destroy
respond_to do |format|
format.html { redirect_to admin_funcionarios_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html... | [
"0.7615027",
"0.75380266",
"0.75115776",
"0.7438658",
"0.72932506",
"0.72602683",
"0.71821505",
"0.7181262",
"0.71102595",
"0.7028232",
"0.70054305",
"0.69871664",
"0.6977697",
"0.6964186",
"0.6955146",
"0.6945944",
"0.6925926",
"0.6918656",
"0.6911894",
"0.6911062",
"0.69109... | 0.7802818 | 0 |
For instance, the length of "it's" is 3, not 4. | def cleanup(str)
str.gsub(/[^a-z]/i, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length() end",
"def length() end",
"def length() end",
"def length() end",
"def length (string)\n string.length\nend",
"def length(*) end",
"def length(*) end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def le... | [
"0.79631144",
"0.79631144",
"0.79631144",
"0.79631144",
"0.76128656",
"0.76070416",
"0.76070416",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.75748956",
"0.75212896",
"0.7482235",
"0.7388497",
"0.729291",
"0.72819704",
"0.7230... | 0.0 | -1 |
def create got these from classmate if password_match? | def show
@tweet = Tweet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def valid_password?; end",
"def password_required?; end",
"def before_create\n\t\tself.password = Hospede.hash_password(self.password)\n\tend",
"def password\n end",
"d... | [
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7064864",
"0.6986145",
"0.69516623",
"0.69409496",
"0.69409496",
"0.693235",
"0.68655133",
"0.68538094",
"0.68538094",
"0.68538094",
"0.68538094",
"0.679734",
"0.6766183",
"0.6753463",
"0.6722922... | 0.0 | -1 |
POST assign/:assignee_type/:assignee_id/to/:assign_to_type POST assign/course/1/to/exam | def form_path
@form_path ||= admin_create_assignment_path(
assignee_type, assignee_id, assign_to_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teacher_assign\n @course_allocation = CourseAllocation.find_by_course_id(params[:id])\n @course = Course.find(params[:id])\n @teachers = get_teachers_for_institute\n end",
"def create\n @assignment = @course.assignments.new(params[:assignment])\n @assignment.save\n @outline = Outline.where... | [
"0.63647693",
"0.62411124",
"0.61490613",
"0.61308014",
"0.6057582",
"0.60494936",
"0.6043505",
"0.6018424",
"0.59534115",
"0.5935091",
"0.5928154",
"0.5867691",
"0.5839717",
"0.5799333",
"0.5797168",
"0.5792861",
"0.5787273",
"0.5773743",
"0.57600313",
"0.574604",
"0.5721076... | 0.0 | -1 |
used in the views so need to sanitize | def sanitize_assignment_type t
t if valid_assignment_types.include? t
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize!; end",
"def validate_and_sanitize\n super\n end",
"def sanitize_content\n self.title = helpers.sanitize(self.title)\n self.user_name = helpers.sanitize(self.user_name)\n end",
"def filter_content \n\t\tself.title = ActionView::Base.full_sanitizer.sanitiz... | [
"0.7518306",
"0.7235429",
"0.7052768",
"0.69793564",
"0.6878666",
"0.6756486",
"0.6658044",
"0.6658044",
"0.6622884",
"0.6558522",
"0.64755964",
"0.6451672",
"0.64195645",
"0.6410674",
"0.6391797",
"0.6379697",
"0.6378053",
"0.6340761",
"0.6340761",
"0.6261128",
"0.6248769",
... | 0.0 | -1 |
This method probably exists for the wrong reason. E.g. handle params coming in in the URL or in the body of the POST request in a flexible fashion. | def int_param key, fallback_key
Integer params[key]
rescue ArgumentError, TypeError
field = "#{fallback_key}_id"
begin
Integer params[:education_assignment][field]
rescue NoMethodError
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def POST\r\n@env[\"action_dispatch.request.request_parameters\"] ||= (normalize_encode_params(super) || {})\r\nrescue TypeError => e\r\nraise ActionController::BadRequest.new(:request, e)\r\nend",
"def valid_params_request?; end",
"def params\n self.GET.update(self.POST)\n rescue EOFError => boom\n ... | [
"0.70598954",
"0.6979006",
"0.6829557",
"0.633713",
"0.6224963",
"0.62221104",
"0.61546314",
"0.6130512",
"0.6014339",
"0.59544444",
"0.5952795",
"0.59401673",
"0.59335905",
"0.59034073",
"0.5890737",
"0.5887199",
"0.5868058",
"0.5862783",
"0.58559465",
"0.5847388",
"0.584588... | 0.0 | -1 |
Returns the square of the sum of the first +n+ natural numbers | def square_of_sums
return (@n * (@n + 1) / 2)**2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end",
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def sum_up_to_squared n=100\r\n (2 * n + 1) * (n +... | [
"0.8386006",
"0.7973424",
"0.79434913",
"0.7864936",
"0.78023165",
"0.765812",
"0.76429236",
"0.7633945",
"0.7561177",
"0.75412804",
"0.75055015",
"0.74811",
"0.7475553",
"0.7463038",
"0.74529445",
"0.74393106",
"0.74113595",
"0.73868793",
"0.73721236",
"0.73595667",
"0.73349... | 0.83127034 | 1 |
Returns the sum of the squares of the first +n+ natural numbers | def sum_of_squares
return @n * (@n + 1) * (2 * @n + 1) / 6
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end",
"def sum_of_squares n\n (n**3)/3 + (n*... | [
"0.8337079",
"0.8165778",
"0.815824",
"0.7973656",
"0.78558964",
"0.7807768",
"0.7765323",
"0.77374494",
"0.7673717",
"0.7672474",
"0.76360095",
"0.76251656",
"0.75980556",
"0.75475436",
"0.7546374",
"0.75056887",
"0.7453837",
"0.73923033",
"0.7390996",
"0.7387779",
"0.736797... | 0.8000374 | 3 |
Returns the difference between square_of_sums and sum_of_squares | def difference
return square_of_sums - sum_of_squares
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference\n square_of_sums - sum_of_squares\n end",
"def difference\n square_of_sums - sum_of_squares\n end",
"def difference\n # square of sums will always be bigger\n square_of_sum - sum_of_squares\n end",
"def difference\n square_of_sum - sum_of_squares\n end",
"def difference_be... | [
"0.88599145",
"0.88599145",
"0.847743",
"0.84173274",
"0.8035531",
"0.7716437",
"0.7547347",
"0.7444694",
"0.7390223",
"0.738993",
"0.73312473",
"0.731875",
"0.7318639",
"0.72615135",
"0.7210095",
"0.71972185",
"0.7183927",
"0.71701443",
"0.7145418",
"0.71305215",
"0.7115464"... | 0.88109684 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_atendimento
@atendimento = Atendimento.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def atendimento_params
params.require(:atendimento).permit(:nr_protocolo, :nm_contato, :tp_retorno, :ds_retorno, :cliente_id, :atendimento_id, :motivo_id, :submotivo_id, :status, :equipamento_id, :rua, :nr_endereco, :bairro, :cidade, :cep, :uf, :lat, :long, :resolucao_id, :dt_fechamento, :obs, :created_by, :updated_by)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
GET /ways GET /ways.json | def index
@ways = Way.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ways_using_node(id)\n api_call(id, \"node/#{id}/ways\")\n end",
"def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end",
"def show\n @ways... | [
"0.69018334",
"0.66725165",
"0.664601",
"0.6622051",
"0.65638196",
"0.63588375",
"0.63127786",
"0.6286787",
"0.6250313",
"0.6243861",
"0.6131232",
"0.61146474",
"0.6103763",
"0.6084988",
"0.60843223",
"0.60350144",
"0.6010627",
"0.598401",
"0.59624785",
"0.5940741",
"0.584865... | 0.71732 | 0 |
GET /ways/1 GET /ways/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ways = Way.all\n end",
"def show\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subway }\n end\n end",
"def show\n @railway = Railway.find(params[:id])\n\n respond_to do |format|\n forma... | [
"0.69644386",
"0.68596375",
"0.6820406",
"0.6747265",
"0.67084944",
"0.664971",
"0.6613311",
"0.6463421",
"0.6420012",
"0.6353054",
"0.6175955",
"0.6164993",
"0.6103839",
"0.6012172",
"0.6005579",
"0.5953195",
"0.5948694",
"0.5923862",
"0.5913849",
"0.5913074",
"0.5909131",
... | 0.0 | -1 |
POST /ways POST /ways.json | def create
@way = Way.new(way_params)
respond_to do |format|
if @way.save
format.html { redirect_to @way, notice: 'Way was successfully created.' }
format.json { render :show, status: :created, location: @way }
else
format.html { render :new }
format.json { render json: @way.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @order_way = OrderWay.new(order_way_params)\n\n respond_to do |format|\n if @order_way.save\n format.html { redirect_to @order_way, notice: 'Order way was successfully created.' }\n format.json { render :show, status: :created, location: @order_way }\n else\n forma... | [
"0.67839986",
"0.6742594",
"0.6700332",
"0.66208863",
"0.6590533",
"0.6566288",
"0.63995945",
"0.6309827",
"0.6180557",
"0.60790014",
"0.5970307",
"0.5951881",
"0.59408665",
"0.59136873",
"0.58563167",
"0.58475304",
"0.58260286",
"0.58092076",
"0.5804434",
"0.5792486",
"0.577... | 0.7276052 | 0 |
PATCH/PUT /ways/1 PATCH/PUT /ways/1.json | def update
respond_to do |format|
if @way.update(way_params)
format.html { redirect_to @way, notice: 'Way was successfully updated.' }
format.json { render :show, status: :ok, location: @way }
else
format.html { render :edit }
format.json { render json: @way.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n if @subway.update_attributes(params[:subway])\n format.html { redirect_to @subway, notice: 'Subway was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\"... | [
"0.6564012",
"0.65603477",
"0.6373927",
"0.6373873",
"0.632334",
"0.6319039",
"0.62574214",
"0.6180161",
"0.6136139",
"0.60556453",
"0.60521275",
"0.6022372",
"0.60013413",
"0.59669256",
"0.5899495",
"0.58886904",
"0.5870361",
"0.58481485",
"0.5842066",
"0.58115643",
"0.57975... | 0.6766084 | 0 |
DELETE /ways/1 DELETE /ways/1.json | def destroy
@way.destroy
respond_to do |format|
format.html { redirect_to ways_url, notice: 'Way was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_pathway\n pathway = Pathway.find(params[:pathway_par])\n current_user.pathways.delete(pathway)\n if current_user.pathways.size < 1\n respond_to do |format|\n format.html { redirect_to '/saved#pathways' }\n format.json { head :no_content }\n end\n end\n end",
"def d... | [
"0.74076796",
"0.73946935",
"0.7356026",
"0.73158926",
"0.7299793",
"0.72144616",
"0.707968",
"0.7048751",
"0.6914441",
"0.68450266",
"0.6755857",
"0.6713121",
"0.6710341",
"0.6634281",
"0.65777314",
"0.65441906",
"0.65349644",
"0.6505535",
"0.6494423",
"0.64901334",
"0.64865... | 0.7384067 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_way
@way = Way.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def way_params
params.require(:way).permit(:vertices_list, :edges_list, :total_distance, :total_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
Detect if an address is IPv4 or IPv6 | def detect_ipvers(address)
if address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
:ipv4
elsif address =~ /\h{0,4}::?\h{1,4}/i
:ipv6
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipv6_address?(addr)\n return true if addr =~ /:/\n return false\n end",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def ipv4?\n self.kind_of? IPAddress::IPv4\n end",
"def ipv4?\n self.kind_of? IPAddress::IPv4\n end"... | [
"0.8162605",
"0.78093964",
"0.78093964",
"0.74765307",
"0.74765307",
"0.7452555",
"0.7430677",
"0.73560476",
"0.7283809",
"0.7238633",
"0.723357",
"0.7224835",
"0.71691257",
"0.71456313",
"0.7126125",
"0.7116245",
"0.71144",
"0.7030418",
"0.701316",
"0.69777775",
"0.6954711",... | 0.7560409 | 3 |
Return an array of addresses that match either IPv4 or IPv6 | def select_ipvers(addresses, ipvers)
addresses = [addresses] unless addresses.is_a?(Array)
addresses.select {|addr| detect_ipvers(addr) == ipvers}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ips\n regex = /\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/\n all_ips = Socket.ip_address_list.map(&:inspect_sockaddr)\n all_ips.select { |ip| !!ip.match(regex) }\n end",
"def prefer_ipv4(addresses)\n return nil unless addresses.is_a?(Array)\n\n addresses.find { |ip| IPAddress.val... | [
"0.7007296",
"0.6620668",
"0.6585659",
"0.6305265",
"0.6299838",
"0.6291751",
"0.62632895",
"0.6225902",
"0.6219659",
"0.6203125",
"0.61873966",
"0.6162141",
"0.6161072",
"0.6157057",
"0.61059684",
"0.60777915",
"0.6075467",
"0.6042411",
"0.6035033",
"0.60247725",
"0.5990672"... | 0.58278465 | 33 |
Return an array of addresses from 1 or more aliases that match either IPv4 or IPv6 | def resolve_alias(addresses, ipvers)
addresses = [addresses] unless addresses.is_a?(Array)
result = []
addresses.each do |address|
if address =~ /^([\w\-]+)$/
if aliases[address]
result += select_ipvers(aliases[address], ipvers)
else
raise "Alias is not defined: #{address}"
end
else
result += select_ipvers(address, ipvers)
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getaddresses(name)\n return [name] if ADDRESS_REGEX.match(name)\n @resolvers.each do |resolver|\n addresses = []\n resolver.each_address(name) { |address| addresses << address }\n return addresses unless addresses.empty?\n end\n []\n end",
"def extract_addresses(address_list)\n a... | [
"0.65996414",
"0.64940137",
"0.64407414",
"0.6321463",
"0.6306254",
"0.62178785",
"0.6201579",
"0.6173752",
"0.61470044",
"0.6053043",
"0.60380906",
"0.5973963",
"0.5969093",
"0.59667933",
"0.59415346",
"0.5933625",
"0.5881579",
"0.5879615",
"0.58582234",
"0.58507216",
"0.581... | 0.70776016 | 0 |
Convert ruby object into VyOS port string | def port_string(input)
if input
port = if input.is_a?(Array)
input.join(',')
elsif input.is_a?(Range)
"#{input.min}-#{input.max}"
else
input.to_s
end
yield(port)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port_string; end",
"def to_s\n\t\t\t\"#{host}:#{port}\"\n\t\tend",
"def to_s\n [@host, @rpc_port].join(':')\n end",
"def to_s\n if @bridge_port == true\n \"Bridge: [#{@port_name}, #{@remote_switch_name}, #{@remote_port_name}, #{@remote_port_number}]\"\n else\n \"Std Port: [#{@port... | [
"0.7103363",
"0.6500296",
"0.6476261",
"0.6378679",
"0.61832774",
"0.6174617",
"0.6174617",
"0.61323726",
"0.6003181",
"0.6001421",
"0.5948682",
"0.59344494",
"0.59115684",
"0.58142847",
"0.57360333",
"0.5689222",
"0.566903",
"0.56652516",
"0.5646701",
"0.56444305",
"0.563249... | 0.51701885 | 84 |
This endpoint allows to recommend a new member to airlines. | def create_recommend_a_new_member(body)
# Prepare query url.
_path_url = '/v1/airline/members/'
_query_builder = Configuration.get_base_uri
_query_builder << _path_url
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'accept' => 'application/json',
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: body.to_json
)
_context = execute_request(_request)
validate_response(_context)
# Return appropriate response type.
decoded = APIHelper.json_deserialize(_context.response.raw_body)
NewMemberResponse.from_hash(decoded)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n add_plan_to_user_if_specified!\n \n format.html { redirect_to(@member, :notice => 'Member was successfully created.') }\n format.json { render :json => @member, :status => :crea... | [
"0.5646906",
"0.5532538",
"0.54985344",
"0.5403972",
"0.5386378",
"0.53768337",
"0.53394663",
"0.533649",
"0.530887",
"0.5281685",
"0.52663296",
"0.5258725",
"0.52580065",
"0.52475876",
"0.5243645",
"0.52206445",
"0.520511",
"0.51992065",
"0.5196027",
"0.5191123",
"0.51868737... | 0.70048314 | 0 |
This endpoint allows to search a member on the airline system. | def create_member_search(body)
# Prepare query url.
_path_url = '/v1/airline/members/actions/search'
_query_builder = Configuration.get_base_uri
_query_builder << _path_url
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'accept' => 'application/json',
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: body.to_json
)
_context = execute_request(_request)
validate_response(_context)
# Return appropriate response type.
decoded = APIHelper.json_deserialize(_context.response.raw_body)
MemberSearchResponse.from_hash(decoded)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\n @members = Member.search_by params[:category], params[:keywords], params[:is_active]\n\n render :template => '/api/members/index'\n end",
"def search_members(query, options = {})\n get search_path(\"members\"), options.merge(query: query)\n end",
"def index\n @search = Member... | [
"0.67855644",
"0.6548864",
"0.6258896",
"0.6216999",
"0.6200944",
"0.61297095",
"0.60450435",
"0.6024119",
"0.6001982",
"0.60001326",
"0.594357",
"0.592639",
"0.59210527",
"0.5875939",
"0.5861792",
"0.5850032",
"0.5848564",
"0.5846454",
"0.5837113",
"0.5830175",
"0.58282036",... | 0.6971287 | 0 |
sets the artist to the artist of the specified name | def artist_name=(name)
self.artist = Artist.find_or_create_by(name: name)
self.artist = artist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artist_name=(name)\n # The actual assignment of the artist \"michael jackson\"\n # to the Song instance variable occurs in the .add_song \n # method in the Artist class.\n Artist.find_or_create_by_name(name).add_song(self)\n end",
"def artist_name=(name)\n self.artist = Arti... | [
"0.8631267",
"0.8611113",
"0.8611113",
"0.8611113",
"0.8611113",
"0.85706115",
"0.856181",
"0.856181",
"0.85435855",
"0.85435855",
"0.85272115",
"0.8488491",
"0.84813833",
"0.84587324",
"0.8446932",
"0.84012806",
"0.84012806",
"0.83807606",
"0.8320474",
"0.8320474",
"0.832047... | 0.84776556 | 13 |
returns the artist name | def artist_name
self.try(:artist).try(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artist_name\n artist.name if artist\n end",
"def artist_name\n \tif self.artist\n \t\tself.artist.name\n \tend\n end",
"def artist_name\n if self.artist\n artist.name\n else\n nil\n end\n end",
"def artist_name\n if self.artist #if song has an artist aka TRUE\n s... | [
"0.91012186",
"0.89411527",
"0.88850105",
"0.8867165",
"0.88493973",
"0.87633175",
"0.8716061",
"0.8660438",
"0.85772765",
"0.85396004",
"0.85396004",
"0.85396004",
"0.85396004",
"0.85040027",
"0.84704375",
"0.84464973",
"0.8440832",
"0.84110284",
"0.83617705",
"0.83224064",
... | 0.8032889 | 26 |
sets the genre to the genre of the specified name | def genre_name=(name)
self.genre = Genre.find_or_create_by(name: name)
self.genre = genre
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre... | [
"0.8453164",
"0.831982",
"0.831982",
"0.831982",
"0.79601127",
"0.7695125",
"0.76474917",
"0.76370174",
"0.7627474",
"0.7627474",
"0.7572217",
"0.74475527",
"0.74475527",
"0.73975426",
"0.7343262",
"0.73291606",
"0.7328257",
"0.7328257",
"0.7308729",
"0.7294673",
"0.7277976",... | 0.85104114 | 0 |
returns the genre name | def genre_name
self.try(:genre).try(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genre_name\n \tif self.genre\n \t\tself.genre.name\n \tend\n end",
"def genre_name\n # self.genre.name\n self.genre ? self.genre.name : ''\n end",
"def get_genre_name\n self.genre.name\n end",
"def genre_name\n self.genre ? self.genre.name : nil\n end",
"def genre_name\n ... | [
"0.9001444",
"0.87545544",
"0.8408421",
"0.8308149",
"0.8308149",
"0.81577224",
"0.79171693",
"0.77513546",
"0.77513546",
"0.77349544",
"0.77349544",
"0.77349544",
"0.7684306",
"0.760172",
"0.75620425",
"0.75557655",
"0.7473183",
"0.7376065",
"0.7169484",
"0.7165394",
"0.7124... | 0.7522001 | 17 |
sets notes for a song adds to existing notes | def note_contents=(notes)
notes.each do |content|
if content.strip != '' # => ignores blank notes
self.notes.build(content: content)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def notes_attributes=(notes)\n notes.each do |note|\n song_note = self.notes.build(co... | [
"0.8257639",
"0.8257639",
"0.74261457",
"0.688843",
"0.68704",
"0.6726616",
"0.6726616",
"0.6726616",
"0.6726616",
"0.6656985",
"0.65901464",
"0.65844625",
"0.65485257",
"0.64999527",
"0.64490795",
"0.6421435",
"0.6409109",
"0.6406017",
"0.6294751",
"0.62918633",
"0.62842435"... | 0.6491131 | 14 |
returns the content of all notes as an array | def note_contents
self.notes.map(&:content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def note_contents\n self.notes.each.map{|note| note.content}\n end",
"def note_contents\n self.notes.collect do |note|\n note.content\n end\n end",
"def note_contents\n self.notes.collect {|note| note.content }\n end",
"def note_contents\n self.notes.collect {|note|... | [
"0.86408603",
"0.83662134",
"0.8366155",
"0.8317342",
"0.7816864",
"0.7816864",
"0.7816864",
"0.7816864",
"0.7488828",
"0.7403367",
"0.73726386",
"0.73456764",
"0.73196155",
"0.72838736",
"0.72627854",
"0.72289383",
"0.7018001",
"0.70014006",
"0.69167584",
"0.69167584",
"0.67... | 0.85840327 | 2 |
then, the method will print: "a", "b", "c", "ab", "bc", "abc" if the input string is "abcd", then, the method will print: "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd" | def print_combinations(str)
return if !str || str.length == 0
str_length = str.length
char_count = 1
while char_count <= str_length
start_index = 0
print_current(start_index, char_count, str, str_length)
char_count += 1
end
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def StringReduction(str)\n until str.split(\"\").uniq.length == 1\n str = str.sub(/ab|ba/, \"c\").\n sub(/ac|ca/, \"b\").\n sub(/cb|bc/, \"a\")\n end\n str.size \nend",
"def find_all_combos(str=[\"\"],arr={})\n if str.length == 1\n return str\n end\n i = 0\n #ite... | [
"0.65881073",
"0.639427",
"0.6373545",
"0.635229",
"0.62963796",
"0.6280881",
"0.62718064",
"0.62551165",
"0.6203235",
"0.6180908",
"0.61791754",
"0.61758715",
"0.61511016",
"0.6150229",
"0.61201406",
"0.6106661",
"0.6102503",
"0.6101571",
"0.61008465",
"0.61001694",
"0.60783... | 0.6488588 | 1 |
Assemble one file job | def initialize(filename, report=false)
@binary = []
@report = []
@source = filename
@labels = {}
@addr = 0
assmeble(report)
generate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_job\n if Backdat::Config[:json].empty?\n Backdat::Config[:json] = File.absolute_path(\"#{@first}/.backdat\")\n end\n job_config = parse_dotfile\n run_job\n end",
"def execute!\n my_temp_file = Tempfile.new(\"jobler_test\")\n\n create_result!(name: \"my-file\", temp_file: my_t... | [
"0.6498386",
"0.6254218",
"0.6228784",
"0.61883307",
"0.6140876",
"0.6118147",
"0.60959375",
"0.60785794",
"0.6068447",
"0.59853154",
"0.5975939",
"0.59707206",
"0.5914611",
"0.59037477",
"0.58763385",
"0.57887536",
"0.576253",
"0.5754528",
"0.574257",
"0.57199246",
"0.570337... | 0.0 | -1 |
Process argument, return register code if arg is like R0,R1 or AX,FLAG. Else if arg is a defined label, then returns it's address. If it is a integer, just read and parse to the caller. Otherwise it must be a undefined lebel, feel free to return nil. process_argument("123h") porcess_argument("R0") process_argument("start") | def process_argument(arg)
return REG[arg] if REG.has_key?(arg)
return EREG[arg] if EREG.has_key?(arg)
return SREG[arg] if SREG.has_key?(arg)
return @labels[arg] if @labels.has_key?(arg)
return arg.to_i(16) if arg =~ /^\d*[Hh]$/
return arg.to_i(10) if arg =~ /^\d*[Dd]+$/
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_argument(arg)\n case arg\n when *@mapping[:http_request] then set_mode(:http_request)\n when *@mapping[:source] then set_mode(:source)\n when *@mapping[:http_status] then set_mode(:http_status)\n when *@mapping[:timestamp] then set_mode(:timestamp) \n wh... | [
"0.65264785",
"0.64714813",
"0.646577",
"0.6157773",
"0.57950747",
"0.57208675",
"0.5696529",
"0.55878943",
"0.5484339",
"0.5467529",
"0.5372045",
"0.5369584",
"0.53099304",
"0.52562016",
"0.5234169",
"0.5228411",
"0.5122328",
"0.51144767",
"0.51029444",
"0.5077223",
"0.50710... | 0.78632027 | 0 |
Generate the required signature as specified by unionpay official document it returns the signature string | def generate_signature
sha1x16 = Digest::SHA1.hexdigest(signed_string)
.tap { |s| logger.debug "sha1x16 #{s}" }
enc = case form_fields['signMethod']
when '01' # 01 means RSA
merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16)
.tap { |s| logger.debug "enc #{s}" }
else # at current time (2015-05-25) no other signing method is mentioned in Unionpay's official docs
raise "sign method #{form_fields['signMethod']} is not implemented yet."
end
Base64.strict_encode64(enc) # has to be strict_encode64, not encode64, as the latter as an extra '\n'
.tap { |s| logger.debug "final: #{s}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_signature(string_to_sign)\n digest = OpenSSL::Digest.new('sha256')\n OpenSSL::HMAC.hexdigest(digest, @api_secret, string_to_sign)\n end",
"def generate_signature\n digest = OpenSSL::Digest.new('sha256')\n string_to_sign = \"#{@url_path}?#{sorted_parameters_query}\"\n ... | [
"0.72814804",
"0.72706914",
"0.7163797",
"0.7154344",
"0.7073618",
"0.70271796",
"0.6941081",
"0.6893011",
"0.6892118",
"0.687593",
"0.68695897",
"0.6845367",
"0.6824029",
"0.68158877",
"0.6784177",
"0.6784177",
"0.6780259",
"0.6761523",
"0.67099506",
"0.6697454",
"0.6692018"... | 0.80659693 | 0 |
Generate the string to sign on from all in from_fields. Currently Unionpay doc specifies that the fields are arranged alphabetically | def signed_string
signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) }
signed_data_only.sort.collect { |s| "#{s[0]}=#{s[1]}" }.join('&')
.tap { |ss| logger.debug "signed string is #{ss}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_field_names\n @signed_fields.join(',')\n end",
"def build_form_string(fields)\n return nil if fields.nil?\n tmp = []\n fields.each{|k,v|\n tmp << \"#{k.to_s}=#{v.to_s}\"\n }\n tmp.join(\"&\")\n end",
"def build_order_string(fields, mode=\"ASC\... | [
"0.5991405",
"0.5496816",
"0.54908687",
"0.54765916",
"0.5473576",
"0.54252845",
"0.54252845",
"0.54045486",
"0.53803265",
"0.5350425",
"0.528696",
"0.5247209",
"0.52301115",
"0.5228437",
"0.51992196",
"0.51936996",
"0.516909",
"0.5140548",
"0.51370764",
"0.5126734",
"0.50654... | 0.5750741 | 1 |
Return and Notify do not have 'form_fields' defined yet it's needed for the signed_string method | def form_fields
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_string\n signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) }\n signed_data_only.sort.collect { |s| \"#{s[0]}=#{s[1]}\" }.join('&')\n .tap { |ss| logger.debug \"signed string is #{ss}\" }\n end",
"def signing_input; end",
"def signin... | [
"0.71437633",
"0.6932859",
"0.6932859",
"0.64043474",
"0.64043474",
"0.63532674",
"0.6196729",
"0.6192886",
"0.61652654",
"0.61143655",
"0.61014444",
"0.60939246",
"0.6086866",
"0.6086866",
"0.60786575",
"0.60775405",
"0.606628",
"0.60344094",
"0.59105015",
"0.59105015",
"0.5... | 0.0 | -1 |
Returns a new TextInjector that injects context using the specified header key | def initialize(correlation_context_key: 'otcorrelations')
@correlation_context_key = correlation_context_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header\n @header ||= HeaderController.new config\n end",
"def text_injector\n TEXT_INJECTOR\n end",
"def match_header(key)\n @env[key.upcase.tr(\"-\",\"_\")]\n end",
"def inject_headers!(obj)\n procid = obj[:options][:header]\n if procid && header_proc = head... | [
"0.5000711",
"0.4993099",
"0.48815724",
"0.4871315",
"0.47960123",
"0.4789204",
"0.4723824",
"0.46729827",
"0.46440515",
"0.46383604",
"0.46351716",
"0.46245736",
"0.46235472",
"0.4620351",
"0.45772737",
"0.45549497",
"0.4548138",
"0.45458016",
"0.45453897",
"0.4530776",
"0.4... | 0.0 | -1 |
Inject inprocess correlations into the supplied carrier. | def inject(carrier, context, &setter)
return carrier unless (correlations = context[ContextKeys.correlation_context_key]) && !correlations.empty?
setter ||= default_setter
setter.call(carrier, @correlation_context_key, encode(correlations))
carrier
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject(carrier, context = Context.current, &setter)\n @injectors.inject(carrier) do |memo, injector|\n injector.inject(memo, context, &setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in CompositePropagator#inject #{e.... | [
"0.7050875",
"0.6734479",
"0.65621763",
"0.63016534",
"0.5946533",
"0.5832985",
"0.57912904",
"0.57182926",
"0.5652006",
"0.56405365",
"0.5390068",
"0.5379433",
"0.52942514",
"0.52912015",
"0.5278401",
"0.52620333",
"0.52503556",
"0.5047367",
"0.5037935",
"0.49455997",
"0.492... | 0.7411865 | 0 |
Returns true if the target_modules == :all, or contains the module_name in the collection. | def can_use(module_name)
target_is_all? or target_includes? module_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def includes_modules?\n @includes_modules\n end",
"def has_modules?\n m = @context.modules.find{|m| m.document_self}\n m ? true : false\n end",
"def matchRequirement?(modules)\n modules.nil? or modules.all? {|mod| has_key?(mod)}\n end",
"def has_all?\n @privileges.fetch(@tar... | [
"0.6894316",
"0.67173016",
"0.64719355",
"0.6443027",
"0.61643624",
"0.6153314",
"0.61509633",
"0.6099001",
"0.60466856",
"0.6044615",
"0.6032038",
"0.59916",
"0.5949316",
"0.581328",
"0.5784757",
"0.5727358",
"0.56976223",
"0.569",
"0.56809425",
"0.5649306",
"0.5649306",
"... | 0.7839998 | 0 |
display_board Should accept a board as an argument and print out the current state of the board for the user. | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"---+----+----\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"---+----+----\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@boa... | [
"0.8053142",
"0.7945663",
"0.7925305",
"0.7919637",
"0.7912888",
"0.7889378",
"0.7876681",
"0.78522366",
"0.78499115",
"0.7849138",
"0.7849138",
"0.78220224",
"0.78220034",
"0.7816811",
"0.78103936",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0... | 0.80963767 | 1 |
valid_move? Should accept a board and an index from the user and return true if the index is within the correct range of 08 and is currently unoccupied by an X or O token. | def valid_move?(board, index)
if position_taken?(board, index) == true; false
#elsif board[index] == "X" || board[index] == "O"; true
elsif index > 9 || index < 0; false
else; true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(board, index)\n if index.between?(0,8) && board[index] != \"X\" && board[index] != \"O\"\n re... | [
"0.8912906",
"0.8912906",
"0.8848799",
"0.884805",
"0.8837264",
"0.88332653",
"0.8832149",
"0.88317454",
"0.88235754",
"0.88234216",
"0.88234216",
"0.88234216",
"0.8816482",
"0.881642",
"0.8814303",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.8807... | 0.87682986 | 40 |
Hint: While not explicitly required by this lab, you might want to encapsulate the logic to check if a position is occupied in its own method, perhaps position_taken? | def position_taken?(board, index)
if board[index] == " " || board[index] == "" || board[index] = nil
false
else
true
#board[index] == "X" || board[index] == "O"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?\nend",
"def position_taken?(board,index)\n #This method must take in both the existing board and the index that the user\n #is trying to fill if the index is already occupied it will not allow this\n position_value=board[index]\n if position_value != nil\n if position_value.include? \"... | [
"0.7775009",
"0.7709548",
"0.7581044",
"0.7484805",
"0.7454599",
"0.74466985",
"0.7444623",
"0.74328506",
"0.7427627",
"0.74262154",
"0.74106264",
"0.73990303",
"0.7393684",
"0.7393684",
"0.7373324",
"0.7373167",
"0.7366633",
"0.736648",
"0.7349871",
"0.7325485",
"0.73241043"... | 0.0 | -1 |
=> [["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "land", "land", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "land", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "... world is a two dimensional array of subarrays. The above representation sets out the array in a way that makes it easy for a human to understand it in terms of map coordinates. Each row in the above is a subarray of elements. The y argument identifies which subarray we want, i.e. the relevant row in the above grid, meaning y is equivalent to a y coordinate, reading from top to bottom with the first row being 0 on the y axis. The x argument identifies which element INSIDE the subarray we want, i.e. the relevant column in the above grid, meaning x is equivalent to an x coordinate. | def continent_size world, x, y
if world[y][x] != 'land' # => false, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true
# Either it's water or we already counted it,
# but either way, we don't want to count it now.
return 0 # => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
end
# So first we count this tile...
size = 1 # => 1, 1, 1
world[y][x] = 'counted land' # => "counted land", "counted land", "counted land"
# Each time the program his a tile marked 'land' it updates that tile
# so it is no longer 'land' but 'counted land', meaning the next time the
# program hits that tile it will no longer be equal to 'land' and therefore
# is not double counted.
# ...then we count all of the neighboring eight tiles
# (and, of course, their neighbors by way of the recursion).
#
# The best way to think of this is that each time the program hits a land tile
# it starts spiraling around that tile until it finds another land tile and
# each time it finds another land tile it starts again from that second land tile
# and so on and son on until it has counted all the land tiles and their neighbors
# that joined the starting tile.
#
size = size + continent_size(world, x-1, y-1) # => 1, 1, 1
size = size + continent_size(world, x , y-1) # => 1, 1, 1
size = size + continent_size(world, x+1, y-1) # => 1, 1, 1
size = size + continent_size(world, x-1, y ) # => 1, 1, 3
size = size + continent_size(world, x+1, y ) # => 1, 1, 3
size = size + continent_size(world, x-1, y+1) # => 1, 1, 3
size = size + continent_size(world, x , y+1) # => 1, 2, 3
size = size + continent_size(world, x+1, y+1) # => 1, 2, 3
size # => 1, 2, 3
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_arrays\n squares = []\n org_row = 0\n org_col = 0\n (0..8).each do |i|\n squares[i] = []\n (org_row..org_row+2).each do |k|\n (org_col..org_col+2).each do |j|\n squares[i].push(@board[k][j])\n end \n end\n if org_row == 6\n ... | [
"0.6215395",
"0.61178416",
"0.60820067",
"0.6050977",
"0.6038105",
"0.6018902",
"0.5964021",
"0.59452164",
"0.59341425",
"0.59038216",
"0.58844256",
"0.5871454",
"0.58675534",
"0.5864965",
"0.5849842",
"0.58264965",
"0.5806505",
"0.5793865",
"0.5757738",
"0.5743406",
"0.57412... | 0.0 | -1 |
A collection of Drip objects associated with a given `Caffeinate::Dripper` | def drips
drip_collection.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dripper\n ::Caffeinate.dripper_collection.resolve(self)\n end",
"def trips\n RideShare::Trip.find_all_for_rider(@id)\n end",
"def rider_trip_instances\n rider_trips = RideShare::Trip.all_rider_trip_instances(@rider_id)\n return rider_trips\n end",
"def trips\n Trip.fi... | [
"0.66506803",
"0.62345374",
"0.6022168",
"0.5945111",
"0.5814769",
"0.57565314",
"0.5748462",
"0.5720995",
"0.5689172",
"0.5657983",
"0.56344426",
"0.56202114",
"0.55891573",
"0.5557003",
"0.55509233",
"0.5521626",
"0.5521104",
"0.55117655",
"0.5487773",
"0.54855525",
"0.5485... | 0.6384552 | 1 |
Register a drip on the Dripper drip :mailer_action_name, mailer_class: "MailerClass", step: 1, delay: 1.hour | def drip(action_name, options = {}, &block)
drip_collection.register(action_name, options, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pickup_scheduled(pickup_id)\n @pickup = Pickup.find(pickup_id)\n @greeting = \"Hi\"\n\n mail(to: \"#{@pickup.name} <#{@pickup.email}>\", subject: 'Your eCycle pickup is scheduled')\n end",
"def send_delayed_validation_email\n #get delayed time\n delayed_time = self.time + 1.hour + 45.minutes\... | [
"0.6321469",
"0.6197253",
"0.6181021",
"0.61545885",
"0.6006346",
"0.5985085",
"0.59707755",
"0.594062",
"0.59278595",
"0.58693933",
"0.58402133",
"0.5823704",
"0.5821306",
"0.57948583",
"0.5769678",
"0.5755207",
"0.5719841",
"0.5719841",
"0.57052875",
"0.56909907",
"0.568201... | 0.5681568 | 21 |
def add_config inject_into_file "config/application.rb", :after => "config.action_view.javascript_expansions" do "config.action_view.javascript_expansions[:defaults] << %w(advanced_scaffold)" end | def create_model
template 'model.rb', "app/models/#{model_path}.rb" unless @skip_model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_config_options_to_initializer\n devise_initializer_path = \"config/initializers/devise.rb\"\n if File.exist?(devise_initializer_path)\n old_content = File.read(devise_initializer_path)\n\n if old_content.match(Regexp.new(/^\\s# ==> Configuration for :trialable\\n/))\n ... | [
"0.59380436",
"0.59212387",
"0.58798695",
"0.5854152",
"0.57930183",
"0.57082844",
"0.5589193",
"0.55627906",
"0.5518282",
"0.55145055",
"0.55059355",
"0.54718477",
"0.5461053",
"0.5457171",
"0.544894",
"0.54344183",
"0.5431317",
"0.54296803",
"0.54124874",
"0.5404428",
"0.53... | 0.0 | -1 |
Method to build a list of instruments | def buildInstrumentList(baseDir)
entries = Dir[baseDir + "/*"]
@instrList = Array.new
entries.each do |entry|
if !entry.eql?(".") && !entry.eql?("..") &&
File::directory?(entry)
@instrList << entry.slice(/[a-zA-Z0-9]+$/).to_s
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instruments\n return @instruments if defined? @instruments\n\n reset_instruments!\n end",
"def create_instr_specs()\n instr_specs = []\n INSTR_DEFS.each do |instr_def|\n\tinstr_specs <<= extract_spec(instr_def)\n end\n instr_specs\nend",
"def generate_instruments(valor, c... | [
"0.6578174",
"0.6343721",
"0.62469006",
"0.60823303",
"0.599287",
"0.5890327",
"0.58779263",
"0.583078",
"0.57019126",
"0.56427205",
"0.56415254",
"0.5570522",
"0.5557859",
"0.5485976",
"0.54788524",
"0.54648286",
"0.5464344",
"0.54270726",
"0.5403116",
"0.53950113",
"0.53821... | 0.6426889 | 3 |
Find flowcells for which analysis is not yet started. Read the directory listing under the instrument directory, compare directories against the list of completed flowcells and find the directories (flowcells) that are new. | def findNewFlowcells()
@newFC = Array.new
dirList = Dir.entries(@instrDir)
dirList.each do |dirEntry|
if !dirEntry.eql?(".") && !dirEntry.eql?("..") &&
File::directory?(@instrDir + "/" + dirEntry) &&
isAvailableForCleaning(@instrDir + "/" + dirEntry)
@newFC << dirEntry
puts dirEntry.slice(/[0-9A-Za-z]+$/).gsub(/^[AB]/, "") + " " + @instrDir + "/" + dirEntry
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findNewFlowcells()\n @newFC = Array.new\n\n dirList = Dir.entries(@instrDir)\n\n dirList.each do |dirEntry|\n if !dirEntry.eql?(\".\") && !dirEntry.eql?(\"..\") &&\n File::directory?(@instrDir + \"/\" + dirEntry) &&\n !@fcList.key?(dirEntry.strip)\n @newFC << dirEntry\n ... | [
"0.7384019",
"0.7383591",
"0.5291802",
"0.51977974",
"0.519609",
"0.5167115",
"0.51391",
"0.5094661",
"0.5057069",
"0.5057069",
"0.5047378",
"0.5021727",
"0.5009236",
"0.50038844",
"0.49701357",
"0.4964281",
"0.49566543",
"0.4933121",
"0.49323624",
"0.49286696",
"0.49044466",... | 0.7258376 | 2 |
Method to determine if a flowcell can be cleaned or not. For a flowcell to be cleaned, all of the following conditions must be true : 1) Marker file ".rsync_finished" must be present 2) It must have been modified 20 days ago (i.e. 1728000 seconds earlier) 3) The flowcell must not have been cleaned earlier (i.e., it must have L001 through L008 directories in its Data/Intensities directory | def isAvailableForCleaning(fcName)
markerName = fcName + "/.rsync_finished"
if File::exist?(markerName)
modTime = File::mtime(markerName)
timeDiff = (Time.now- modTime)
intensityLaneDir = fcName + "/Data/Intensities/L00*"
intensityLaneDir = Dir[fcName + "/Data/Intensities/L00*"]
# If intensitiy directory has directories L001 through L008 and
# modification time of .rsync_finished is 20 days (i.e. 1728000 seconds)
# that flowcell is available for cleaning.
# Please note: To change the interval of when a flowcell becomes a
# candidate flowcell for cleaning, please change the number below.
if intensityLaneDir != nil && intensityLaneDir.length > 0 && (timeDiff > 1728000)
return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fcReady?(fcName)\n if File::exist?(@instrDir + \"/\" + fcName + \"/.rsync_finished\")\n return true\n end\n \n if fcName.match(/SN601/) || fcName.match(/SN166/) \n puts \"Flowcell \" + fcName + \" is not configured for automatic analysis\"\n return false\n end\n\n # If the mar... | [
"0.6459014",
"0.61789834",
"0.6173833",
"0.57643414",
"0.5756706",
"0.56445915",
"0.5590954",
"0.554623",
"0.5523257",
"0.55117345",
"0.5488111",
"0.54705775",
"0.54400265",
"0.5393438",
"0.53783447",
"0.5327384",
"0.5319959",
"0.5294783",
"0.5291879",
"0.52897424",
"0.528745... | 0.77530825 | 0 |
Return true if the user's password matches the submitted password. | def has_password?(submitted_password)
# Compare encrypted_password with the encrypted version of
# submitted_password.
encrypted_password == encrypt(submitted_password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matching_password?(pass)\n self.password_hash == encrypt_password(pass)\n end",
"def has_password?(submitted_password)\n password == encrypt(submitted_password)\n end",
"def password_match? password\n\t\tBCrypt::Password.new(@password) == password\n\tend",
"def passwords_match?\n context.user.... | [
"0.8485361",
"0.83525056",
"0.8315177",
"0.83141565",
"0.8279726",
"0.82433754",
"0.821651",
"0.821651",
"0.8204761",
"0.81947446",
"0.81943554",
"0.8180314",
"0.8180314",
"0.81543386",
"0.8150993",
"0.81353897",
"0.8129398",
"0.8129398",
"0.81292814",
"0.81292814",
"0.812928... | 0.79240835 | 58 |
GET /troubles GET /troubles.json | def index
set_search_troubles
@variable_trouble = Trouble.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @problems = Problem.all\n\n render json: @problems\n end",
"def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end... | [
"0.6914684",
"0.64868885",
"0.6422672",
"0.63073707",
"0.6295702",
"0.6295702",
"0.6295702",
"0.6285203",
"0.6158924",
"0.6093062",
"0.5966853",
"0.5966853",
"0.59652627",
"0.5953674",
"0.59529537",
"0.59241974",
"0.5901176",
"0.58958864",
"0.5867919",
"0.58045363",
"0.580178... | 0.5796422 | 21 |
POST /troubles POST /troubles.json | def create
@variable_trouble = Trouble.new(trouble_params)
respond_to do |format|
if @variable_trouble.save
flash[:success] = 'トラブルを追加しました'
format.html { redirect_to troubles_url }
else
set_search_troubles
flash[:danger] = 'トラブル追加に失敗しました'
format.html { render :index }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trouble_params\n params.require(:trouble).permit(:name, :url, :solution, :status_id, :category_id, :user_id)\n end",
"def create\n @problem = Problem.new(problem_params)\n\n if @problem.save\n render json: @problem, status: :created, location: @problem\n else\n render json: @proble... | [
"0.62379307",
"0.6224483",
"0.5897463",
"0.58892846",
"0.588561",
"0.5864274",
"0.5863429",
"0.5823895",
"0.57829446",
"0.5765519",
"0.57513356",
"0.57098365",
"0.5709618",
"0.56485784",
"0.56097573",
"0.5588947",
"0.55829775",
"0.55620325",
"0.55547756",
"0.55421436",
"0.553... | 0.5890337 | 3 |
PATCH/PUT /troubles/1 PATCH/PUT /troubles/1.json | def update
respond_to do |format|
if @variable_trouble.update(trouble_params)
flash[:success] = 'トラブルを更新しました'
format.html { redirect_to troubles_url }
format.json { render :show, status: :ok, location: @trouble }
else
set_search_troubles
flash[:danger] = 'トラブル更新に失敗しました'
format.html { render :edit }
format.json { render json: @trouble.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @problem = Problem.find(params[:id])\n\n if @problem.update(problem_params)\n head :no_content\n else\n render json: @problem.errors, status: :unp... | [
"0.61565197",
"0.6118787",
"0.6118581",
"0.61094546",
"0.60861963",
"0.60642135",
"0.6036091",
"0.6034049",
"0.6034049",
"0.6034049",
"0.6002611",
"0.59443915",
"0.5921111",
"0.59197736",
"0.589512",
"0.5892983",
"0.58820117",
"0.58804244",
"0.5850145",
"0.58493286",
"0.58485... | 0.5504445 | 61 |
DELETE /troubles/1 DELETE /troubles/1.json | def destroy
@variable_trouble.destroy
respond_to do |format|
flash[:danger] = 'トラブルを削除しました'
format.html { redirect_to troubles_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mistake = Mistake.find(params[:id])\n @mistake.destroy\n\n respond_to do |format|\n format.html { redirect_to mistakes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to pro... | [
"0.7169323",
"0.7005562",
"0.69641334",
"0.69164264",
"0.69087666",
"0.69050944",
"0.68755704",
"0.6863204",
"0.6863204",
"0.6863204",
"0.6863204",
"0.68540335",
"0.6846601",
"0.6824922",
"0.6821377",
"0.6793374",
"0.6787306",
"0.6785399",
"0.6785399",
"0.6762854",
"0.6744673... | 0.6533346 | 58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.