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
POST /leaf_spot_imm_searches POST /leaf_spot_imm_searches.json
def create @leaf_spot_imm_search = LeafSpotImmSearch.new(leaf_spot_imm_search_params) respond_to do |format| if @leaf_spot_imm_search.save format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully created.' } format.json { render :show, status: :created, location: @leaf_spot_imm_search } else format.html { render :new } format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @leaf_spot_imm_searches = LeafSpotImmSearch.all\n end", "def leaf_spot_imm_search_params\n params.require(:leaf_spot_imm_search).permit(:search_id, :leaf_spot_imm_id)\n end", "def set_leaf_spot_imm_search\n @leaf_spot_imm_search = LeafSpotImmSearch.find(params[:id])\n end", "d...
[ "0.716472", "0.70289606", "0.6843638", "0.5995051", "0.5925393", "0.5724561", "0.56819296", "0.5668447", "0.56587774", "0.5597701", "0.55376047", "0.5479734", "0.54553634", "0.5434269", "0.5424556", "0.5416983", "0.5416606", "0.5392421", "0.53834224", "0.5374588", "0.5364401"...
0.6925797
2
PATCH/PUT /leaf_spot_imm_searches/1 PATCH/PUT /leaf_spot_imm_searches/1.json
def update respond_to do |format| if @leaf_spot_imm_search.update(leaf_spot_imm_search_params) format.html { redirect_to @leaf_spot_imm_search, notice: 'Leaf spot imm search was successfully updated.' } format.json { render :show, status: :ok, location: @leaf_spot_imm_search } else format.html { render :edit } format.json { render json: @leaf_spot_imm_search.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_leaf_spot_imm_search\n @leaf_spot_imm_search = LeafSpotImmSearch.find(params[:id])\n end", "def leaf_spot_imm_search_params\n params.require(:leaf_spot_imm_search).permit(:search_id, :leaf_spot_imm_id)\n end", "def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n...
[ "0.6511506", "0.6430987", "0.593413", "0.5877458", "0.5822385", "0.5667287", "0.5568403", "0.55408686", "0.5534161", "0.54694426", "0.5451681", "0.54371697", "0.54137814", "0.539564", "0.5387593", "0.5346209", "0.53414595", "0.5297225", "0.526672", "0.52615017", "0.52585065",...
0.7513949
0
DELETE /leaf_spot_imm_searches/1 DELETE /leaf_spot_imm_searches/1.json
def destroy @leaf_spot_imm_search.destroy respond_to do |format| format.html { redirect_to leaf_spot_imm_searches_url, notice: 'Leaf spot imm search was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: DELETE_SUCCESS }\n format.json { head :no_content }\n end\n end", "def destroy\n @advance_search.destroy\n respond_to do |format|\n format.html { redirect_to advance_searches_url }\n...
[ "0.6636038", "0.6626745", "0.6483126", "0.6445629", "0.6438108", "0.6425712", "0.64251727", "0.6358157", "0.63345337", "0.63231456", "0.6321574", "0.6321574", "0.6321574", "0.6321574", "0.6321574", "0.6316388", "0.6258293", "0.6256212", "0.62497807", "0.6242029", "0.6236143",...
0.7589751
0
Use callbacks to share common setup or constraints between actions.
def set_leaf_spot_imm_search @leaf_spot_imm_search = LeafSpotImmSearch.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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def leaf_spot_imm_search_params params.require(:leaf_spot_imm_search).permit(:search_id, :leaf_spot_imm_id) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
GET /festivals/1/films/1 GET /festivals/1/films/1.xml
def show @film = @festival.films.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @film } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @fam = Fam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @fam }\n end\n end", "def show\n @film = Film.published.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { re...
[ "0.6422294", "0.5945609", "0.58748734", "0.5871135", "0.58684886", "0.57827955", "0.5766279", "0.57577723", "0.57332265", "0.57319516", "0.572501", "0.571337", "0.57076037", "0.56797373", "0.5678734", "0.56785995", "0.56589586", "0.56578887", "0.56469846", "0.56448746", "0.56...
0.72963136
0
GET /festivals/1/films/new GET /festivals/1/films/new.xml
def new @film = @festival.films.new respond_to do |format| format.html { raise NonAjaxEditsNotSupported } format.js # new.rjs format.xml { render :xml => @film } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @fam = Fam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fam }\n end\n end", "def new\n @feat = @person.feats.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feat }\n end\n ...
[ "0.70557725", "0.6827975", "0.664286", "0.66235065", "0.65458953", "0.6537541", "0.64939666", "0.64841455", "0.64806056", "0.6450843", "0.6450843", "0.64481574", "0.6440349", "0.64398605", "0.6430357", "0.641874", "0.64111334", "0.64075786", "0.640542", "0.6377793", "0.635061...
0.68759835
1
POST /festivals/1/films POST /festivals/1/films.xml
def create @film = @festival.films.new(params[:film]) @saved = @film.save respond_to do |format| format.html { raise NonAjaxEditsNotSupported } format.js if @saved format.xml { render :xml => @film, :status => :created, :location => @film } else format.xml { render :xml => @film.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @fam = Fam.new(params[:fam])\n\n respond_to do |format|\n if @fam.save\n flash[:notice] = 'Fam was successfully created.'\n format.html { redirect_to(@fam) }\n format.xml { render :xml => @fam, :status => :created, :location => @fam }\n else\n format.html {...
[ "0.6207764", "0.5970602", "0.5744422", "0.5744422", "0.56854284", "0.5611808", "0.56021523", "0.5564345", "0.54632294", "0.54605484", "0.5451148", "0.54456246", "0.53912866", "0.53912276", "0.53831565", "0.5380625", "0.53759617", "0.5354884", "0.5345772", "0.53380185", "0.527...
0.63393736
0
PUT /festivals/1/films/1 PUT /festivals/1/films/1.xml
def update @film = @festival.films.find(params[:id]) @updated = @film.update_attributes(params[:film]) respond_to do |format| format.html { raise NonAjaxEditsNotSupported } format.js # update.rjs if @updated format.xml { head :ok } else format.xml { render :xml => @film.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @fam = Fam.find(params[:id])\n\n respond_to do |format|\n if @fam.update_attributes(params[:fam])\n flash[:notice] = 'Fam was successfully updated.'\n format.html { redirect_to(@fam) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edi...
[ "0.6519106", "0.6207139", "0.62046474", "0.6149017", "0.60566956", "0.6034293", "0.60188466", "0.59054023", "0.5810741", "0.5789958", "0.57750154", "0.57720196", "0.57038635", "0.5689641", "0.56299114", "0.56247145", "0.5614178", "0.5607249", "0.5601533", "0.5598347", "0.5594...
0.6404152
1
DELETE /festivals/1/films/1 DELETE /festivals/1/films/1.xml
def destroy @film = @festival.films.find(params[:id]) @film.destroy respond_to do |format| format.html { raise NonAjaxEditsNotSupported } format.js # destroy.rjs format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @fam = Fam.find(params[:id])\n @fam.destroy\n\n respond_to do |format|\n format.html { redirect_to(fams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.f...
[ "0.6787344", "0.666118", "0.6406267", "0.6400847", "0.6380219", "0.6380219", "0.6354462", "0.6349836", "0.6324378", "0.629916", "0.6294409", "0.6254232", "0.62495023", "0.6228882", "0.62284726", "0.62264764", "0.6221851", "0.6198549", "0.61904335", "0.61827904", "0.61825156",...
0.61859465
19
Because I don't have a database, need to read listings from a file
def load_resources Listing @resources = YAML::load(File.open('listings.yml')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readList # read the list file and return an array\n array_list = []\n i = 0\n File.open(\"list.txt\").readlines.each do |line|\n array_list[i] = line\n i += 1\n end\n array_list\nend", "def load_list filename\n\tlist = []\n\tbegin\n\t\topen filename do |f|\n\t\t\tuntil (line = f.gets).nil?\n\t\t\t...
[ "0.6520914", "0.6483409", "0.6466084", "0.64653945", "0.6465354", "0.63598293", "0.6344077", "0.6321655", "0.62903386", "0.62736374", "0.62287223", "0.6196735", "0.6188961", "0.61673975", "0.6163015", "0.61499304", "0.61460894", "0.6123204", "0.6123204", "0.60856074", "0.6077...
0.5468776
84
Look up a matching handler for the line and process it The process method on a handler always returns a Contexts object
def parse_line line, contexts line = line.encode Encoding::UTF_8 if encode_lines? handler = handler_for_line line handler.process line, contexts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle(line)\n parsed = parse(line)\n return unless parsed\n\n handle_parsed(parsed)\n end", "def process_line(line)\n if (@custom_processor && @custom_processor.class.method_defined?(:process_line))\n @custom_processor.process_line line\n else\n line.split ' '\n ...
[ "0.6575301", "0.6278986", "0.60873467", "0.5979731", "0.5973956", "0.59736633", "0.59658754", "0.5962331", "0.5956132", "0.5916274", "0.5835513", "0.5824703", "0.5763471", "0.57351506", "0.56787103", "0.55791795", "0.55451995", "0.552181", "0.55182767", "0.55119985", "0.54861...
0.67651904
0
Delete whitespace and regions
def clean_up_data(rows) rows.delete_if { |row| row.any? { |value| value.length < 3 } } # Remove headers and trailing header rows.delete_at(0) rows.delete_at(-1) rows end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_leading_and_trailing_whitespace(text)\n pre_blocks = text.split(DO_NOT_TOUCH_WHITESPACE)\n\n output = []\n pre_blocks.each.with_index do |block, index|\n if index % 2 == 0\n output << block.gsub(/[ \\t]*\\n[ \\t]*/im, \"\\n\").gsub(/ *\\t */im, \"\\t\")\n ...
[ "0.6816816", "0.67972803", "0.6764195", "0.67106396", "0.6649246", "0.6648069", "0.6604431", "0.6501035", "0.644495", "0.6427563", "0.64252424", "0.64028466", "0.63701874", "0.6314949", "0.6307267", "0.62857145", "0.62492645", "0.6239386", "0.6222667", "0.6220087", "0.6203872...
0.0
-1
def create_hashes(rows) headers = ["name", "capacity", "storage"] hashes = rows.map do |row| Hash[headers.zip(row)] end hashes end Write to file
def csv_writer(rows) headers = ["name", "capacity", "storage"] CSV.open("reservoir_data.csv", 'w') do |csv| csv << headers rows.each do |row| csv << row end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def machine_hash(headers,rows)\n # This is just to give a nice data structure (a hash of )\n rows.each_with_index.map do |row, index|\n # todo - rearrange the hash so it is sorted - do we need the row index?\n Hash[headers.each_with_index.map { |header, pos| \n [header, row[pos] ]}\n ]....
[ "0.71236014", "0.6468792", "0.6459042", "0.6358782", "0.628336", "0.6224471", "0.6188475", "0.61865014", "0.614731", "0.61054206", "0.60396963", "0.60146755", "0.59880847", "0.59871787", "0.59838164", "0.5963479", "0.5943188", "0.59374887", "0.5872913", "0.5847528", "0.582373...
0.65567064
1
whites start at bottom
def initialize(pos, grid, color, king = false) @pos = pos @color = color @grid = grid @king = king end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position \n end", "def move_to_bottom\n # return unless in_list?\n acts_as_list_class.transaction do\n decrement_positions_on_lower_items if in_list?\n assume_botto...
[ "0.6748228", "0.6548339", "0.65188503", "0.65147936", "0.65145797", "0.6507956", "0.64927566", "0.64678925", "0.63840663", "0.6339344", "0.6335653", "0.63092655", "0.6239952", "0.6122511", "0.6122511", "0.6063986", "0.60565126", "0.60489583", "0.6044544", "0.60318583", "0.594...
0.0
-1
how can i clean this up, get rid of need to check that the slide is valid twice?
def perform_moves!(move_sequence) if move_sequence.count == 1 if perform_slide?(move_sequence[0]) perform_slide(move_sequence[0]) else perform_jump(move_sequence[0]) end else move_sequence.each do |move| perform_jump(move) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slide\n slides.first rescue nil\n end", "def test_truth\n assert_kind_of Slide, slides(:first)\n end", "def valid_slide?(color)\n player_pieces(color).any?{ |piece| piece.valid_slides.any? }\n end", "def validate_cover\n errors.add(:position, :cover_must_be_first_slide) if self.kind == COV...
[ "0.6200143", "0.61274326", "0.6084023", "0.60409975", "0.60064477", "0.5999631", "0.5921774", "0.59066194", "0.5903091", "0.5901312", "0.5900295", "0.58976007", "0.58689755", "0.5809254", "0.58059675", "0.58017987", "0.57822216", "0.5775066", "0.5774184", "0.57466114", "0.565...
0.0
-1
come back and refactor this... logic a little messy
def possible_jumps pos_jumps = [ ] row, col = @pos move_diffs.each do |row_change, col_change| jumped_piece = [row + row_change, col + col_change] new_position = [row + (row_change * 2), (col + col_change * 2)] unless @grid[jumped_piece].nil? || @grid[jumped_piece].color == @color pos_jumps << new_position end end pos_jumps end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def anchored; end", "def suivre; end", "def schubert; end", "def checks; end", "def operations; end", "def operations; end", "def offences_by; end", "def formation; end", "def post_match() end", "def processor; end", "def the_lineup #in short, this re...
[ "0.5846858", "0.5635316", "0.55140984", "0.5512021", "0.54703", "0.52831966", "0.5269533", "0.5269533", "0.52375257", "0.52201587", "0.5207385", "0.51988256", "0.51130545", "0.50949156", "0.50364864", "0.50364864", "0.5022084", "0.5016035", "0.50055736", "0.50055736", "0.5005...
0.0
-1
GET /guards/1 GET /guards/1.xml
def show @guard = Guard.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @guard } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @guardian = Guardian.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @guardian }\n end\n end", "def show\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xm...
[ "0.5788277", "0.57758784", "0.57613766", "0.57572806", "0.57301974", "0.56725246", "0.5670936", "0.5670066", "0.5657093", "0.5628463", "0.5618517", "0.5616494", "0.559104", "0.5576799", "0.556168", "0.55555737", "0.5518697", "0.5512807", "0.55050904", "0.55013466", "0.5493536...
0.60650074
0
GET /guards/new GET /guards/new.xml
def new @guard = Guard.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @guard } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compliance }\n end\n end", "def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider }\n end\n end", "def...
[ "0.69041663", "0.6827875", "0.6790674", "0.6775494", "0.6773475", "0.67727506", "0.6768087", "0.6756935", "0.67148274", "0.6694192", "0.6648209", "0.6644479", "0.6644479", "0.6644479", "0.6644299", "0.66318166", "0.6611558", "0.66030514", "0.6597194", "0.65963095", "0.6596309...
0.71009535
0
POST /guards POST /guards.xml
def create @guard = Guard.new(params[:guard]) respond_to do |format| if @guard.save flash[:notice] = 'Guard was successfully created.' format.html { redirect_to(@guard) } format.xml { render :xml => @guard, :status => :created, :location => @guard } else format.html { render :action => "new" } format.xml { render :xml => @guard.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_save_advice\r\n \r\n post :save_advice, :id => @Questionnaire, :advice => { \"1\"=> { :advice => \"test\" } } \r\n \r\n assert_response :redirect\r\n assert_equal \"The questionnaire's question advice was successfully saved\", flash[:notice]\r\n assert_redirected_to :action => 'list'\...
[ "0.5406219", "0.5316001", "0.5180328", "0.51626474", "0.5150757", "0.5144402", "0.5136275", "0.50968206", "0.50630915", "0.5048071", "0.50398743", "0.5002049", "0.49935716", "0.49922383", "0.49887684", "0.4979475", "0.4959973", "0.49582654", "0.4932153", "0.4920405", "0.49183...
0.48875394
23
PUT /guards/1 PUT /guards/1.xml
def update @guard = Guard.find(params[:id]) respond_to do |format| if @guard.update_attributes(params[:guard]) flash[:notice] = 'Guard was successfully updated.' format.html { redirect_to(@guard) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @guard.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n ...
[ "0.5905561", "0.5754443", "0.5661206", "0.5576061", "0.55624217", "0.55200994", "0.5447036", "0.5308832", "0.5258701", "0.52486163", "0.52459127", "0.52223533", "0.51879245", "0.51745313", "0.51508856", "0.5147677", "0.5139272", "0.51369625", "0.51262873", "0.51022166", "0.50...
0.5285048
8
DELETE /guards/1 DELETE /guards/1.xml
def destroy @guard = Guard.find(params[:id]) @guard.destroy respond_to do |format| format.html { redirect_to(guards_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @guarantor = Guarantor.find(params[:id])\n @guarantor.destroy\n applicant=Applicant.find(@guarantor.applicant_id)\n respond_to do |format|\n format.html { redirect_to(applicant, :notice => 'Guarantor deleted.') }\n format.xml { head :ok }\n end\n end", "def delete()\n ...
[ "0.636203", "0.6321088", "0.6265856", "0.62530905", "0.6244561", "0.6178069", "0.6176648", "0.6153654", "0.61462575", "0.6127529", "0.6124317", "0.60945207", "0.60943735", "0.6070501", "0.6039952", "0.6032935", "0.6011977", "0.6008153", "0.6003945", "0.59994155", "0.59917456"...
0.66825676
0
Problem Suppose an array A consists of n elements, each of which is red, white or blue. We seek to sort the elements so that all the reds come before all the whites, which come before all the blues. The only operation permitted on the keys are: Examine(A, i) report the color of the ith element of A Swap(A, i , j) swap the ith element of A with the jth element. Find a correct and efficient algorithm for redwhiteblue sorting. There is a linear time solution. End This algorithm can be solved using the Dutch National Flag Algorithm where the array would needed to be divided into subsections (reds,mids, unknowns and blues). In one pass of the array we keep track of 3 positions, where the last red is, where the last white is and where the last blue is. When traversing over the array we use the mid(white) index as our position. When the value at mid is red we swap the value at the current red index with the mid index and increase both indices. When the value is the mid(white) we simply increase the mid and move on When the value is equal to the high(red) we swap the value with the value at the red index and decrement the red index. Given 0 = red, 1 = white, 2 = blue t
def three_way_partition(array) lo = 0 mid = 0 hi = array.size - 1 while mid <= hi val = array[mid] case val when 0 array[lo], array[mid] = array[mid],array[lo] lo += 1 mid += 1 when 1 mid += 1 when 2 array[mid], array[hi] = array[hi], array[mid] hi -= 1 end end array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_by_color(array)\n colors = [:red, :blue, :yellow]\n i = 0\n j = 1\n 0.upto(array.size - 1) do\n break if j > array.size - 1\n if array[i][1] != :red && array[j][1] == :red \n array[i], array[j] = array[j], array[i]\n i += 1\n end\n j += 1\n end\n \n # i is now at the position ...
[ "0.79806346", "0.711194", "0.6523694", "0.6167179", "0.61610234", "0.60550654", "0.6015937", "0.5930779", "0.5900443", "0.58585835", "0.58548653", "0.58542633", "0.5813449", "0.5801417", "0.5764387", "0.57517904", "0.57509303", "0.57396793", "0.5736663", "0.5730018", "0.57164...
0.0
-1
Examples: account.authenticated?(:confirmation, 'confirmation_token') account.authenticated?(:remember, 'remember_token') account.authenticated?(:reset_password, 'reset_password_token')
def authenticated?(attribute, token) digest = self.try("#{attribute}_digest") return false if digest.nil? ::BCrypt::Password.new(digest) == token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_authenticated?\n basic_authenticated? || token_authenticated?\n end", "def authenticated?\n true\n end", "def is_authenticated?\n end", "def authenticated?\n authentication.authenticated?\n end", "def authenticated?\n @authenticated\n end", "def authenticated?\n ...
[ "0.75272405", "0.7406296", "0.7386397", "0.73764074", "0.73453337", "0.73453337", "0.7252854", "0.7242171", "0.7122058", "0.7122058", "0.7122058", "0.7042444", "0.70382786", "0.70010877", "0.69914687", "0.6961681", "0.6961681", "0.6954723", "0.6925081", "0.6917218", "0.690810...
0.0
-1
return all roles related with self and self account_groups
def all_roles _role_ids_ = (account_groups.map(&:role_ids) + role_ids).flatten.uniq Role.where(id: _role_ids_) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_roles\n result = Array.new\n \n# for role in self.roles\n# result << role.ancestors_and_self\n# end\n \n for group in self.groups\n result << group.all_roles\n end\n \n result.flatten!\n result.uniq!\n \n return result\n end", "def roles\n groups.find(:all, :cond...
[ "0.739752", "0.7090536", "0.68356854", "0.66487414", "0.6629416", "0.6606212", "0.6347266", "0.63248616", "0.6312422", "0.62840325", "0.62070054", "0.61775064", "0.6159339", "0.6139426", "0.6110836", "0.61017835", "0.6078071", "0.6049364", "0.60354936", "0.60335445", "0.60307...
0.7625081
0
Construct a series of arguments.
def build_args(prefix = nil, args) pre = prefix ? prefix + " " : "" args.inject("") {|str, arg| str << pre + arg + " "} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def args\n n = self.num_args\n a = []\n n.times { |i|\n a.push Arg::new(self, i)\n }\n return a\n end", "def args\n n = self.num_args\n a = []\n n.times { |i|\n a.push Arg::new(self, i)\n }\n return a\n end", "def addArgs(vals); vals.each { ...
[ "0.6552697", "0.6552697", "0.6494469", "0.6454489", "0.63808215", "0.63703585", "0.63653284", "0.63653284", "0.6253949", "0.6226967", "0.6204987", "0.61643344", "0.6131809", "0.61165804", "0.6111379", "0.610955", "0.6026722", "0.601024", "0.5974691", "0.5974691", "0.5963202",...
0.624742
9
Append to an option.
def append_option(key, *value) @options[key] = ((@options[key] || []) + [value]).flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_option(option)\n @options += [option]\n end", "def addOption(option)\n\t\t@list.last.merge!(option)\n\tend", "def add_option(choice, *args, &block)\n self.options << choice\n self.builder.add_choice(choice, *args, &block)\n end", "def append_opt(opt)\n if opt.name == :dhcp_messa...
[ "0.8213087", "0.7177456", "0.71597177", "0.71308154", "0.68898356", "0.68823177", "0.67696524", "0.6692969", "0.6630291", "0.66029876", "0.6599891", "0.6581243", "0.6559765", "0.6517126", "0.6511164", "0.64537925", "0.64380985", "0.64332277", "0.6340348", "0.6288536", "0.6261...
0.77726835
1
Adjust a list of files to include the path to the test file.
def adjust(files) files.map { |file| @options[:path] + "/" + file } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_files=(list)\n @test_files = list\n end", "def add_files(*files)\n @source_paths &= files\n end", "def expanded_file_list\n test_files = Rake::FileList[pattern].compact\n test_files += @test_files.to_a if @test_files\n test_files\n end", "def test_files\n fil...
[ "0.6746312", "0.6739699", "0.664375", "0.649044", "0.64880854", "0.6390702", "0.61977226", "0.6128834", "0.6110002", "0.6014145", "0.6010524", "0.6001569", "0.59968156", "0.59964406", "0.58759105", "0.5849682", "0.58485955", "0.5846049", "0.58370394", "0.5774988", "0.5763194"...
0.7261856
0
For all responses in this controller, return the CORS access control headers.
def cors_set_access_control_headers headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' headers['Access-Control-Max-Age'] = "1728000" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response_headers(env)\n cors_origin(env) ? cors_headers(env) : {}\n end", "def cors_set_access_control_headers\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Expose-Headers'] = 'ETag'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'...
[ "0.76200086", "0.76057684", "0.76057684", "0.7502795", "0.7487873", "0.74259764", "0.7410305", "0.740784", "0.7405322", "0.7395", "0.739231", "0.7384529", "0.73775524", "0.73729867", "0.73729867", "0.73729867", "0.73599845", "0.73512226", "0.7333351", "0.7333351", "0.72869694...
0.72364885
37
If this is a preflight OPTIONS request, then shortcircuit the request, return only the necessary headers and return an empty text/plain.
def cors_preflight_check if request.method == :options headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version' headers['Access-Control-Max-Age'] = '1728000' render :text => '', :content_type => 'text/plain' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_options\n head(:ok) if request.request_method == \"OPTIONS\"\n end", "def cors_preflight_check\n if request.method == 'OPTIONS'\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'\n headers['Access-Control-Allow-...
[ "0.7614249", "0.7467578", "0.7409435", "0.7409435", "0.7308112", "0.7288653", "0.7264328", "0.72398067", "0.7235166", "0.72183186", "0.721749", "0.7214403", "0.71994877", "0.7199308", "0.7199308", "0.7199308", "0.71798396", "0.71593463", "0.7152738", "0.7152525", "0.71361864"...
0.7212929
17
configure Config object with subject class and various options
def initialize subject_class, options = {} raise ArgumentError, "The first argument must be the Class which is the subject of the behavior" unless subject_class.is_a?(Class) @subject_class = subject_class apply_options! options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config(subject)\n @self_config ||= self.config_class.find_by(subject: subject, key: self.key)\n end", "def subject_config(subject)\n get \"/config/#{subject}\"\n end", "def update_subject_config(subject, config)\n put \"/config/#{subject}\", { body: config.to_json }\n en...
[ "0.7216634", "0.6767596", "0.66828066", "0.66447127", "0.66356665", "0.6619825", "0.66095585", "0.65970194", "0.64984816", "0.64481497", "0.64149266", "0.6414321", "0.6414321", "0.6414321", "0.6414321", "0.6414321", "0.64114696", "0.64114696", "0.64114696", "0.64099354", "0.6...
0.0
-1
Call setter for each key/value pair
def apply_options! options = {} options.each_pair do |key, value| send("#{key}=", value) if self.respond_to?(:"#{key}=") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set(fields)\n case self[:value]\n when Proc\n fields.send \"#{self[:key]}=\", self[:value].call(nil)\n else\n attr = if self[:key].to_s.end_with?('?')\n self[:key].to_s[0..-2]\n else\n self[:key]\n ...
[ "0.7077602", "0.70014846", "0.70014846", "0.68610924", "0.6782143", "0.67506045", "0.6735641", "0.66050345", "0.6535287", "0.648141", "0.64715016", "0.64432395", "0.6421955", "0.6417616", "0.64083165", "0.6399381", "0.6390345", "0.63867944", "0.63718235", "0.6368263", "0.6359...
0.0
-1
Configure subject with behavior First apply any remaining options needed Then configure models if configured to do do
def configure! options = {} apply_options! options configure_models if auto_config?(:models) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure\n return quick_join if !join_model\n [subject_model, object_model, join_model].compact.each do |model| \n model.configure\n end \n end", "def configure\n create_belongs_to :subject, class_name_option(:subject)\n create_belongs_to :object, class_name_option(:o...
[ "0.6979871", "0.62139076", "0.61475646", "0.61191726", "0.59010214", "0.5784482", "0.577737", "0.57525873", "0.57525873", "0.56635594", "0.5619064", "0.5619064", "0.5594302", "0.5436158", "0.5397122", "0.53866965", "0.5383661", "0.53133905", "0.5290292", "0.5242534", "0.52417...
0.66698515
2
get the auto configuration settings hash
def auto_config @auto_config ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hash()\n\t\t\treturn @config.clone()\n\t\tend", "def to_hash\n self.config.to_hash\n end", "def to_hash\n configuration\n end", "def to_h\n config\n end", "def to_hash\n @configuration\n end", "def to_hash\n @configuration\n end", "def to_hash...
[ "0.7673606", "0.6931116", "0.6875609", "0.6811018", "0.67586315", "0.67586315", "0.6700916", "0.6697547", "0.6598611", "0.6598611", "0.6586555", "0.6524824", "0.6505437", "0.6505437", "0.64553523", "0.64501005", "0.64300865", "0.64193916", "0.6415477", "0.6407492", "0.6402535...
0.7256648
2
is a certain type of auto configuration enabled?
def auto_config? name return auto_config[name] if !auto_config[name].nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config\n mode == \"autoinst_config\"\n end", "def configured?\n true\n end", "def configured?; false; end", "def configuration?\n get_mode.to_s.include?('config')\n end", "def auto_config? name\n return auto_config[name] if !auto_config[name].nil?\n Troles::Con...
[ "0.7918839", "0.73479337", "0.7234662", "0.71866626", "0.71792614", "0.6892769", "0.689206", "0.6886087", "0.685284", "0.6741846", "0.6737845", "0.6735295", "0.6599472", "0.6599472", "0.65645564", "0.6540362", "0.65352446", "0.6523569", "0.65149254", "0.64861846", "0.64832115...
0.7429825
1
Get the main field name that is used for the behavior added, fx :troles for roles behavior
def main_field @main_field ||= begin default_main_field end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_field_name\n\t\tend", "def field_name\n @field.name\n end", "def field_name\r\n @field_name ||= begin\r\n %r/(\\w+)Field$/.match(name)[1]\r\n rescue\r\n %r/(\\w+)$/.match(name)[1]\r\n end\r\n end", "def field_name\n self.class.name.split(\"::\").last.downc...
[ "0.69857955", "0.6906255", "0.66457266", "0.6534383", "0.6374389", "0.63659745", "0.6336275", "0.6332047", "0.63004225", "0.6297585", "0.6293652", "0.628871", "0.6254938", "0.6191561", "0.6181366", "0.61638266", "0.61638266", "0.61586624", "0.6156493", "0.6156493", "0.61371",...
0.0
-1
Set the main field of the behavior
def main_field= field_name name = field_name.to_s.alpha_numeric.to_sym raise ArgumentException, "Not a valid field name: #{field_name}" if !valid_field_name?(name) @main_field ||= name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_field\n @main_field ||= begin\n default_main_field\n end\n end", "def main_field\n @main_field ||= begin\n default_main_field\n end\n end", "def configure_field\n end", "def configure_field\n end", "def set_display(widget) \n @main_widget ...
[ "0.6121511", "0.6121511", "0.5920789", "0.5870191", "0.54317486", "0.54254335", "0.5371921", "0.53626394", "0.5290675", "0.52900124", "0.5288204", "0.52789694", "0.5273231", "0.52376795", "0.51954526", "0.51890117", "0.5157922", "0.51543725", "0.51472825", "0.51383656", "0.51...
0.50327665
39
get the orm name
def orm @orm || self.class.default_orm end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orm\n @orm ||= :none\n end", "def name\n @db_name\n end", "def orm\n if @orm\n return @orm\n else\n self.orm = ENV['ORM']\n end\n @orm\n end", "def orm\n @orm ||= begin\n if defined?(ActiveRecord::Base) && ActiveRecord::Base.connected? && S...
[ "0.7173224", "0.712456", "0.69726235", "0.6966767", "0.677164", "0.66634834", "0.6635984", "0.6625153", "0.65889144", "0.65889144", "0.6560384", "0.6560384", "0.65079117", "0.6498855", "0.6463175", "0.64550096", "0.6430718", "0.642821", "0.6414036", "0.6414004", "0.6411984", ...
0.7326106
1
is it a generic strategy/orm ?
def generic? return true if orm.nil? || orm == :generic @generic.nil? ? false : @generic end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orm; end", "def alchemy\r\n end", "def strategy; end", "def generic?; true; end", "def single_object_db; end", "def prerecord(klass, name); end", "def use_prepared_statements_for?(type)\n if defined?(super)\n result = super\n return result unless result.nil?\n ...
[ "0.67086446", "0.6680326", "0.62374544", "0.6004661", "0.59786105", "0.5725396", "0.571461", "0.5712513", "0.5621569", "0.5572046", "0.55534637", "0.55534637", "0.54924273", "0.54346377", "0.54346377", "0.53535545", "0.5278378", "0.52699673", "0.526183", "0.5248149", "0.52437...
0.60873646
4
Show the logged calls
def index @calls = Call.all.order('created_at DESC') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_history\n logger.info('[]' + request.method + \"\\t\" + request.fullpath + \"\\t\" + request.remote_ip + \"\\t\" + Time.now.strftime('%Y-%m-%d %H:%M:%S'))\n end", "def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend", "def call_tracing\n @page_t...
[ "0.6701976", "0.6678386", "0.65746415", "0.64326644", "0.64297765", "0.6427081", "0.6404469", "0.63954556", "0.6345736", "0.63456285", "0.63368106", "0.63294303", "0.63246995", "0.63246995", "0.63246995", "0.63246995", "0.63246995", "0.63246995", "0.63246995", "0.63246995", "...
0.0
-1
When a call comes in, we create a Call log entry and we render the XML file describing how to handle the call
def answer return render nothing: true unless params[:Event] == 'StartApp' @from = params[:From] company_number = CompanyNumber.find_by_sip_endpoint params[:To] Call.create! from: @from, call_uuid: params[:CallUUID], company_number: company_number @user_numbers = company_number.users.joins(:user_numbers).select('user_numbers.sip_endpoint') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @call_log = CallLog.new(params[:call_log])\n\n respond_to do |format|\n if @call_log.save\n format.html { redirect_to(@call_log, :notice => t(:call_log_created)) }\n format.xml { render :xml => @call_log, :status => :created, :location => @call_log }\n else\n form...
[ "0.6427556", "0.6177012", "0.61453575", "0.60692173", "0.60169286", "0.6014099", "0.5973682", "0.59726775", "0.5934904", "0.5930262", "0.59135586", "0.5731635", "0.57307154", "0.5712374", "0.56764346", "0.5645702", "0.5640544", "0.56098324", "0.5569632", "0.5541602", "0.54695...
0.0
-1
This route can be triggered by several events during a call, and we act for only a few of them
def log # When someone actually picks up the call if params[:DialAction] == 'answer' user_number = UserNumber.find_by_sip_endpoint(params[:DialBLegTo]) @call.update! user_number: user_number # When the call is over, we log the call duration and the time it took to # pick up the call elsif params[:DialAction] == 'hangup' && params[:DialBLegHangupCause] == 'NORMAL_CLEARING' pickup_time = params[:AnswerTime].to_time - params[:StartTime].to_time @call.update! duration: params[:DialBLegDuration], pickup_time: pickup_time end render nothing: true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callwide_events()\n on :event => 'error', :next => '/error.json' # For fatal programming errors. Log some details so we can fix it\n on :event => 'hangup', :next => '/hangup.json' # When a user hangs or call is done. We will want to log some details.\nend", "def route\n #TODO\n end", "def rou...
[ "0.67447895", "0.6262165", "0.6197178", "0.6197178", "0.6191316", "0.61823624", "0.6130707", "0.6124416", "0.60470057", "0.5879433", "0.58617884", "0.58596176", "0.5841882", "0.58206284", "0.5800671", "0.5800671", "0.57940614", "0.57837844", "0.57837844", "0.57837844", "0.571...
0.0
-1
When the dial is over. If someone picked up the call, we do nothing. Otherwise (rejected, timeout, busy,...), we record a voicemail.
def end_dial return render nothing: true if params[:CallStatus] == 'completed' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call?\n if rejection_reason\n TinyDialer::Log.info \"Rejected #{phone}: #{rejection_reason}\"\n return\n end\n # Make sure (now, now) overlaps (start, stop)\n now = (Time.now.utc + (3600*(timezone)).to_i).strftime('%H:%M')\n unless TinyDialer.db.fetch(\"select ('#{now}'::text::time, '#...
[ "0.6372694", "0.63137484", "0.62984216", "0.5550385", "0.5470833", "0.5459178", "0.5440483", "0.5394325", "0.5384063", "0.5375275", "0.5351732", "0.53430194", "0.5278601", "0.52784586", "0.526246", "0.52535534", "0.52472454", "0.52319646", "0.5218153", "0.52144283", "0.518734...
0.5958283
3
When no one answers the call and the voicemail has been recorded, we save the url of the voicemail audio file
def voicemail @call.update! voicemail: params[:RecordFile], duration: params[:RecordingDuration] render nothing: true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_voicemail_message(user)\n ahn_log.record_voicemail.debug \"playing beep, ready to record voicemail\"\n play 'beep'\n\n # TODO maybe add uuid to file name\n fn = \"#{user.id}_#{Time.now.to_i}\"\n file_name = COMPONENTS.voicemail[\"voicemail_directory\"] + fn\n file = file_name + \".#{CO...
[ "0.6842245", "0.6816026", "0.6726095", "0.64919776", "0.6384651", "0.6245367", "0.6243171", "0.62332404", "0.6207534", "0.6084212", "0.6054795", "0.59512675", "0.5904211", "0.5889845", "0.58578175", "0.5834319", "0.58333856", "0.5832681", "0.5799476", "0.5783429", "0.57813036...
0.66670156
3
assign_rooms(["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"])
def printer (attendees) the_badges = batch_badge_creator (attendees) the_rooms = assign_rooms (attendees) the_badges.each do |x| puts "#{x}" end the_rooms.each do |x| puts "#{x}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_rooms(names)\n assignments = []\n rooms = (1..7).to_a\n names.each_with_index do |name, index|\n assignments.push(\"Hello, #{name}! You'll be assigned to room #{rooms[index]}!\")\n end\n return assignments\nend", "def assign_rooms(names)\n assignments = [];\n names.each_with_index { |name, i...
[ "0.8229181", "0.8163804", "0.8022056", "0.79739535", "0.77126974", "0.77026916", "0.7689169", "0.7659879", "0.7587761", "0.75472695", "0.7542743", "0.75424784", "0.7528686", "0.74863034", "0.7447473", "0.7435326", "0.74094486", "0.73801833", "0.7369993", "0.7354445", "0.73447...
0.0
-1
=begin def last_person end =end
def show boook puts @hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_name\n return person.last_name\n end", "def last_name; end", "def last_name; end", "def last_name; end", "def last_name; end", "def last() end", "def last; end", "def last; end", "def last; end", "def last_name\n @last_name\n end", "def last\n end", "def last_name\n ...
[ "0.74063075", "0.7011822", "0.7011822", "0.7011822", "0.7011822", "0.6885185", "0.68614304", "0.68614304", "0.68614304", "0.68369734", "0.6833746", "0.67267376", "0.67267376", "0.6704265", "0.6662109", "0.6604422", "0.65683717", "0.6434868", "0.6411263", "0.6391077", "0.63769...
0.0
-1
Writes bytes directly to the IO object.
def write(bytes) @io.write(bytes) nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(bytes)\r\n end", "def write(io)\n io = BinData::IO.new(io) unless BinData::IO === io\n\n do_write(io)\n io.flush\n self\n end", "def write bytes\n r = response_object\n r.body \"\" if r.body_io.nil?\n r.body_io.write bytes\n end", "def io(data, io)\n io.wr...
[ "0.77240044", "0.767987", "0.72430104", "0.72015387", "0.6981127", "0.6953536", "0.69503915", "0.68942535", "0.68942535", "0.68886614", "0.68806094", "0.68796396", "0.6869945", "0.6813113", "0.67795295", "0.67501783", "0.67364347", "0.6633813", "0.66079766", "0.65959054", "0....
0.8240759
0
Writes an 8bit boolean to the IO object.
def write_boolean(boolean) boolean ? write_int8(1) : write_int8(0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_bool(*b); end", "def write_booleanr(bool)\n\t\twrite_byte(1)\n\t\twrite_boolean(bool)\n\tend", "def bool_to_binary(val)\n saved_object_count = @written_object_count\n @written_object_count += 1\n\n @object_table[saved_object_count] = val ? \"\\x9\" : \"\\x8\" # 0x9 is 1001, type indica...
[ "0.7299487", "0.7149008", "0.61976385", "0.59821904", "0.59737766", "0.58780134", "0.57552665", "0.56953734", "0.5683204", "0.5656538", "0.55406576", "0.5491624", "0.543189", "0.54240245", "0.54226005", "0.5382854", "0.5350557", "0.53317887", "0.5328034", "0.52960986", "0.527...
0.7627317
0
Writes an 8bit integer to the IO object.
def write_int8(int) write([int].pack("C")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_i(i)\n z.write i.p32\nend", "def write_varint(int)\n int = int << 1\n int = ~int | 1 if int < 0\n\n chunks = []\n while int >> 7 != 0\n chunks << (int & 0x7f | 0x80)\n int >>= 7\n end\n chunks << int\n write(chunks.pack(\"C*\"))\n ...
[ "0.6684698", "0.6608419", "0.6507216", "0.64572746", "0.6446795", "0.6424291", "0.63450706", "0.6329984", "0.6321829", "0.6317031", "0.62843823", "0.62360305", "0.62215775", "0.6158286", "0.61564684", "0.6070906", "0.6049056", "0.60213804", "0.6014682", "0.59742707", "0.59560...
0.7866866
0
Writes a 16bit integer to the IO object.
def write_int16(int) write([int].pack("s>")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write16(val)\n\tval = (-val) | 0x8000 if val < 0\n\tputc((val >> 8) & 0xff)\n\tputc(val & 0xff)\n end", "def encode_and_write_int16(int, mode='file')\n\t\t# make sure 'byte' arrays are clear\n\t\t@byte1.clear\n\t\t@byte2.clear\n\t\t# convert int argument into binary, put in arrays\n\t\t15.downto(8) do |...
[ "0.70209384", "0.68871415", "0.68432695", "0.63513136", "0.62037164", "0.60883254", "0.5981403", "0.59678274", "0.5954523", "0.59169126", "0.5911222", "0.5844161", "0.58246", "0.5823545", "0.57841533", "0.5775634", "0.57191944", "0.571265", "0.5712276", "0.5706617", "0.569546...
0.826333
0
Writes a 32bit integer to the IO object.
def write_int32(int) write([int].pack("l>")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def int32(val)\n raise ArgumentError, \"int32() requires an Integer argument\" \\\n unless val.is_a?(Integer)\n raise RangeError, \"argument to int32() must be in the range \" +\n \"-2**31 <= arg <= 2**31-1\" \\\n unless val >= -2**31 ...
[ "0.7225985", "0.721072", "0.7194844", "0.69908506", "0.6926294", "0.6872787", "0.67737365", "0.67489505", "0.6748842", "0.6649834", "0.6597686", "0.6584023", "0.65757567", "0.645551", "0.6442932", "0.6356821", "0.6314031", "0.629214", "0.62657666", "0.6098168", "0.5954551", ...
0.83171153
0
Writes a 64bit integer to the IO object.
def write_int64(int) write([int].pack("q>")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_int64(*n); end", "def put_i64(arg)\n @data += [(arg >> 32) & UINT_MASK, arg & UINT_MASK].pack(\"NN\")\n self\n end", "def write_long(*n); end", "def write_int(file, int, md)\n int = [int].pack('N')\n md << int\n file.write(int)\n end", "def write_int(value, stream =...
[ "0.7757498", "0.68079746", "0.6679131", "0.6667459", "0.63482016", "0.6277216", "0.62628424", "0.6244755", "0.6167701", "0.6150978", "0.6141332", "0.6095988", "0.6059898", "0.6049532", "0.60115427", "0.6002218", "0.599803", "0.59032845", "0.5860196", "0.5860196", "0.58596677"...
0.83039373
0
Writes an array to the IO object. Each item in the specified array will be yielded to the provided block; it's the responsibility of the block to write those items using the encoder.
def write_array(array, &block) if array.nil? # An array can be null, which is different from it being empty. write_int32(-1) else write_int32(array.size) array.each(&block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_array(array)\n\t\twrite_byte(10)\n\t\twrite_word32_network(array.length)\n\t\tarray.each do |el| \n\t\t\twrite(el)\n\t\tend\n\tend", "def write_varint_array(array, &block)\n if array.nil?\n write_varint(-1)\n else\n write_varint(array.size)\n array.each(&block)\...
[ "0.6863102", "0.6826727", "0.6097435", "0.6035484", "0.58435345", "0.5754701", "0.57182705", "0.5709481", "0.5704442", "0.5658664", "0.56524307", "0.5605451", "0.5545483", "0.5530539", "0.5524677", "0.5524677", "0.54987806", "0.545878", "0.54545754", "0.5447909", "0.540853", ...
0.7923702
0
Writes an array to the IO object. Just like write_array, unless the size is under varint format
def write_varint_array(array, &block) if array.nil? write_varint(-1) else write_varint(array.size) array.each(&block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_array(array)\n\t\twrite_byte(10)\n\t\twrite_word32_network(array.length)\n\t\tarray.each do |el| \n\t\t\twrite(el)\n\t\tend\n\tend", "def write_array(array, &block)\n if array.nil?\n # An array can be null, which is different from it being empty.\n write_int32(-1)\n else...
[ "0.7943161", "0.71779764", "0.6731046", "0.67198324", "0.6516874", "0.63610566", "0.63603246", "0.6319324", "0.61691755", "0.61451405", "0.6113215", "0.60244584", "0.60224783", "0.5974177", "0.5949958", "0.59203404", "0.5851798", "0.5827137", "0.5826137", "0.5824781", "0.5788...
0.6815927
2
Writes a string to the IO object.
def write_string(string) if string.nil? write_int16(-1) else write_int16(string.bytesize) write(string) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(string)\n @handle.write(string)\n end", "def write string\n end", "def write(str)\n writing { write0 str }\n end", "def write!( string )\n @stream << string\n end", "def write_string(string)\n\t\twrite_byte(2)\n\t\twrite_utf(string.to_s)\n\tend", "def syswrite(st...
[ "0.847355", "0.8362848", "0.8215714", "0.7903698", "0.76729614", "0.7595885", "0.7568859", "0.7568859", "0.7534099", "0.7523392", "0.7456617", "0.7439216", "0.7409765", "0.7332832", "0.73086363", "0.7307801", "0.7083046", "0.70591205", "0.70111567", "0.70111567", "0.6938605",...
0.7045185
18
Writes a string to the IO object, the size is under varint format
def write_varint_string(string) if string.nil? write_varint(-1) else write_varint(string.bytesize) write(string) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(string)\n string.to_s.bytesize\n end", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write string\n end", "def write(str)\n writing { write0 str }\n end", "def write(string)\n send(string)\n string.length\n end", "def write(str)\n s ...
[ "0.78593", "0.7604738", "0.7414807", "0.73520833", "0.73187006", "0.72003394", "0.7119894", "0.7054407", "0.7037742", "0.70048136", "0.68805236", "0.6752933", "0.6671899", "0.6632141", "0.656557", "0.651033", "0.651033", "0.64185447", "0.64165807", "0.6412854", "0.6400829", ...
0.66224796
14
Writes an integer under varints serializing to the IO object.
def write_varint(int) int = int << 1 int = ~int | 1 if int < 0 chunks = [] while int >> 7 != 0 chunks << (int & 0x7f | 0x80) int >>= 7 end chunks << int write(chunks.pack("C*")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_int(value) \n @codegen.write_int(value)\n end", "def write_int(value, stream = @index)\n stream.write([value].pack('L'))\n end", "def write_varint(i, data: nil, stream: nil)\n buf = encode_varint(i)\n data << buf if data\n stream.write(buf) if stream\n bu...
[ "0.73925453", "0.7198742", "0.7121977", "0.6955201", "0.690309", "0.68457305", "0.6691438", "0.65506095", "0.65127933", "0.6350357", "0.63346916", "0.62954724", "0.6244484", "0.6185402", "0.61474836", "0.6060596", "0.601771", "0.5999958", "0.5980629", "0.59512264", "0.5933526...
0.6999754
3
Writes a byte string to the IO object.
def write_bytes(bytes) if bytes.nil? write_int32(-1) else write_int32(bytes.bytesize) write(bytes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(bytes)\n @io.write(bytes)\n\n nil\n end", "def write(string)\n @handle.write(string)\n end", "def write(bytes)\r\n end", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write(string)\n string.to_s.bytesize\n end", "def write(str)\...
[ "0.78178066", "0.74724317", "0.73846424", "0.73388565", "0.73045856", "0.7131149", "0.703012", "0.7018725", "0.6949363", "0.6949222", "0.69329894", "0.6915319", "0.68876916", "0.68819714", "0.6879513", "0.6833574", "0.68219787", "0.680301", "0.6720407", "0.66476995", "0.66291...
0.61887485
45
Writes a byte string to the IO object, the size is under varint format
def write_varint_bytes(bytes) if bytes.nil? write_varint(-1) else write_varint(bytes.bytesize) write(bytes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(string)\n string.to_s.bytesize\n end", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write_byte(*n); end", "def write(bytes)\r\n end", "def write(bytes)\n @io.write(bytes)\n\n nil\n end", "def write(string)\n\t\t\t\t@write_buffer << string\...
[ "0.80468494", "0.79287845", "0.7310547", "0.72953856", "0.70280015", "0.70229805", "0.6818229", "0.6769037", "0.6685795", "0.6645412", "0.6625934", "0.6609277", "0.65974224", "0.65971804", "0.6577895", "0.6544731", "0.6522107", "0.6519173", "0.6507226", "0.6505245", "0.649719...
0.62259233
29
before_action :require_same_user, except: [:edit, :update]
def index @company = Company.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_same_user\n # if the user is on another user's edit or update page\n if current_user != @user and !current_user.admin?\n # flash message\n flash[:danger] = \"Access denied.\"\n # and redirect to articles listing\n redirect_to articles_path\n end\n end", "def require_same...
[ "0.809157", "0.78970766", "0.7776367", "0.7669978", "0.7639958", "0.75839335", "0.75267303", "0.75190496", "0.74935085", "0.74656653", "0.74600446", "0.7456615", "0.74560815", "0.738951", "0.7377735", "0.7371912", "0.73404634", "0.733168", "0.7316766", "0.72924685", "0.728976...
0.0
-1
rand generates pseudo random from 01 rand(10) generates pseudo random from 010 we use it to get something like 4.41445946155691
def random_float rand * rand(10) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_random()\n begin\n r = Kernel.rand()\n end while r == 0.0\n \n if use_flt?\n BigDecimal(r.to_s)\n else\n r\n end\n end", "def rand\n return extract_number / (2**32 -1).to_f\n end", "def random\n 1 + (10 * rand(0))\n end", "def ran...
[ "0.7837686", "0.77281445", "0.7547714", "0.71551806", "0.71075815", "0.71075815", "0.7002897", "0.6914746", "0.68725765", "0.68639934", "0.6802012", "0.6802012", "0.67990583", "0.67890334", "0.6755617", "0.67540085", "0.6747877", "0.67228144", "0.67228144", "0.67228144", "0.6...
0.8145263
0
comprobar que el acceso se corresponde con el usuario logeado
def correct_employee params[:id]==current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend", "def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(session[:alumno_id]) if session[:alumno_id]\n end", "def comprobar...
[ "0.6571516", "0.646132", "0.64290553", "0.63437504", "0.6303104", "0.61469847", "0.61469847", "0.6069323", "0.6067246", "0.6043428", "0.6016864", "0.6016177", "0.5942837", "0.5905743", "0.5895983", "0.5885552", "0.58311933", "0.5805476", "0.5786475", "0.57707316", "0.57252365...
0.0
-1
comprobar que el departamento se corresponde al del usuario logeado, si no es administrador. Si es adm se debera corresponder a la empresa.
def correct_dpto if current_user.role<3 && !params[:department].nil? unless current_user.department_id==params[:department].to_i flash[:danger] = "ERROR: No tiene acceso al recurso solicitado" redirect_to current_user end elsif current_user.role==3 redirect_to current_user unless current_emp.departments.where(:id => params[:department]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_departments(user=current_user)\n if user.role? :superadmin\n @departments = Department.active\n else\n @departments = @department || user.department\n end\n end", "def set_admin_departamento\n @admin_departamento = Admin::Departamento.find(params[:id])\n end", "def get_depa...
[ "0.63323087", "0.63115716", "0.6158076", "0.6103626", "0.5995021", "0.5987482", "0.5873196", "0.58308876", "0.58051515", "0.5761376", "0.57514656", "0.5695848", "0.5689716", "0.5677122", "0.5670629", "0.56586474", "0.5652256", "0.56519073", "0.5625365", "0.56181085", "0.56111...
0.6475799
0
obtener la empresa del empleado autentificado.
def current_emp user=self.current_user dpto=Department.find(user.department_id) @current_emp=Enterprise.find(dpto.enterprise_id) if dpto end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_empresa\n @empresa = Empresa.first\n end", "def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(session[:alumno_id]) if session[:alumno_id]\n end", "def inicia...
[ "0.635461", "0.6142139", "0.6101184", "0.60557014", "0.60557014", "0.60557014", "0.60557014", "0.60557014", "0.5972444", "0.59518254", "0.5931809", "0.5894312", "0.58338535", "0.58247507", "0.57495284", "0.57460386", "0.5741295", "0.57398254", "0.570893", "0.56976646", "0.568...
0.5374184
51
return current Role name
def current_role case current_user.role when 1 @current_role='Empleado' when 2 @current_role='Jefe Departamento' when 3 @current_role='Auditor' when 4 @current_role='Administrador' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def role_name\r\n Role.find(object.role_id).role_name\r\n end", "def role_name\n @role_name ||= object.meta[:role].try(:capitalize)\n end", "def role_name\n object.role_name\n end", "def role\r\n r = read_attribute(:role)\r\n r.capitalize unless r.nil?\r\n end", "def current_role\n ...
[ "0.8402955", "0.8367127", "0.82425946", "0.800383", "0.78114134", "0.77763313", "0.75726336", "0.75634325", "0.7552031", "0.7523308", "0.7490301", "0.7489514", "0.74656725", "0.7458993", "0.7445728", "0.74190587", "0.7373033", "0.73613995", "0.73411566", "0.73333424", "0.7290...
0.754882
9
Find the legacy access controls From the Sufia.Frakenversion (Sufia6F) codebase. Create equivalent_permissions for the GenericWork or FileSet. Destroy the legacy access controls.
def migrate_permissions_for(object) # Find any access controls for this work. The must be sufia6F style in order to not show up on the Work. legacy_access_controls = access_controls_for object puts "#{legacy_access_controls.count} AccessControls for #{object.class}: #{object.id}" puts "#{object.permissions}" # Create equivalent access controls self.class.make_equivalent_permissions( object, legacy_access_controls ) puts "Created equivalent permissions." puts "#{object.permissions}" # Destroy legacy_access_controls if object.save puts "Able to save #{object.class} with new permissions. Destroying old access controls." legacy_access_controls.each{ |ac| ac.destroy } else puts "Unable to save #{object.class}." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setable_permissions\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == B...
[ "0.54069215", "0.5394768", "0.5394768", "0.5243208", "0.51110125", "0.51008105", "0.50688976", "0.50420976", "0.4997379", "0.49165583", "0.4913748", "0.4897455", "0.4861618", "0.4841139", "0.48138663", "0.48138663", "0.48012033", "0.47829705", "0.47727913", "0.47565815", "0.4...
0.6743784
0
Sift through all AccessControls and fine the ones that specify access to the given work id.
def access_controls_for(object) all_acls.select{ |ac| ac.access_to_id == object.id } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_access_control\n @access_control = AccessControl.find(params[:id])\n end", "def check_access_control_account_all\n @account = Account.find(params[:account_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @account.user_id\n rescue\n resp...
[ "0.61088336", "0.5771665", "0.5768473", "0.5598489", "0.5573087", "0.55460536", "0.5509252", "0.54257214", "0.54257214", "0.54257214", "0.54257214", "0.54257214", "0.5422771", "0.53708947", "0.53124815", "0.53081685", "0.53018373", "0.52960354", "0.5266907", "0.5257056", "0.5...
0.64365894
0
Get array of GenericWorks that are missing creator and description metadata.
def works_with_missing_metadata GenericWork.all.select do |gw| gw.description == [] && gw.creator == [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creatable_works\n all_works.select do |work|\n can?(:create, work)\n end\n end", "def missing_list\n list = []\n regular_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n ...
[ "0.5886883", "0.5348945", "0.53283125", "0.5142102", "0.5132125", "0.51179856", "0.50782174", "0.50779605", "0.50741905", "0.5022318", "0.4969895", "0.4919487", "0.4869716", "0.48494473", "0.47848085", "0.47560102", "0.4749283", "0.47350717", "0.4710902", "0.47080576", "0.470...
0.79984206
0
Get array of FileSets that have an original file which is missing technical metadata. Minimally, check for size as a surrogate.
def file_sets_missing_metadata FileSet.all.select do |fs| fs.original_file && fs.original_file.file_size == [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_sets\n @iss_file.file_sets.select {|fs| fs.components.include? name }\n end", "def staged\n @files.select { |k, f| f.sha_index != \"0000000000000000000000000000000000000000\" && f.type != nil }\n end", "def relevant_itemsets\n frequent_itemsets.reject do |itemset|\n ...
[ "0.5951391", "0.58240366", "0.5803019", "0.5778906", "0.5763632", "0.5749727", "0.56249124", "0.561522", "0.5559767", "0.55465734", "0.551472", "0.546619", "0.5438188", "0.5438188", "0.54299843", "0.53837687", "0.5373799", "0.5342839", "0.5305659", "0.52989376", "0.52727896",...
0.834574
0
Get list of GenericWorks that are still using the v6.Franensufia style of access controls. These will appear empty from the v7 based code.
def works_with_empty_permissions GenericWork.all.select{|gw| gw.permissions.empty?} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_works\n [ScannedResource, ScannedMap, RasterResource, VectorResource, Numismatics::Issue, Playlist]\n end", "def index\n @admin_tech_supports = Admin::TechSupport.all\n end", "def works_with_missing_metadata\n GenericWork.all.select do |gw|\n gw.description == [] && gw.creator == []...
[ "0.5908111", "0.5455268", "0.52878094", "0.5179741", "0.51601195", "0.506519", "0.49479342", "0.49426058", "0.49189162", "0.49071422", "0.49010187", "0.48997656", "0.48822734", "0.48709238", "0.48695105", "0.4839005", "0.48134086", "0.4812925", "0.4812481", "0.48121077", "0.4...
0.5370319
2
Mutate the work. Make new permission based on access control
def make_equivalent_permissions(object, access_controls) access_controls.each{ |access_ctl| object.permissions.build access_ctl.to_hash } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def af_perform(work)\n attribute_map = work.permissions.map(&:to_hash)\n work.file_sets.each do |file|\n # copy and removed access to the new access with the delete flag\n file.permissions.map(&:to_hash).each do |perm|\n unless attribute_map.include?(perm)\n perm[:_destroy] = true\n...
[ "0.67044514", "0.662718", "0.6604972", "0.65883493", "0.65368253", "0.6496509", "0.64837027", "0.6424326", "0.641749", "0.6392473", "0.6298476", "0.6287444", "0.6286463", "0.6266979", "0.626581", "0.62240946", "0.62192607", "0.6218046", "0.62096894", "0.62060577", "0.62044", ...
0.0
-1
Take property value from Sufia6F predicate DC.creator write it to the current property (which uses DC11.creator as the predicate)
def update_creator_of(object) object.creator = object.get_values(::RDF::Vocab::DC.creator) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def creator=(name)\n creator = DCMES.new\n creator.content = name\n self.dc_creators = [creator]\n name\n end", "def direct_write_predicate(predicate, value)\n ActiveRDF::FederationManager.add(self, predicate, value)\n end", "def creator=(creator)\n @crea...
[ "0.5499075", "0.5340245", "0.52810454", "0.5190694", "0.5190694", "0.50843453", "0.5066934", "0.5062746", "0.5062702", "0.50044614", "0.49611464", "0.48996618", "0.48730752", "0.48683342", "0.48524168", "0.4849785", "0.4842948", "0.47967225", "0.47967225", "0.47897446", "0.47...
0.6679118
0
Well, let's not test those 3 lines of code. def test_attach_merge_fields_option end
def test_attach_with_fe @dashboard.register '.+', Ruote::StorageParticipant pdef = Ruote.define do set 'v:message' => 'hello world' bravo end wfid = @dashboard.launch(pdef, 'message' => 'hello planet') r = @dashboard.wait_for('dispatched') adef = Ruote.define do echo '${v:message}' echo '${f:message}' end fe = @dashboard.ps(wfid).expressions.last fei = @dashboard.attach(fe.to_h, adef) r = @dashboard.wait_for('ceased') ps = @dashboard.ps(wfid) assert_equal '0_1_0', fei.expid assert_equal wfid, fei.wfid assert_equal "hello world\nhello planet", @tracer.to_s assert_equal 0, ps.errors.size assert_equal 2, ps.expressions.size assert_equal 1, ps.stored_workitems.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_merge\n # Rule is non-admins can only merge herbaria in which they own all records\n # into their own personal herbarium. Nothing else. Mary owns all the\n # records at fundis, randomly enough, so if we create a personal\n # herbarium for her, she should be able to merge fundis into it...
[ "0.6094126", "0.5764082", "0.5726817", "0.5674355", "0.56248164", "0.5575488", "0.557181", "0.55328673", "0.53965706", "0.5371851", "0.53565717", "0.5332604", "0.5289605", "0.52349776", "0.5226545", "0.52100784", "0.51951534", "0.51950985", "0.51910824", "0.5151763", "0.51446...
0.0
-1
Show invalid properties with the reasons. Usually used together with valid?
def list_invalid_properties invalid_properties = Array.new return invalid_properties end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil....
[ "0.76497203", "0.76497203", "0.76497203", "0.76497203", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7356452", "0.7334807", "0.72685325", "0.7238964", "0.7231359", "0.72258264", "0.7208294", "0.71760833", "0.717024...
0.0
-1
Check to see if the all the properties in the model are valid
def valid? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_properties\n true\n end", "def validate_properties\n true\n end", "def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :...
[ "0.78992486", "0.78992486", "0.70971805", "0.70782334", "0.7032205", "0.7031276", "0.69510347", "0.6869891", "0.6858077", "0.6858077", "0.68287027", "0.6823878", "0.6820306", "0.68144894", "0.6794656", "0.6752167", "0.66843414", "0.6676546", "0.6667755", "0.66296124", "0.6618...
0.0
-1
Checks equality by comparing each attribute.
def ==(o) return true if self.equal?(o) self.class == o.class && id_conta == o.id_conta && id_pessoa == o.id_pessoa && id_cartao == o.id_cartao && id_bandeira == o.id_bandeira && id_tipo_cartao == o.id_tipo_cartao && numero_cartao == o.numero_cartao && nome_plastico == o.nome_plastico && cvv2 == o.cvv2 && data_geracao == o.data_geracao && data_validade == o.data_validade && cpf == o.cpf && tipo_portador == o.tipo_portador && trilha1 == o.trilha1 && trilha2 == o.trilha2 && trilha_cvv1 == o.trilha_cvv1 && trilha_cvv2 == o.trilha_cvv2 && flag_virtual == o.flag_virtual && nome_bandeira == o.nome_bandeira && flag_titular == o.flag_titular && sequencial_cartao == o.sequencial_cartao && id_status == o.id_status && descricao_status_cartao == o.descricao_status_cartao && data_status == o.data_status && id_estagio == o.id_estagio && descricao_estagio == o.descricao_estagio && data_estagio == o.data_estagio && numero_bin == o.numero_bin && id_produto == o.id_produto && descricao_produto == o.descricao_produto && id_status_conta == o.id_status_conta && descricao_status_conta == o.descricao_status_conta && data_embossing == o.data_embossing && codigo_desbloqueio == o.codigo_desbloqueio && nome_pessoa == o.nome_pessoa && tipo_pessoa == o.tipo_pessoa && data_nascimento == o.data_nascimento && id_endereco == o.id_endereco && id_tipo_endereco == o.id_tipo_endereco && descricao_tipo_endereco == o.descricao_tipo_endereco && cep == o.cep && logradouro == o.logradouro && numero_endereco == o.numero_endereco && complemento_endereco == o.complemento_endereco && bairro == o.bairro && cidade == o.cidade && uf == o.uf && pais == o.pais && senha_criptografada == o.senha_criptografada && icvv == o.icvv && id_status_impressao == o.id_status_impressao end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n attributes == other.attributes\n end", "def ==(other) # :nodoc:\n @attrs == other.attrs\n end", "def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en...
[ "0.7291717", "0.7188103", "0.70395297", "0.7007927", "0.68874705", "0.6861532", "0.6707156", "0.6660597", "0.66147524", "0.658478", "0.6584619", "0.6580019", "0.65543133", "0.6543933", "0.65068495", "0.6479513", "0.6456241", "0.6415999", "0.6412208", "0.6412208", "0.6412208",...
0.0
-1
Calculates hash code according to all attributes.
def hash [id_conta, id_pessoa, id_cartao, id_bandeira, id_tipo_cartao, numero_cartao, nome_plastico, cvv2, data_geracao, data_validade, cpf, tipo_portador, trilha1, trilha2, trilha_cvv1, trilha_cvv2, flag_virtual, nome_bandeira, flag_titular, sequencial_cartao, id_status, descricao_status_cartao, data_status, id_estagio, descricao_estagio, data_estagio, numero_bin, id_produto, descricao_produto, id_status_conta, descricao_status_conta, data_embossing, codigo_desbloqueio, nome_pessoa, tipo_pessoa, data_nascimento, id_endereco, id_tipo_endereco, descricao_tipo_endereco, cep, logradouro, numero_endereco, complemento_endereco, bairro, cidade, uf, pais, senha_criptografada, icvv, id_status_impressao].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ...
[ "0.7120876", "0.7039781", "0.7039781", "0.7039781", "0.7039781", "0.7039781", "0.7039781", "0.7039781", "0.68948233", "0.67841566", "0.6706898", "0.66992533", "0.6688269", "0.6669114", "0.6488987", "0.64612424", "0.64612424", "0.6444354", "0.6411414", "0.6396147", "0.6388743"...
0.0
-1
Builds the object from hash
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end", "def build_from_hash(attributes)\n\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ...
[ "0.8011074", "0.7470833", "0.7457607", "0.7256629", "0.72455454", "0.70060325", "0.6973257", "0.6955014", "0.69459796", "0.69398683", "0.69363195", "0.6917627", "0.6872358", "0.6796184", "0.6783521", "0.67575246", "0.67575246", "0.67560464", "0.67514306", "0.67136854", "0.666...
0.0
-1
Deserializes the data based on type
def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /^(true|t|yes|y|1)$/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = Pier.const_get(type).new temp_model.build_from_hash(value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s...
[ "0.7330926", "0.7274019", "0.72504056", "0.7245751", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", ...
0.71791923
38
Returns the string representation of the object
def to_s to_hash.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @object.to_s\n end", "def to_s\n object.to_s\n end", "def serialize(object)\n object.to_s\n end", "def to_s\n self.inspect\n end", "def to_s\n @string || @object.to_s('F')\n end", "def to_s\n @string || @object.to_s('F')\n end", "de...
[ "0.901024", "0.89506465", "0.84703195", "0.83409667", "0.8337169", "0.8337169", "0.8332247", "0.82546586", "0.8145818", "0.8144667", "0.81357557", "0.812714", "0.8093436", "0.8086725", "0.8073356", "0.8039774", "0.80308646", "0.80064154", "0.80064154", "0.80064154", "0.800641...
0.0
-1
to_body is an alias to to_hash (backward compatibility)
def to_body to_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_body\r\n to_hash\r\n end", "def to_body\n to_hash\nend", "def to_body\n to_hash\nend" ]
[ "0.8429592", "0.8347019", "0.8347019" ]
0.0
-1
Returns the object in the form of hash
def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n object\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n to_a.hash\n end", "def hash\n [_hash, name, owner].hash\n end", "def hash\n return to_s.hash\n end", "def hash\n @hash\n end", "def hash\n @hash.hash\n end", "def hash\n ...
[ "0.8270299", "0.78767854", "0.78726953", "0.7802364", "0.7789188", "0.77806795", "0.7775915", "0.7767511", "0.7760525", "0.7760525", "0.77559966", "0.7731286", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916",...
0.0
-1
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value
def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\n value.hash\n end", "def hash\n @value.hash\n end", "def hash\r\n return to_s.hash\r\n end", "def to_hash\n @value\n end", "def to_hash\n @va...
[ "0.6719518", "0.6719518", "0.666832", "0.66565555", "0.6586841", "0.6452931", "0.6414911", "0.6414911", "0.6382046", "0.6346188", "0.6302933", "0.62237245", "0.6151989", "0.6101756", "0.60795677", "0.60795677", "0.60717124", "0.6035991", "0.6021168", "0.5936472", "0.5903488",...
0.0
-1
Override this method from core vagrant, here we branch out the provision for windows FIXME: This should be removed when the core vagrant supports communication class for windows guests
def run_provisioner(env) if env[:machine].config.vm.guest == :windows case env[:provisioner].class.to_s when "VagrantPlugins::Shell::Provisioner" VagrantPlugins::VagrantHyperV::Provisioner::Shell.new(env).provision_for_windows when "VagrantPlugins::Puppet::Provisioner::Puppet" VagrantPlugins::VagrantHyperV::Provisioner::Puppet.new(env).provision_for_windows when "VagrantPlugins::Chef::Provisioner::ChefSolo" VagrantPlugins::VagrantHyperV::Provisioner::ChefSolo.new(env).provision_for_windows end else original_run_provisioner(env) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provision_winssh(args)\n with_script_file do |path|\n # Upload the script to the machine\n @machine.communicate.tap do |comm|\n env = config.env.map{|k,v| comm.generate_environment_export(k, v)}.join\n upload_path = config.upload_path.to_s\n if File.ext...
[ "0.7146217", "0.70492584", "0.6754668", "0.6731797", "0.64458185", "0.6392794", "0.6363255", "0.6361694", "0.632649", "0.63092256", "0.6272282", "0.6267608", "0.62578017", "0.62375796", "0.6216973", "0.61980397", "0.6189879", "0.61584574", "0.61557585", "0.6139744", "0.612985...
0.7328448
0
Get the `itctx` from the new (22nd May 2017) API endpoint "olympus" Update (29th March 2019) olympus migrates to new appstoreconnect API
def fetch_olympus_session0 response = request(:get, "https://appstoreconnect.apple.com/olympus/v1/session") body = response.body if body body = JSON.parse(body) if body.kind_of?(String) user_map = body["user"] if user_map self.user_email = user_map["emailAddress"] end provider = body["provider"] if provider self.provider = Spaceship::Provider.new(provider_hash: provider) return true end end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context\n get('/augeas/context')\n end", "def get_lti_tool_provider_information(org_unit_id, tp_id)\n path = \"/d2l/api/le/#{$le_ver}/lti/tp/#{org_unit_id}/#{tp_id}\"\n _get(path)\nend", "def graphiti_context\n if respond_to?(:jsonapi_context)\n DEPRECATOR.deprecation_warning(\"Ov...
[ "0.5284229", "0.52677834", "0.52620333", "0.518934", "0.5134698", "0.50523055", "0.50523055", "0.50523055", "0.5028967", "0.4981038", "0.49371794", "0.489742", "0.48655948", "0.48410177", "0.4839949", "0.48383677", "0.4822754", "0.4821109", "0.47953126", "0.47879517", "0.4760...
0.0
-1
XXX shell injection possible
def mimetype; @mimetype ||= `file -b --mime-type '#@fname'`.strip; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shell(*) end", "def shell_commands(cmd, args); end", "def shell_commands(cmd, *args); end", "def shell=(p0) end", "def exec(cmd, *rest) end", "def shell_wrap(cmd)\n return cmd unless @shell\n\n shell = @shell_command || \"$SHELL\"\n options = \" #{@shell_options}\" if @shell_options\n\...
[ "0.73802996", "0.7371442", "0.7233444", "0.6852378", "0.66496587", "0.6626033", "0.65987766", "0.65598017", "0.65476626", "0.6547588", "0.6547588", "0.6516827", "0.64856565", "0.6439151", "0.641212", "0.6394465", "0.6376933", "0.63383424", "0.6333282", "0.6319847", "0.6314773...
0.0
-1
XXX shell injection possible
def md5; Digest::MD5.file(fname).hexdigest; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shell(*) end", "def shell_commands(cmd, args); end", "def shell_commands(cmd, *args); end", "def shell=(p0) end", "def exec(cmd, *rest) end", "def shell_wrap(cmd)\n return cmd unless @shell\n\n shell = @shell_command || \"$SHELL\"\n options = \" #{@shell_options}\" if @shell_options\n\...
[ "0.73802996", "0.7371442", "0.7233444", "0.6852378", "0.66496587", "0.6626033", "0.65987766", "0.65598017", "0.65476626", "0.6547588", "0.6547588", "0.6516827", "0.64856565", "0.6439151", "0.641212", "0.6394465", "0.6376933", "0.63383424", "0.6333282", "0.6319847", "0.6314773...
0.0
-1
insert, autoallocating the primary key from a sequence
def insert_sequenced(row) sql = row.type.insert_sql_minus_key vals = row.field_values_minus_key #$stderr.puts sql #$stderr.puts vals.inspect db.do(sql, *vals) insert_id = db.select_one(row.type.get_insert_id_sql)[0] row.send(row.type.primary_key.setter_name, insert_id) row.reset_changed end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primary_key_sequence(table, opts=OPTS)\n quoted_table = quote_schema_table(table)\n Sequel.synchronize{return @primary_key_sequences[quoted_table] if @primary_key_sequences.has_key?(quoted_table)}\n cond = {Sequel[:t][:oid] => regclass_oid(table, opts)}\n value = if pks = _select_se...
[ "0.6798957", "0.67284274", "0.6689262", "0.6686622", "0.66330767", "0.66164786", "0.66038424", "0.66038424", "0.6461906", "0.64407325", "0.6437145", "0.64316994", "0.62496734", "0.6223949", "0.6220948", "0.6183803", "0.61683446", "0.6158695", "0.61476517", "0.6142947", "0.613...
0.70880693
0
update a table with new data
def update(row) table = row.type fields = row.changed_fields return if fields.empty? sql = "update #{table.name}\nset\t" sql << fields.map{|field| "#{field} = ?"}.join(",\n\t") sql << ",\n\t_version = _version + 1\n" sql << "where\t" sql << table.primary_key.name.to_s << " = ?\n" sql << " and\t_version = ?" # now get the values for the changed rows vals = fields.map do |f| v = row.send(f) v = nil if v.type == String and v.empty? v end vals << row.send(table.primary_key.name) vals << row._version rpc = db.do(sql, *vals) if rpc != 1 msg = "Expected to update one row, but updated #{rpc}: #{sql}\n\n" + vals.map {|v| v.inspect} .join("\n") $stderr.puts msg end row._version += 1 row.reset_changed end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_record(table, values, org_key = nil)\n update table_update_query(table, values, org_key)\n end", "def update(table,cond,op)\n connection.update(path(table),cond,op)\n end", "def update(table, id, attributes) # abstract\n end", "def update data, table, condition = {}\n ...
[ "0.7137988", "0.7104973", "0.70614934", "0.6802528", "0.6796238", "0.6657435", "0.6565005", "0.6556319", "0.6549175", "0.6420742", "0.6401176", "0.63918537", "0.63918537", "0.6387685", "0.6360001", "0.6353984", "0.6345568", "0.6344913", "0.6344217", "0.63201827", "0.6320103",...
0.6094916
66
freeform update multiple rows
def update_where(table, what, where, *bindvars) sql = "update #{table.name}\nset #{what} where #{where}" #$stderr.puts sql db.do(sql, *bindvars) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update()\n sql = \"UPDATE customers (name, funds) = ($1, $2) WHERE id = $3\"\n values = [@name, @funds, @id]\n SqlRunner.run(sql,values)\n# => Updating only, no need to return any array\n end", "def update(*args)\n each{|r| r.update(*args)}\n end", "def batch_update\n @success = true\...
[ "0.68336505", "0.67137647", "0.6661009", "0.66592205", "0.6653152", "0.66213614", "0.6593405", "0.6548404", "0.6491957", "0.6478361", "0.64333946", "0.64278793", "0.64019996", "0.6341838", "0.62932986", "0.629179", "0.6262843", "0.62626386", "0.62547845", "0.6216891", "0.6216...
0.0
-1
An initializer called by the framework once per billling cycle. Override this method if you need to perform highlatency operations, like network transactions, that should not be performed perresource.
def setup(resources) ; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n open_connection!\n @transaction_open = false\n end", "def initialize(&block)\n load_defaults!\n\n @only_collections ||= Array.new\n @additional_options ||= Array.new\n @ipv6 ||= false\n @lock ||= false\n\n ...
[ "0.66455775", "0.64023906", "0.62130326", "0.6180118", "0.6168774", "0.6160818", "0.613698", "0.6104816", "0.609717", "0.60814637", "0.60731286", "0.6056982", "0.60249364", "0.6006676", "0.60053176", "0.6002044", "0.5999935", "0.5997332", "0.599696", "0.599696", "0.5993939", ...
0.0
-1
Returns the cost for a particular resource over some duration in seconds. ALL BILLING POLICY SUBCLASSES SHOULD OVERRIDE THIS METHOD
def get_cost_for_duration(resource, duration) ; 1.0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cost_item(time_entry)\n if User.current.logged? && (User.current.allowed_to?(:view_rate, time_entry.project) || User.current.admin?)\n return time_entry.cost\n else\n return nil\n end\n end", "def get_cost_for_duration(rds_server, duration)\n CENTS_PER_GB_PER_MONTH[zone_setting...
[ "0.6435194", "0.6388575", "0.63044333", "0.6247949", "0.61560947", "0.61206895", "0.6092066", "0.603561", "0.60191697", "0.60113394", "0.59981644", "0.59981644", "0.5982747", "0.5955256", "0.59534687", "0.5890761", "0.5880231", "0.58663607", "0.5865109", "0.5840298", "0.58402...
0.84995687
0
Returns the default billing type for this policy. Override this to set a humanreadable name for the policy. Defaults to the last part of the subclass name.
def billing_type self.class.name.split('::').last #(defaluts to class name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polymorphic_name\n store_full_class_name ? base_class.name : base_class.name.demodulize\n end", "def payment_type_display\n self.payment_type.to_s.titleize\n end", "def default_type_label(type)\n type.name.gsub(/::/, '_').underscore\n end", "def get_account_payment_type\n ...
[ "0.62362546", "0.6170936", "0.603222", "0.60252243", "0.6016412", "0.6016412", "0.596855", "0.5942817", "0.5875563", "0.5849752", "0.5811886", "0.57751286", "0.57346225", "0.57091135", "0.5694887", "0.56857264", "0.5669168", "0.5666361", "0.5663587", "0.558719", "0.5585203", ...
0.76226145
0
Writes 'record' into the database if: 1. there's no previous record for this resource + billing type; or 2. the previous such record differs in hourly cost or billing codes; or 3. the records are separated by more than maximum_time_gap Otherwise, `record` is merged with the previous record that matches its resource and billing type
def write_or_merge_with_existing(new_record, maximum_time_gap) write_new_record = true last_record = BillingRecord.most_recent_like(new_record) # If the previous record for this resource/billing type has the same # hourly rate and billing codes, just update the previous record if last_record && last_record.overlaps_with(new_record, maximum_time_gap) if (last_record.cost_per_hour.round(PRECISION) == new_record.cost_per_hour.round(PRECISION)) && (last_record.billing_codes == new_record.billing_codes) @log.debug "Updating record #{last_record.id} for "+ " #{new_record.resource_type} #{new_record.resource_id}"+ " in account #{new_record.account}" last_record.merge_with new_record write_new_record = false else # If the previous record has different rate or codes... # Make the new record begin where the previous one leaves off new_record.start_time = last_record.stop_time end end if write_new_record @log.debug "Creating new record for for #{new_record.resource_type}"+ " #{new_record.resource_id} in account #{new_record.account}" ActiveRecord::Base.connection_pool.with_connection {new_record.save!} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(record)\n unless exist?(record[0])\n domain = new_domain(record[0])\n zone = new_zone(domain.id)\n for t in @templates\n new_record(t, domain, record)\n end\n\n if(record[4] == \"yes\")\n @mxgoogle.each do |content, ttl_prio|\n new_mx_record(domain, conten...
[ "0.56278914", "0.5587419", "0.55569816", "0.5539045", "0.54759395", "0.5458649", "0.5354007", "0.5308939", "0.5194794", "0.519341", "0.5172661", "0.5169908", "0.5164831", "0.5113958", "0.51138276", "0.5112749", "0.510494", "0.510494", "0.5060039", "0.50281835", "0.4986451", ...
0.759342
0
Needed for BASIC auth.
def initialize(url=nil, app_token=nil, headers=nil, password=nil) if not url.nil? @url = url end if not headers.nil? @headers = headers end if not app_token.nil? @app_token = app_token end if not password.nil? @password = password #@password = Base64.decode64(@password_encoded) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def capable_plain_auth?; end", "def http_auth?; end", "def auth_param; end", "def auth(value); end", "def http_auth_login\n # FIXME: Implement\n end", "def http_auth_hash; end", "def valid_for_http_auth?; end", "def basic_auth(opts); end", "def process_auth\n return if username.e...
[ "0.78337425", "0.7721335", "0.745977", "0.7459031", "0.74567896", "0.7366682", "0.7279803", "0.7267096", "0.71507466", "0.71216106", "0.7110395", "0.70317066", "0.7026549", "0.70234555", "0.7010221", "0.7010221", "0.6999582", "0.6999582", "0.69384754", "0.6929665", "0.6866460...
0.0
-1
Fundamental REST API methods:
def POST(data=nil, headers=nil) if not data.nil? #if request data passed in, use it. @data = data end uri = URI(@url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.path) request.body = @data if @search_type == 'premium' request['Authorization'] = "Bearer #{@app_token}" else request.basic_auth(@app_token, @password) end begin response = http.request(request) rescue logger() sleep 5 response = http.request(request) #try again end return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def rest_end_point; end", "def api; end", "def api; end", "def GET; end", "def get; end", "def rest_endpoint=(_arg0); end", "def apis; end", "def http; end", "def rest_token_endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpo...
[ "0.7704782", "0.7333716", "0.71042", "0.71042", "0.7056775", "0.6923904", "0.69045806", "0.6864587", "0.67562145", "0.6656274", "0.66175437", "0.66175437", "0.66175437", "0.66175437", "0.6521443", "0.65020096", "0.65020096", "0.65020096", "0.6461406", "0.6429797", "0.642751",...
0.0
-1
Initializes mongo_rack. Pass in options for default override.
def initialize(app, options={}) super host, port, db_name, cltn_name = parse_server_desc( @default_options[:server] ) @mutex = Mutex.new @connection = ::Mongo::Connection.new( host, port, :pool_size => @default_options[:pool_size], :timeout => @default_options[:pool_timeout] ) @db = @connection.db( db_name ) @sessions = @db[cltn_name] @logger = ::Logger.new( $stdout ) @logger.level = set_log_level( @default_options[:log_level] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_options\n {\n :host => 'localhost',\n :port => Mongo::Connection::DEFAULT_PORT\n }\n end", "def mongodb=(options = {})\n if options.respond_to?(:keys)\n mongodb.port = options[:port] if options[:port]\n mongodb.host = options[:host] ...
[ "0.6971827", "0.6885016", "0.6864397", "0.68434364", "0.6764299", "0.665844", "0.6635276", "0.6432224", "0.641191", "0.6410892", "0.63685095", "0.6346203", "0.6298248", "0.62118423", "0.6206694", "0.6184704", "0.6096594", "0.6056411", "0.6003625", "0.5994437", "0.5955226", ...
0.72428447
0
Fetch session with optional session id. Retrieve session from mongodb if any
def get_session( env, sid ) return _get_session( env, sid ) unless env['rack.multithread'] mutex.synchronize do return _get_session( env, sid ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_session(session_id)\n session = Session.find(:first, :conditions => ['session_id=?', session_id])\n return session\n end", "def find_session(env, sid); end", "def _get_session(env, sid)\n logger.debug \"Getting session info for #{sid.inspect}\"\n if sid\...
[ "0.72872627", "0.72659105", "0.7157519", "0.71179223", "0.7100643", "0.7100643", "0.70402014", "0.6895149", "0.6894149", "0.68487936", "0.6806819", "0.67743635", "0.6764229", "0.67397064", "0.6694158", "0.6694158", "0.66931856", "0.6691595", "0.66478264", "0.65959245", "0.658...
0.6782583
11
Update session params and sync to mongoDB.
def set_session( env, sid, new_session, options ) return _set_session( env, sid, new_session, options ) unless env['rack.multithread'] mutex.synchronize do return _set_session( env, sid, new_session, options ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @session\n @session.update_session(marshalize(@data))\n end\n end", "def update!(**args)\n @session_info = args[:session_info] if args.key?(:session_info)\n end", "def _set_session(env, sid, new_session, options)\n logger.debug \"Setting session #{new_sessio...
[ "0.6666415", "0.63413286", "0.6267413", "0.6248333", "0.61030054", "0.6085092", "0.60247654", "0.59672946", "0.5959882", "0.5911531", "0.58766234", "0.5813328", "0.57611984", "0.57220805", "0.5712111", "0.57028687", "0.5696298", "0.5675262", "0.56745166", "0.5645979", "0.5645...
0.0
-1
Generates unique session id
def generate_sid loop do sid = super break sid unless sessions.find_one( { :_id => sid } ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_new_id\n require 'securerandom'\n begin\n # by OpenSSL, or system provided entropy pool\n session_id = SecureRandom.hex(16)\n rescue NotImplementedError\n # never happens on modern systems\n require 'digest'\n d = Digest('SHA512').new\n now = Time...
[ "0.85316926", "0.83458763", "0.8298293", "0.81053936", "0.8020402", "0.79397106", "0.78987354", "0.7844322", "0.7765848", "0.7710106", "0.7692605", "0.76704866", "0.7627447", "0.7610668", "0.76006633", "0.7568669", "0.7537012", "0.74737036", "0.74585634", "0.7446753", "0.7438...
0.68986255
67