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
Returns true if the integer is not a negative number.
def nonnegative? return self >= 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def negative?\n value < 0\n end", "def is_negative(number)\n if number < 0 \n return true\n end\n return false\nend", "def negative?\n self < 0\n end", "def is_negative(number)\n if number < 0 \n return true\n else return false\n end\nend", "def neg?\n sig...
[ "0.7881126", "0.7790372", "0.772323", "0.77213186", "0.7715048", "0.766447", "0.76474506", "0.76463175", "0.7626655", "0.76182604", "0.7567973", "0.75263387", "0.75194365", "0.74946266", "0.7449626", "0.74372876", "0.7436601", "0.7385241", "0.7377311", "0.73387814", "0.730993...
0.77484334
2
Returns true iff the string is affirmative/positive.
def is_positive? return POSITIVE_RESPONSES.include?(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def potential_false_positive?\n content.strip =~ CC_FALSE_POSITIVE_REGEX\n end", "def negative?(string)\n true if string.start_with?('-')\nend", "def comment_affirmative?(comment)\n !!(comment =~ /(^lgtm$)|(^:\\+1:\\s+$)|(^:ok:\\s+$)|(^looks\\s+good(?:\\s+to\\s+me)?$)|(^:shipit:\\s+$)|(^:rocket...
[ "0.6049818", "0.59708583", "0.59435666", "0.5931404", "0.5916779", "0.5878877", "0.5810991", "0.5801396", "0.5710757", "0.57016414", "0.56614107", "0.5659417", "0.5642817", "0.56283987", "0.56076163", "0.5591935", "0.5577227", "0.55671316", "0.5562497", "0.55403537", "0.55303...
0.5411449
29
Returns true iff the string is negatory/negative.
def is_negative? return NEGATIVE_RESPONSES.include?(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def negative?(string)\n true if string.start_with?('-')\nend", "def is_negated_sentence?\n index = 1\n if @classified[index] && LogicalOperator::REGEX_UNARY.match(@classified[index].value)\n return true\n end\n false\n end", "def potential_false_positive?\n content.strip =~ CC_FALSE_P...
[ "0.775215", "0.7084375", "0.6991796", "0.6927339", "0.69198525", "0.6892861", "0.67754036", "0.6662945", "0.6638801", "0.65187556", "0.646009", "0.646009", "0.6456951", "0.64551115", "0.64528155", "0.6382173", "0.6379558", "0.6379417", "0.63708305", "0.63440305", "0.6292276",...
0.0
-1
the method used to actually define the headers of the columns, taking the name of the attribute and a hash of options. The following options are evaluated here: :th_html:: a hash with htmlattributes added to the s created :header:: if present, the value will be output in the header cell, otherwise, the capitalized name is used
def header_association(relation, name, opts={}, &block) raise "Not in header mode!" if @row_mode != :header opts = normalize_column_options(name, opts) if opts[:sortable] and @table_options[:sortable] # change classes accordingly end make_tag(:th, opts[:th_html]) do concat(t(opts[:header] || "#{relation.to_s.humanize.titlecase} #{name.to_s.humanize.titlecase}"), :escape_html) end # </th> end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grid_head_data_headers(cols: nil, **opt, &block)\n start_column = positive(opt.delete(:'aria-colindex')) || 1\n (cols || grid_row_columns).map.with_index(start_column) do |col, idx|\n grid_head_cell(col, **opt, 'aria-colindex': idx, &block)\n end\n end", "def datagrid_header(grid, options = {}...
[ "0.7083747", "0.70706123", "0.7004658", "0.68664557", "0.68338674", "0.6797143", "0.67545974", "0.67545974", "0.671215", "0.6690526", "0.6682058", "0.6650024", "0.6612019", "0.6609378", "0.66082096", "0.6601234", "0.65641326", "0.65579003", "0.65073013", "0.64780945", "0.6439...
0.7293132
0
Todo use Database list instead
def list_addons Dir.glob("/var/lib/apollo/addons/*.gem") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def db_listing\n lista = [] \n achado = $db.query \"SELECT * FROM produtos\" \n achado.each do |vals| \n lista.push vals\n end\n return lista\nend", "def set_databaselist\n @databaselist = DatabaseList.find(params[:id])\n end", "def list\n\t\tdocs = proxy_database.view(\"#{shared_...
[ "0.66340065", "0.62902397", "0.6214556", "0.62141997", "0.6128124", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", "0.6093635", ...
0.0
-1
Register a block for the given hook_name
def register_hook(hook_name, block) hooks_for(hook_name).each do |blk| # Simple but effective proc compartion return nil if blk.source_location == block.source_location end hooks_for(hook_name) << block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_hook(name, &block)\n hooks[name.to_sym] ||= []\n hooks[name.to_sym] << block\n end", "def register(plugin_name, hook_name, &block)\n @registrations ||= {}\n @registrations[hook_name] ||= []\n @registrations[hook_name] << Hook.new(hook_name, plugin_name, block)\n ...
[ "0.82826465", "0.768479", "0.7673934", "0.75480956", "0.7406499", "0.7315303", "0.7199191", "0.719309", "0.70262396", "0.70031404", "0.6959886", "0.68377876", "0.6768326", "0.67465055", "0.67101824", "0.6650343", "0.6634738", "0.66164833", "0.6574998", "0.65531075", "0.654966...
0.84524316
0
cuts fine the high quality bounds
def cut_fine_bounds(qual,new_start,new_end) # puts " ççççççççççççççç #{new_start+@window} >= #{new_end} " # puts " #{new_start} #{new_end} .o.o.o.o.o.o.o.o1" # cut it fine one_ok = 0 i=@window-1 # puts " qual[new_start+i] new_start #{new_start} i #{i} = #{new_start+i} qual.size #{qual.size}" while (i>=0) if (qual[new_start+i] < @low) break if one_ok else one_ok = 1 end i-=1 end new_start += i+1 oneOk = 0 i=0 while (i<@window) if (qual[new_end+i] < @low) break if oneOk else oneOk = 1 end i+=1 end new_end += i-1 # puts "6b new_start #{new_start} new-end #{new_end}" # puts " #{new_start} #{new_end} .o.o.o.o.o.o.o.o2" return new_start, new_end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cut_factor\r\n return 0.0\r\n end", "def cutoffs\n end", "def initial_cut_values\n end", "def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end", "def cut_position\n 0 #no cut\n end", "def cutoffs\n return [] if averages.length < 20\n\n # TODO: Take tr...
[ "0.7186853", "0.70316726", "0.6390188", "0.6247901", "0.62024844", "0.60085034", "0.59990305", "0.59886754", "0.5871869", "0.5828802", "0.57932955", "0.5785665", "0.5780534", "0.5767909", "0.5765214", "0.5728367", "0.5720654", "0.570516", "0.56893176", "0.5639827", "0.562344"...
0.74302137
0
Begins the plugin1's execution whit the sequence "seq" Creates an action by each subsequence with low quality to eliminate it A subsequence has low quality if (the add of all its qualitis < subsequence_size20) Creates the qualities windows from the sequence, looks for the subsequence with high quality and mark, with an action, the before part to the High Quality Subsequence like a low quality part Finally mark, with an action, the after part to the High Quality Subsequence like a low quality part
def exec_seq(seq,blast_query) if ((self.class.to_s=='PluginLowQuality') && seq.seq_qual.nil? ) $LOG.error " Quality File haven't been provided. It's impossible to execute " + self.class.to_s elsif (seq.seq_qual.size>0) $LOG.debug "[#{self.class.to_s}, seq: #{seq.seq_name}]: checking low quality of the sequence" @low=@params.get_param('min_quality').to_i if @params.get_param('window_width').to_i>seq.seq_fasta.length @window=seq.seq_fasta.length else @window=@params.get_param('window_width').to_i end @cut_off=@window*@low type='ActionLowQuality' low_qual=0 actions=[] p_begin,p_end =0,-1 # positions from high quality bounds while ((p_begin>=0) && (p_end + 1 < seq.seq_qual.size) ) p_begin_old,p_end_old= p_begin, p_end p_begin,p_end = find_high_quality(seq.seq_qual,p_end+1) if ((p_begin>0) && (p_begin-p_end_old-1>=@window/2)) #if we have found the high quality part, and the low quality part has enough size # it's created an action before of the high quality part add_action_before_high_qual(p_begin,p_end,actions,seq,p_end_old+1) # puts "low1 ini fin #{p_end_old+1} #{p_begin-1} = #{p_begin-1-p_end_old-1+1}" low_qual = p_begin-1-p_end_old-1 + 1 add_stats('low_qual',low_qual) # @stats[:low_qual]={low_qual => 1} end # puts "-----ññññ----- high quality #{p_begin} #{p_end}+#{seq.insert_start} seq size #{seq.seq_fasta.size}" end # puts "high [#{p_begin}, #{p_end}] old [#{p_begin_old}, #{p_end_old}] size #{seq.seq_qual.size}" if ((p_begin>=0) && (p_end+1<seq.seq_qual.size)) #if we have found the high quality part # it's created an action after of the high quality part add_action_after_high_qual(p_begin,p_end,actions,seq) # puts "low2 ini fin #{p_end+1} #{seq.seq_fasta.size-1} = #{seq.seq_fasta.size-1-p_end-1+1}" low_qual = seq.seq_fasta.size-1 - p_end-seq.insert_start-1 + 1 # if @stats[:low_qual][low_qual].nil? # @stats[:low_qual][low_qual] = 0 # end # @stats[:low_qual][low_qual] += 1 add_stats('low_qual',low_qual) # @stats[:low_qual]={low_qual => 1} end # puts "-----ññññ----- high quality #{p_begin} #{p_end}" if p_end<0 and p_end_old #add action low qual to all the part a = seq.new_action(p_end_old+1 ,seq.seq_fasta.size-1,"ActionLowQuality") # adds the ActionInsert to the sequence before adding the actionMid # puts "new low qual start: #{p_end_old+1} end: #{seq.seq_fasta.size-1} = #{seq.seq_fasta.size-1 - p_end_old-1 + 1}" low_qual = seq.seq_fasta.size-1 - p_end_old-1 + 1 # if @stats[:low_qual][low_qual].nil? # @stats[:low_qual][low_qual] = 0 # end # @stats[:low_qual][low_qual] += 1 add_stats('low_qual',low_qual) # @stats[:low_qual]={'low_qual' => 1} actions.push a end # puts "------- ADDING ACTIONs LOW QUAL #{actions.size}" seq.add_actions(actions) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exec_seq(seq,blast_query)\n\n if ((self.class.to_s=='PluginLowQuality') && seq.seq_qual.nil? ) \n $LOG.debug \" Quality File haven't been provided. It's impossible to execute \" + self.class.to_s \n elsif ((seq.seq_qual.size>0) && (@params.get_param('use_qual').to_s=='true'))\n \n ...
[ "0.723205", "0.5806966", "0.558916", "0.5545389", "0.534961", "0.5293338", "0.52256083", "0.5117753", "0.5093442", "0.50143725", "0.5011357", "0.50105375", "0.50037885", "0.4993269", "0.49479097", "0.49301416", "0.49084014", "0.48958617", "0.48868892", "0.48779353", "0.487655...
0.72228235
1
Returns true if the specified plugin is enabled, false otherwise.
def plugin_enabled?(plugin_name) !!@config['plugins'][plugin_name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plugin_disabled?\n if config['enabled']\n false\n else\n true\n end\n end", "def plugin_disabled?\n if config['enabled']\n false\n else\n true\n end\n end", "def enabled?\n !!configuration.enabled\n end", "def enabled?\n ...
[ "0.77581686", "0.77217394", "0.74848926", "0.7299643", "0.72848415", "0.72188413", "0.7179726", "0.7112248", "0.7112248", "0.7112248", "0.7112248", "0.7108847", "0.7104546", "0.70966214", "0.70966214", "0.7082719", "0.706945", "0.7054058", "0.7054058", "0.70495534", "0.704517...
0.84003806
0
Returns a hash containing :user => username string, :pass => password string for the MySQL application user, as found in Jetpants' configuration. Plugins may freely override this if there's a better way to obtain this password for example, if you already distribute an application configuration or credentials file to all of your servers.
def app_credentials {user: @config['mysql_app_user'], pass: @config['mysql_app_password']} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n config = { database: database, hosts: hosts }\n if username && password\n config.merge!(username: username, password: password)\n end\n config\n end", "def to_hash\n config = { database: database, hosts: hosts }\n if username && password\n config...
[ "0.67533314", "0.67316407", "0.6652198", "0.6623854", "0.6561693", "0.6483461", "0.64666855", "0.6455614", "0.63117456", "0.62374747", "0.6230079", "0.6203029", "0.6201706", "0.61851525", "0.6171335", "0.6124925", "0.611028", "0.60022724", "0.5977721", "0.595088", "0.59344023...
0.7280355
0
Returns a hash containing :user => username string, :pass => password string for the MySQL replication user, as found in Jetpants' configuration. Plugins may freely override this if there's a better way to obtain this password for example, by parsing master.info on a specific slave in your topology. SEE ALSO: DBreplication_credentials, which only falls back to the global version when needed.
def replication_credentials {user: @config['mysql_repl_user'], pass: @config['mysql_repl_password']} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replication_credentials\n user = false\n pass = false\n if master || slaves.count > 0\n target = (@master ? self : @slaves[0])\n results = target.ssh_cmd(\"cat #{mysql_directory}/master.info | head -6 | tail -2\").split\n if results.count == 2 && results[0] != 'test'\n ...
[ "0.82047504", "0.6811308", "0.66757125", "0.6653264", "0.66091245", "0.6567035", "0.639987", "0.62575996", "0.6252973", "0.62146264", "0.6196669", "0.6170164", "0.61139715", "0.61079663", "0.60533905", "0.6035386", "0.6023309", "0.59609324", "0.5910032", "0.588732", "0.588021...
0.80047894
1
Proxy missing toplevel Jetpants methods to the configuration hash, or failing that, to the Topology singleton.
def method_missing(name, *args, &block) if @config.has_key? name.to_s @config[name.to_s] elsif name.to_s[-1] == '=' && @config.has_key?(name.to_s[0..-2]) var = name.to_s[0..-2] @config[var] = args[0] elsif @topology.respond_to? name @topology.send name, *args, &block else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure; end", "def configure\n not_implemented(__method__)\n end", "def method_missing(missing_method_name, *args, &block)\n if 'cfg' == missing_method_name.to_s\n self.config.settings\n else\n super\n end\n end", "def configure\n # do nothing\n end"...
[ "0.55934346", "0.5531349", "0.5352243", "0.5295676", "0.523009", "0.52298117", "0.5206412", "0.52019745", "0.51876426", "0.5178877", "0.5178877", "0.51560086", "0.51327914", "0.51295364", "0.512569", "0.50958014", "0.5061046", "0.5058298", "0.5058298", "0.5058298", "0.5058298...
0.5102874
15
GET /advisers GET /advisers.json
def index @advisers = Adviser.reserved_by(current_user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @advisers = Adviser.page params[:page]\n end", "def show\n render json: @adopter\n end", "def index\n @advertisements = Advertisement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advertisements }\n end\n end", "def index\n...
[ "0.71431476", "0.683159", "0.6669862", "0.6669862", "0.66464174", "0.6616483", "0.6613734", "0.65568036", "0.65376043", "0.6484491", "0.6403133", "0.64011467", "0.6373983", "0.6362798", "0.63521874", "0.63482106", "0.6293622", "0.6291916", "0.62839955", "0.627306", "0.6259305...
0.6734751
2
GET /advisers/1 GET /advisers/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @advisers = Adviser.page params[:page]\n end", "def show\n render json: @adopter\n end", "def show\n @advertisement = Advertisement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advertisement }\n end\n end", "d...
[ "0.67883873", "0.6725822", "0.65790814", "0.652938", "0.6529224", "0.6529224", "0.63835746", "0.63743854", "0.63439417", "0.63340205", "0.63168466", "0.62942535", "0.6292849", "0.62925696", "0.6282792", "0.6256289", "0.6247579", "0.62382615", "0.623637", "0.62350523", "0.6219...
0.0
-1
POST /advisers POST /advisers.json
def create @adviser = Adviser.new(adviser_params) respond_to do |format| if @adviser.save format.html { redirect_to @adviser, notice: 'Adviser was successfully created.' } format.json { render :show, status: :created, location: @adviser } else format.html { render :new } format.json { render json: @adviser.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @adopter = Adopter.new(adopter_params)\n\n if @adopter.save\n render json: @adopter, status: :created, location: @adopter\n else\n render json: @adopter.errors, status: :unprocessable_entity\n end\n end", "def create\n @adviser = Adviser.new adviser_params\n\n if @advise...
[ "0.6638861", "0.6627731", "0.6205557", "0.6039927", "0.5892265", "0.5884094", "0.5879558", "0.58572865", "0.58458966", "0.58453405", "0.57965463", "0.5794671", "0.5786513", "0.57818854", "0.5732793", "0.5731817", "0.5721102", "0.5717963", "0.57056284", "0.5703016", "0.5701682...
0.71945715
0
PATCH/PUT /advisers/1 PATCH/PUT /advisers/1.json
def update respond_to do |format| if @adviser.update(adviser_params) format.html { redirect_to @adviser, notice: 'Adviser was successfully updated.' } format.json { render :show, status: :ok, location: @adviser } else format.html { render :edit } format.json { render json: @adviser.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @adopter = Adopter.find(params[:id])\n\n if @adopter.update(adopter_params)\n head :no_content\n else\n render json: @adopter.errors, status: :unprocessable_entity\n end\n end", "def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n ...
[ "0.66067034", "0.63921857", "0.63143355", "0.62960464", "0.6241952", "0.6202694", "0.6186607", "0.6166868", "0.6150689", "0.6118127", "0.6116926", "0.6078653", "0.6063427", "0.60560983", "0.6043763", "0.60241425", "0.6009438", "0.6000823", "0.5996957", "0.5970959", "0.5968632...
0.67159724
0
DELETE /advisers/1 DELETE /advisers/1.json
def destroy @adviser.destroy respond_to do |format| format.html { redirect_to advisers_url, notice: 'Adviser was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def advisor_destroy\n @advisor.destroy\n respond_to do |format|\n form...
[ "0.713061", "0.7000745", "0.6976171", "0.6936827", "0.6867224", "0.6828198", "0.6797921", "0.6785375", "0.6776823", "0.67755663", "0.67755663", "0.6756988", "0.6742134", "0.67343664", "0.6718671", "0.6712131", "0.66957814", "0.6676033", "0.6655355", "0.6653049", "0.6649165", ...
0.72985536
0
Use callbacks to share common setup or constraints between actions.
def set_adviser @adviser = Adviser.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def adviser_params params.require(:adviser).permit(:name, :comment, :avator, :min_age, :max_age, :day, :start_time, :end_time) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_etoken @etokendetail = ETokenDetail.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Return this object as a string.
def to_s "#<Vec:0x%x @x=%f, @y=%f, @z=%f>" % [self.object_id, self.x, self.y, self.z] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @string ||= Builder::ToString.new(self).string\n end", "def to_s\n object.to_s\n end", "def to_s\n self\n end", "def to_s\n @object.to_s\n end", "def to_s\n self.inspect\n end", "def to_s\n\t\t\t@string\n\t\tend", "def to_s\n @string\n ...
[ "0.85639936", "0.84404683", "0.841758", "0.84075266", "0.8327311", "0.8317891", "0.82580745", "0.82580745", "0.82580745", "0.82580745", "0.8212347", "0.8209762", "0.8209762", "0.8209762", "0.8209762", "0.81663775", "0.81581295", "0.81581295", "0.8156842", "0.80683845", "0.805...
0.0
-1
Return x, y and z values of this object as an array.
def to_a [self.x, self.y, self.z] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_a\n [@x, @y, @z]\n end", "def to_ary\n [@x, @y, @z]\n end", "def xyz\n return [self.x,self.y,self.z]\n end", "def to_a\n [@x, @y, @z]\n end", "def to_a\n [x, y, z]\n end", "def to_xyz\n [x, y, z]\n end", "def xyz\n [x, y,...
[ "0.8335534", "0.82297295", "0.8080773", "0.8051961", "0.78918016", "0.7709333", "0.76071274", "0.7509479", "0.7479183", "0.7403998", "0.72254246", "0.7167434", "0.71556437", "0.7147853", "0.6971585", "0.6971585", "0.69025046", "0.69025046", "0.6870183", "0.68352395", "0.67477...
0.8575445
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notification_mailer.notice.subject
def notice(notification) @notification = notification mail to: @notification.user_email, :subject => "Cipher-tech wants you to know: #{@notification.notifier_type} #{@notification.message}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def translate(mapping, key)\n I...
[ "0.68688095", "0.6837246", "0.676314", "0.6580562", "0.65329504", "0.64362967", "0.634487", "0.6333099", "0.62832355", "0.62079734", "0.6198489", "0.6184978", "0.616909", "0.60781634", "0.6025514", "0.60243225", "0.6014449", "0.60121155", "0.5971", "0.59245324", "0.5904601", ...
0.6034975
14
en g3 tenemos la tabla de la multiplicacion Galoisx3
def g3 [0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11, 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41, 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1, 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a][self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_table\n dimension_length = (@numbers_to_multiply.length - 1)\n @multiplication_table = []\n new_table_row = [\" \"]\n\n for i in 0..dimension_length\n new_table_row << @numbers_to_multiply[i]\n end\n\n new_table_row\n @multiplication_table << new_table_row\n\n for x in 0..di...
[ "0.6958807", "0.63267756", "0.63126343", "0.629004", "0.6289271", "0.62454337", "0.6224622", "0.61331606", "0.6109414", "0.61064124", "0.5934183", "0.5904126", "0.58408326", "0.5746665", "0.57442266", "0.57294863", "0.57231283", "0.5691494", "0.5681615", "0.5668103", "0.56629...
0.0
-1
como es la implementacion de 128 bits, solo necesitamos la primera fila de rcon
def rcon [0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a][self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bit_small; @bit_small ||= gbit(8) end", "def xor_d8\n end", "def compute_need_bits; end", "def rc4_initialize(key)\r\n @q1 = 0\r\n @q2 = 0\r\n @key = []\r\n key.each_byte { |elem| @key << elem } while @key.size < 256\r\n @key.slice!(256..@key.size - 1) if @key.size >= 256\r\n ...
[ "0.61207885", "0.61158025", "0.6054908", "0.6038625", "0.6000557", "0.5963241", "0.5963241", "0.5948528", "0.5906979", "0.58483547", "0.57699984", "0.57565534", "0.57488954", "0.57353264", "0.57238746", "0.5704699", "0.57015884", "0.56914073", "0.5690158", "0.5677681", "0.567...
0.63782376
0
desplazamiento de las filas
def shift_rows [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11].map { |i| self[i] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setear_fijos_arbol\n # @incisos = Inciso.all\n # @partidas_principales = PartidaPrincipal.all\n # @partidas_parciales = PartidaParcial.all \n @clases = Clase.where(\"fecha_de_baja IS NULL\")\n @bienes_de_consumo = BienDeConsumo.where(\"fecha_de_baja IS NULL\")\n end"...
[ "0.6311864", "0.62465155", "0.6132851", "0.5878293", "0.5826968", "0.5787664", "0.5752299", "0.5742479", "0.57248956", "0.56858164", "0.55896497", "0.5565639", "0.55529046", "0.55434394", "0.5504694", "0.54820365", "0.5439687", "0.5433332", "0.5430732", "0.5419794", "0.541847...
0.0
-1
sustitucion de bytes, se busca en la SCaja el indice correspondiente
def sub_bytes # map{|i|i.sbox} map(&:sbox) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getbyte()\n #This is a stub, used for indexing\n end", "def bytes()\n #This is a stub, used for indexing\n end", "def getbyte\n end", "def getbyte\n end", "def get_byte(offset) datap[offset].unpack('C*')[0] end", "def read_data_byte(offset) [offset + 1, get_byte(offset)] end", ...
[ "0.7076473", "0.69375384", "0.6843885", "0.6843885", "0.6742966", "0.65990657", "0.6597863", "0.6585154", "0.64334905", "0.6418498", "0.6396806", "0.634322", "0.6317727", "0.62986565", "0.62573653", "0.62482226", "0.6228743", "0.6225314", "0.61957204", "0.61878735", "0.617731...
0.6922624
2
La matriz de multiplicaion es: 2 3 1 1 1 2 3 1 1 1 2 3 3 1 1 2
def mix_col a0, a1, a2, a3 = self [a0.g2 ^ a1.g3 ^ a2 ^ a3, # r0 = 2a0 + 3a1 + 1a2 + 1a3 a0 ^ a1.g2 ^ a2.g3 ^ a3, # r1 = 1a0 + 2a1 + 3a2 + 1a3 a0 ^ a1 ^ a2.g2 ^ a3.g3, # r2 = 1a0 + 1a1 + 2a2 + 3a3 a0.g3 ^ a1 ^ a2 ^ a3.g2] # r3 = 3a0 + 1a1 + 1a2 + 2a3 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mult(a)\n c=Matriz.new(@n,@m,[0,0],[0,0])\n for i in 0...@n do\n for j in 0...@m do\n c.A[i][j]=@A[i][j]*a\n end\n end\n c\n end", "def *(mat)\n if (@c == mat.f)\n result = Array.new\n for i in 0...@f do\n result[i] = Array.new\n for j in 0...@c do\n ...
[ "0.7148681", "0.6920143", "0.6694497", "0.66417146", "0.65745133", "0.63225454", "0.6318604", "0.6216598", "0.6182438", "0.6175589", "0.6127744", "0.61247486", "0.61178786", "0.60985655", "0.607847", "0.6074983", "0.6053661", "0.6048111", "0.603207", "0.6023847", "0.6006296",...
0.0
-1
Only based on file_size, time is in another thread
def should_commit?(segregation) seg = @segregations[segregation] if @size_file > 0 and seg[:file_pointers][seg[:current_page]].size > @size_file @logger.info("S3> should_commit: upload because of size") return true end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upd_folder_size\n \n @t1 = Thread.new{ \n \n @time_samples = []\n \n puts \"in upd_folder_size...\"\n prev_size = 0\n loop {\n puts \"in loop each 2 secs\"\n this_size = 0\n @fen_d.children.each { |pn|\n this_size += (pn.size? || 0) if pn.file?\n }\n @time_sam...
[ "0.68119997", "0.68119997", "0.63783795", "0.62276334", "0.61928046", "0.60742056", "0.6061868", "0.6060305", "0.60260296", "0.6024048", "0.60169905", "0.59717345", "0.5912999", "0.5906724", "0.5906724", "0.58753955", "0.5829003", "0.5826475", "0.57849056", "0.5748649", "0.57...
0.0
-1
defines attack power of weapon calling it in
def attack(weapon) rand(10) + weapon.power end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def melee_weapon; end", "def skill_effect_power(user, skill)\r\n power = skill.power + user.atk * skill.atk_f / 100\r\n if power > 0\r\n power -= self.pdef * skill.pdef_f / 200\r\n power -= self.mdef * skill.mdef_f / 200\r\n power = [power, 0].max\r\n end\r\n return power\r\n end", ...
[ "0.79050213", "0.7747055", "0.76487255", "0.75713044", "0.7534121", "0.7389856", "0.73322654", "0.72724485", "0.72724485", "0.72724485", "0.71723235", "0.7163409", "0.7155564", "0.713311", "0.7086691", "0.70820904", "0.69554657", "0.6909916", "0.68693453", "0.6843656", "0.683...
0.7977906
0
agree to bandit's favor and start this story
def entrance_decision_enter_cave_intimidate puts "************************************************************" puts "Bandit: oh? so you think you're tough? Tell you what, you defeat me and I'll give you my sword and free passage." puts "You get in a brawl with the bandit leader and win." puts "Bandit: Argh. no more please. you can go in the cave just please no more." puts "Bandit sword equipped" puts "Bandit Sword power: 20" @enter_cave = true @bandit_beat = true @bandit_blade = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_bridge_quest\n slowly do\n\"\"\"\nWhat should Duncan do? \n There's bacon!! Dash across that bridge and hunt! -- Press 1\n Carefully approach and investigate the scenario. -- Press 2\n Use special power! -- Press 3\n\"\"\" \n end\n end", "def start!\n fail(Api::V3::DecisionReviews::St...
[ "0.6598366", "0.6039374", "0.5993872", "0.58562845", "0.58427197", "0.58426493", "0.582788", "0.5823663", "0.5804023", "0.579267", "0.57371217", "0.5722689", "0.5722689", "0.5722689", "0.5717217", "0.5699157", "0.56796086", "0.56696194", "0.5668821", "0.5666516", "0.5665928",...
0.55397743
39
hunter run away story agree to task
def entrance_decision_enter_cave_money puts "************************************************************" puts "Bandit: Ha! You sad poor bum! well if you really want to do get into this cave then I need you to do me a favor. interested?" puts "type yes, no, or what kind of favor?" while user_input = gets.chomp.downcase.rstrip.lstrip # loop while getting user input case user_input when "what kind of favor?" puts "Bandit: Don't worry about it! now are you in or are you out?" puts "type yes or no" when "yes" bandit_favor break when "no" puts "Bandit: Get the hell out of here before I get pissed." run_away_story break else puts "Please type yes, no, or what kind of favor? only!" # print the prompt, so the user knows to re-enter input end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def explain_true(task); end", "def explain_false(task); end", "def runner; end", "def unrun\n log \"Nothing to do.\"\n end", "def task\n end", "def task()\n world = Robota::World\n world.read_world(\"../karel/empty.map\")\n \n karel = Question3.new(1, 1, Robota::NORTH, 1)\n karel2 = Que...
[ "0.61179453", "0.6104812", "0.60765177", "0.606553", "0.59957945", "0.597583", "0.58894306", "0.5866626", "0.58137697", "0.58080405", "0.5804556", "0.5804556", "0.5799922", "0.5798359", "0.57974863", "0.57590675", "0.57535154", "0.5752506", "0.5752506", "0.5752506", "0.572531...
0.0
-1
Get the file path to output the js based on the file being built. The output path is relative to where guard is being run.
def get_output(file) file_dir = File.dirname(file) file_name = File.basename(file).split('.')[0..-2].join('.') unless file_name =~ /\.js$/ file_name << ".js" end file_dir = file_dir.gsub(Regexp.new("#{@options[:input]}(\/){0,1}"), '') if @options[:input] file_dir = File.join(@options[:output], file_dir) if @options[:output] if file_dir == '' file_name else File.join(file_dir, file_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_file_relative_path\n case app_type\n when 'react' then 'src/App.js'\n else \"app.js\"\n end\n end", "def min_file_path\n compiled_path || current_file_path\n end", "def output_directory_path\n if @output_directory.nil?\n directory = File.join(Rails.root, 'script')\n e...
[ "0.7439646", "0.6925266", "0.68200505", "0.68200505", "0.6777334", "0.66875744", "0.662785", "0.6620004", "0.6611387", "0.6569362", "0.6525306", "0.6393457", "0.63900155", "0.63803333", "0.63761437", "0.6309383", "0.62982816", "0.62811136", "0.62769955", "0.6234619", "0.62156...
0.72546166
1
This method changes the current working directory and is expected to only be called on failure.
def print_logs(dir) Dir.chdir(dir) `tar xzvf *.tgz` puts `cat benchmarks/*.log` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chdir; end", "def excel_change_directory(new_wd)\n new_wd = File.expand_path(new_wd)\n raise ExcelError.new(\"Cannot change working directory - '#{new_wd}' does not exist\") unless File.exist?(new_wd)\n\n begin\n orig_wd_w = Converter.to_windows_path(Dir.pwd)\n new_wd_w = Convert...
[ "0.68388975", "0.67206544", "0.6552479", "0.6545177", "0.65362006", "0.64169693", "0.63286334", "0.63179463", "0.63160914", "0.6280584", "0.62431735", "0.6086282", "0.6075103", "0.60471594", "0.6021106", "0.59786123", "0.5965951", "0.5949556", "0.59077287", "0.5893211", "0.58...
0.0
-1
TODO: use most_recently_updated_products when SelectWithModal updated
def buyers BuyerDecorator.decorate_collection(raw_buyers) .map(&:new_application_data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_version_select \n versions = Version.where(:product_id => params[:id]).order(:version) unless params[:id].blank?\n render :partial => \"versions\", :locals => { :versions => versions }\n end", "def get_products_selected\n raise \"expecting knowledge to be set\" unless @current_knowled...
[ "0.63044727", "0.6182841", "0.61034477", "0.6069368", "0.6043629", "0.60099846", "0.59375066", "0.59321016", "0.5916352", "0.591597", "0.59028727", "0.586576", "0.5858987", "0.5841421", "0.58215576", "0.58090025", "0.5799752", "0.5727355", "0.5710853", "0.56959176", "0.566369...
0.0
-1
TODO: use most_recently_updated_products when SelectWithModal updated
def products ServiceDecorator.decorate_collection(raw_products) .map(&:new_application_data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_version_select \n versions = Version.where(:product_id => params[:id]).order(:version) unless params[:id].blank?\n render :partial => \"versions\", :locals => { :versions => versions }\n end", "def get_products_selected\n raise \"expecting knowledge to be set\" unless @current_knowled...
[ "0.63050437", "0.6185222", "0.61048293", "0.6070713", "0.60430247", "0.60103804", "0.5938764", "0.59338534", "0.591773", "0.5917383", "0.59027296", "0.58663243", "0.58617824", "0.58431625", "0.58222073", "0.58106303", "0.5802056", "0.572816", "0.57115877", "0.5698697", "0.566...
0.0
-1
Starts the parsing and send each parsed item through its block. Usage: feed.block_while_parsing do |item| puts item.link end
def parse(&block) @block = block puts "Parsing #{xml_url}" @parser.parse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block_while_parsing(&block)\n @parsed = false\n parse(&block)\n NSRunLoop.currentRunLoop.runUntilDate(NSDate.distantFuture)\n end", "def each(&block)\n parse.each(&block)\n end", "def parse_loop!\n catch :stop do\n loop do\n parse!\n end\n end\n ...
[ "0.6609162", "0.6598775", "0.6447107", "0.6424853", "0.62081075", "0.61740524", "0.6167954", "0.61452657", "0.6042727", "0.5933327", "0.5919884", "0.58522564", "0.582255", "0.5779989", "0.5763085", "0.5758381", "0.5758381", "0.57516587", "0.5723449", "0.57057655", "0.5703027"...
0.67877555
0
Starts the parsing but keep block the main runloop until the parsing is done. Do not use this method in a GUI app. use parse instead.
def block_while_parsing(&block) @parsed = false parse(&block) NSRunLoop.currentRunLoop.runUntilDate(NSDate.distantFuture) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start\n parse!\n run\n end", "def parse_loop!\n catch :stop do\n loop do\n parse!\n end\n end\n end", "def register_parsing_thread\n @parser_thread = Thread.new { parser.parse }\n end", "def start\n @cmd.parse\n end", "def sta...
[ "0.81302416", "0.68834996", "0.68038154", "0.67565143", "0.67275304", "0.6502049", "0.63343847", "0.61940914", "0.6096319", "0.6087762", "0.6083373", "0.6054436", "0.60471606", "0.59694886", "0.5953991", "0.5947588", "0.5899494", "0.5892", "0.5892", "0.5892", "0.58864355", ...
0.67244077
5
Delegate getting called when parsing starts
def parserDidStartDocument(parser) puts "starting parsing.." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_parse; end", "def after_parse; end", "def after_parse\n end", "def parsed; end", "def parsed; end", "def parse\n end", "def parse; end", "def parse; end", "def parse; end", "def parser; end", "def parser; end", "def parser; end", "def parser; end", "def after_parse_callbacks...
[ "0.7981116", "0.7981116", "0.7899573", "0.7360422", "0.7360422", "0.7192568", "0.71316516", "0.71316516", "0.71316516", "0.69915193", "0.69915193", "0.69915193", "0.69915193", "0.6979689", "0.6962986", "0.67637295", "0.670452", "0.66378975", "0.6593159", "0.6571546", "0.65634...
0.73277575
5
Delegate being called when an element starts being processed
def parser(parser, didStartElement:element, namespaceURI:uri, qualifiedName:name, attributes:attrs) if element == 'item' @current_item = RSSItem.new elsif element == 'enclosure' @current_item.enclosure = attrs end @current_element = element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_begin(node); end", "def on_start(span)\n # noop\n end", "def on_start\n yield self\n end", "def after_processing\n end", "def on_start(_klass, _method); end", "def parserDidStartDocument(parser)\n puts \"starting parsing..\"\n end", "def after_processing_ho...
[ "0.6063394", "0.6026945", "0.6001979", "0.58562934", "0.5770506", "0.57270634", "0.56991756", "0.56859916", "0.5574861", "0.5571298", "0.5570372", "0.5544183", "0.5526519", "0.55251837", "0.55040973", "0.5488826", "0.5444391", "0.5423596", "0.53608894", "0.53583133", "0.53287...
0.5026305
62
as the parser finds characters, this method is being called
def parser(parser, foundCharacters:string) if @current_item && @current_item.respond_to?(@current_element) el = @current_item.send(@current_element) el << string end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_characters(chars)\n end", "def find_char\n if @match == true\n find_array\n remove_miss_match_words\n @match == false\n else\n remove_miss_match_words\n end\n\n @chars = analysis\n\n #for short words do\n if @remain > 1\n find_main_ch...
[ "0.6806106", "0.65109724", "0.6300259", "0.62845397", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.61712265", "0.6171185", "0.6171185", "0.6171185", "0.6171185", "0.6171185", "0.6171185", "0.6...
0.54938084
68
method called when an element is done being parsed
def parser(parser, didEndElement:element, namespaceURI:uri, qualifiedName:name) if element == 'item' @items << @current_item end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parserDidEndDocument(parser)\n @parsed = true\n puts \"done parsing\"\n if @block\n @items.each{|item| @block.call(item)}\n end\n end", "def after_parse\n end", "def end_element(name)\n clear_characters_buffer\n if @elem\n if @elem.parent == @doc\n # If we're ...
[ "0.67255676", "0.6588596", "0.6557112", "0.6548466", "0.6548466", "0.6349047", "0.6349047", "0.6235774", "0.61254543", "0.6084347", "0.5955655", "0.5824718", "0.58027667", "0.57308453", "0.5720197", "0.570194", "0.5658031", "0.5656084", "0.5649964", "0.5649964", "0.5646266", ...
0.5062645
82
delegate getting called when the parsing is done If a block was set, it will be called on each parsed items
def parserDidEndDocument(parser) @parsed = true puts "done parsing" if @block @items.each{|item| @block.call(item)} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_parse(&block)\n after_parse_callbacks.push(block)\n end", "def parsed(&block)\n parse unless @parsed\n block.call\n end", "def after_parse\n end", "def each(&block)\n parse.each(&block)\n end", "def after_parse; end", "def after_parse; end", "def parse(&block)\...
[ "0.75788873", "0.72236335", "0.69017196", "0.68864083", "0.68799114", "0.68799114", "0.6613421", "0.65548104", "0.6494689", "0.64247555", "0.6391611", "0.6364123", "0.6331894", "0.6331894", "0.63280797", "0.6309434", "0.6291706", "0.6258881", "0.62453645", "0.6241695", "0.622...
0.763938
0
def initialize(id,name) self.id = id
def initialize(lecturers) lecturers_data = [{"name"=>"MR NJIE"},{"name"=>"MR JOBE"},{"name"=>"MRS GAYE"},{"name"=>"DR COOPER"}] lecturers = lecturers_data @lecturers = lecturers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(id, name)\n @id = id\n @name = name\n end", "def initialize(name, id)\n @name = name\n @id = id\n end", "def initialize(id) @id = id; end", "def initialize(id) @id = id; end", "def initialize( id, name )\n\t\t@id = Integer( id )\n\t\t@name = name.to_sym\n\tend", "...
[ "0.9266781", "0.92492497", "0.9197071", "0.9197071", "0.91242266", "0.9069304", "0.90553045", "0.8957963", "0.8941467", "0.8929503", "0.89168555", "0.8882889", "0.8882889", "0.8882889", "0.8697845", "0.86060154", "0.8405337", "0.8383645", "0.8346105", "0.8186337", "0.81742465...
0.0
-1
puts the completed mini satisfaction survey PDF in the Document Library, and sends an email notification
def create_and_put_pdf_for_mini_satisf_survey(response_set_code, mcoc_renewal_id, grantee_name, project_name, user_id) @mcoc_mini_survey = McocMiniSurvey.find_by_mcoc_renewal_id(mcoc_renewal_id) @mcoc_renewal = McocRenewal.find(@mcoc_mini_survey.mcoc_renewal_id) @grantee_name = @mcoc_renewal.grantee_name @project_name = @mcoc_renewal.project_name @response_set = ResponseSet.find_by_access_code(response_set_code, :include => {:responses => [:question, :answer]}) if @response_set @survey = @response_set.survey mcoc_group_id = Rails.configuration.liferaymcocgroupid.to_i mcoc_questionnaire_file_name_stem = Rails.configuration.minisatisffilename pdf_file_name = "#{@mcoc_renewal.project_name}-#{mcoc_questionnaire_file_name_stem}" #puts "mcoc_renewal_id #{mcoc_renewal_id} response_set_code #{response_set_code} grantee_name #{grantee_name} project_name #{project_name} pdf_file_name = #{pdf_file_name}..." pdf = MiniSatisfSurvey.new(mcoc_renewal_id, response_set_code, @grantee_name, @project_name, pdf_file_name) pdf_file_as_base_64 = Base64.encode64(pdf.render) #to do: wire in a please wait dialog, or fire this off asynchronously (longer-running process that doesn't need #to hang up the user) doc_name = @mcoc_mini_survey.doc_name description = "" mcoc_folder_id = Rails.configuration.liferayminisatisfactionsurveyfolderid.to_i liferay_ws = LiferayDocument.new #So we have the most up to date questionnaire pushed to the DocLib) we will first see if we #already have a DocLib entry: liferay_ws_result = liferay_ws.get(mcoc_group_id, mcoc_folder_id, doc_name) if liferay_ws_result == "found" #we need to update, as opposed to add liferay_ws.update(mcoc_group_id, mcoc_folder_id, doc_name, pdf_file_name, description, pdf_file_as_base_64) else #we didn't find an existing DocLib entry, so we'll create a new one via an "add" call: added_result = liferay_ws.add(mcoc_group_id, mcoc_folder_id, pdf_file_name, description, pdf_file_as_base_64) #update the given mcoc_renewal record with the doc_name that we just generated due to the addition of the document in the doclib. doc_name = added_result[:doc_name] @mcoc_mini_survey.update_column(:doc_name, doc_name) #call the webservice that applies specific permissions on the file (primary_ley) just added to the document library: liferay_ws_permission = LiferayPermission.new company_id = Rails.configuration.liferaycompanyid added_primary_key = added_result[:primary_key] role_id = Rails.configuration.liferaymcocmonitoringcmterole name = Rails.configuration.liferaywsdldlfileentryname action_ids = Rails.configuration.liferaymcocmonitoringcmteroleactionidsfile liferay_ws_permission.add_for_mcoc_user(mcoc_group_id, company_id, name, added_primary_key, role_id, action_ids) end url_stem = Rails.configuration.doclibrootstem url_path = Rails.configuration.doclibrootmainecoc full_doclib_url = "#{url_stem}#{url_path}#{mcoc_folder_id}" pdf.render_file(pdf_file_name) pdf_file_perm = File.open(pdf_file_name) @mcoc_mini_survey.mini_survey = pdf_file_perm @mcoc_mini_survey.save #saves the recently-created mini survey PDF File.delete(pdf_file_name) #keep things tidy! #send an email notification using the finished_survey_email_lists "distribution": this will be used for internal use only... FinishedSurveyMailer.delay.send_finished_mini_survey_email(@mcoc_mini_survey) #delayed_job #FinishedSurveyMailer.send_finished_mini_survey_email(@mcoc_mini_survey).deliver #when we're not delaying... end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summary(client)\n\n @client = client\n @greeting = \"Hi, here is a pdf\"\n mail to: client.email, subject: 'Summary Confirmation'\n\n\n\n end", "def doc\n estimate = get_estimate\n \n begin\n send_data estimate.pdf, filename: \"estimate #{estimate.doc_number}.pdf\", :disposition => 'i...
[ "0.66253275", "0.6528336", "0.64463574", "0.6351109", "0.6335721", "0.6305403", "0.6183945", "0.61270016", "0.6118012", "0.6100235", "0.6097316", "0.6078886", "0.60156024", "0.6012527", "0.5942947", "0.59395653", "0.59395653", "0.5926788", "0.5878387", "0.585704", "0.58498263...
0.6910712
0
list all the venues for this owner List of venue types
def list_types user = current_user if !params[:distance].nil? and params[:distance].to_i > 0 distance = params[:distance].to_i else distance = 30 end if !params[:latitude].blank? latitude = params[:latitude].to_f else latitude = user.latitude end if !params[:longitude].blank? longitude = params[:longitude].to_f else longitude = user.longitude end if !params[:latitude].blank? and !params[:longitude].blank? user.latitude = latitude user.longitude = longitude user.save end result = Venue.collect_network_types(current_user, latitude, longitude, distance) render json: success(result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @venues = current_user.venues\n @venue_list = []\n @avail_venues = Venue.near(current_user,Vba::Application::SEARCH_RANGE)\n @avail_venues.each do |v|\n if v.user_id.nil?\n @venue_list << v\n end\n end\n @avail_venues = @venue_list\n @avail_venues.sort { |a,b| a.na...
[ "0.6763286", "0.67520463", "0.670465", "0.66648614", "0.6601492", "0.6388698", "0.63176465", "0.63026404", "0.62808406", "0.626433", "0.617903", "0.61762625", "0.61762625", "0.616733", "0.6166088", "0.61085933", "0.61053395", "0.6065282", "0.60557705", "0.60534286", "0.603837...
0.6139911
15
List of venues :nocov:
def list user = current_user if !params[:distance].nil? and params[:distance].to_i > 0 distance = params[:distance].to_i else distance = 10000 end if !params[:latitude].blank? latitude = params[:latitude].to_f else latitude = user.latitude end if !params[:longitude].blank? longitude = params[:longitude].to_f else longitude = user.longitude end if !params[:latitude].blank? and !params[:longitude].blank? user.latitude = latitude user.longitude = longitude user.save end if !params[:without_featured_venues].blank? without_featured_venues = params[:without_featured_venues]=='1' else without_featured_venues = false end # venues = Venue.all venues = Venue.near_venues(latitude, longitude, distance, without_featured_venues) page_number = nil venues_per_page = nil page_number = params[:page].to_i + 1 if !params[:page].blank? venues_per_page = params[:per_page].to_i if !params[:per_page].blank? if !page_number.nil? and !venues_per_page.nil? and venues_per_page > 0 and page_number >= 0 pagination = Hash.new pagination['page'] = page_number - 1 pagination['per_page'] = venues_per_page pagination['total_count'] = venues.length venues = Kaminari.paginate_array(venues).page(page_number).per(venues_per_page) if !venues.nil? end data = Venue.venues_object(current_user, venues) render json: success((JSON.parse data), 'data', pagination) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def venues(options = {})\n self.class.require_latitude_and_longitude(options)\n\n response = self.class.get(\"/venues.json\", :query => options, :basic_auth => @auth)[\"venues\"]\n response && response.flatten\n end", "def index\n @venues = Venue.all\n end", "def index\n @venues = current_user...
[ "0.7970686", "0.77025026", "0.7636925", "0.7433847", "0.73012215", "0.722709", "0.7199247", "0.71742463", "0.7069167", "0.7069167", "0.7002555", "0.6996513", "0.6995102", "0.6975774", "0.6933995", "0.69227916", "0.69130117", "0.6906759", "0.6864732", "0.68601227", "0.6847698"...
0.6861569
19
creates a ranking of levels and determines whether the user falls at least at the specified level
def is_at_least_level?(level) return false if !ADMIN_RANKING[level] or !ADMIN_RANKING[self.role] return ADMIN_RANKING[self.role] >= ADMIN_RANKING[level] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user_ranking\n return if last_rank? || self.changes[:score].nil? || self.changes[:rank].present?\n old_score, new_score = self.changes[:score]\n User::LEVELS.each do |threshold|\n if old_score < threshold && new_score >= threshold\n self.update(rank: self[:rank] + 1, levelled_up: tr...
[ "0.6874216", "0.6790082", "0.67393345", "0.6706466", "0.6662136", "0.6472284", "0.64703095", "0.64084685", "0.63899887", "0.6356851", "0.62980074", "0.620676", "0.61863005", "0.61848074", "0.6177817", "0.6137141", "0.6101154", "0.60874003", "0.608239", "0.6081616", "0.6076875...
0.7143461
0
returns a user's first name and last name together
def display_name display = [first_name, last_name].join(' ').strip display.blank? ? email : display end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name\n if first_name.present? || last_name.present?\n [first_name, last_name].join(\" \").strip\n else\n username\n end\n end", "def user_full_name\n first_name + \" \" + last_name\n end", "def proper_name # method to get the full name of user\n first_name + \" \" + last_name\n ...
[ "0.8623107", "0.8497924", "0.84192157", "0.8398877", "0.8362392", "0.81744945", "0.8166345", "0.8063398", "0.8035718", "0.79974145", "0.79613197", "0.79512393", "0.794818", "0.79372776", "0.7864792", "0.7864792", "0.7864792", "0.7864792", "0.7864792", "0.7864792", "0.7859854"...
0.0
-1
Verifies a given password is equivalent to a user's password
def has_password? (submitted_password) password_digest == encrypt(submitted_password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_password?(password); end", "def verify_password(password)\n hash_password(password) == @password_hash\n end", "def valid_password?(password)\n true\n end", "def passwords_match?\n context.user.password == context.password\n end", "def password\n password = @prompt.m...
[ "0.82363725", "0.79427886", "0.7889329", "0.78741217", "0.7863791", "0.783406", "0.78288996", "0.781856", "0.78004533", "0.7773374", "0.77556", "0.7704311", "0.7702285", "0.7702146", "0.7673229", "0.7666313", "0.7641032", "0.76313835", "0.7630329", "0.7623872", "0.7607609", ...
0.7626635
19
encrypts a new user's password
def encrypt_password if new_record? self.salt = make_salt self.password_digest = encrypt(password_digest) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt_password\r\n \r\n # If the user is new, create a salt\r\n self.make_salt if new_record?\r\n \r\n # Hash the salt and password to create the encrypted pass\r\n self.encrypted_password = sha_hash(\"#{self.password}--#{self.salt}\")\r\n \r\n end", "def encrypt_passw...
[ "0.8729235", "0.8427732", "0.8400424", "0.83331853", "0.83310497", "0.8325568", "0.8320553", "0.8288086", "0.8203035", "0.81792146", "0.81685424", "0.80939215", "0.8083945", "0.8040792", "0.79782504", "0.7958251", "0.7957775", "0.79560864", "0.7932246", "0.7906409", "0.787894...
0.8279958
8
encrypts a given string with the user's salt
def encrypt(string) secure_hash("#{salt}--#{string}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end", "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end", "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end", "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end", "def encry...
[ "0.8408337", "0.84006023", "0.83473366", "0.83473366", "0.83473366", "0.834284", "0.832349", "0.80361843", "0.8029231", "0.7930706", "0.7906605", "0.7906605", "0.7906605", "0.7906605", "0.7906605", "0.7906605", "0.7882456", "0.78555167", "0.78476906", "0.7840986", "0.7840986"...
0.83932394
2
returns a new salt based on the current time and the user's submitted password
def make_salt secure_hash("#{Time.now.utc}--#{password_digest}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_salt\n secure_hash(\"#Time.now.utc}--#{password}\")\n end", "def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end", "def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end", "def make_salt\n\t secure_hash(\"#{Time.now.utc}--#{password}\")\n\tend", ...
[ "0.8439608", "0.8409241", "0.8409241", "0.8386351", "0.8203194", "0.79203564", "0.78506076", "0.78506076", "0.78326654", "0.7709855", "0.7669547", "0.76676", "0.7567469", "0.756382", "0.7540385", "0.75215805", "0.7488061", "0.7443533", "0.7405851", "0.73946255", "0.73592407",...
0.8382773
4
encrypts a string with SHA2 encryption
def secure_hash(string) Digest::SHA2.hexdigest(string) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt(string)\n Digest::SHA1.hexdigest(string)\n end", "def encrypt(string)\n Digest::SHA1.hexdigest(string)\n end", "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end", "def encrypt(string)\n secure_hash(\"#{salt}--#{string}\") \n\tend", "def encrypt(string)\n se...
[ "0.8045615", "0.8045615", "0.77524394", "0.7729495", "0.7693773", "0.7678292", "0.7623088", "0.7623088", "0.7623088", "0.7573153", "0.7519729", "0.7519311", "0.746782", "0.74574214", "0.74574214", "0.74574214", "0.74417895", "0.74417895", "0.74417895", "0.74417895", "0.744178...
0.7477698
12
I guess this isn't needed but I WROTE IT AND I'M LEAVING IT HERE
def word_number text.split.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def terpene; end", "def anchored; end", "def offences_by; end", "def suivre; end", "def who_we_are\r\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def formation; end", "def stderrs; end", ...
[ "0.6967323", "0.69298136", "0.6447577", "0.64444", "0.64314574", "0.63390994", "0.6286531", "0.62824947", "0.6253617", "0.6253617", "0.6253617", "0.6253617", "0.6139048", "0.6096948", "0.602699", "0.60196614", "0.60151166", "0.60023934", "0.598181", "0.598181", "0.59814036", ...
0.0
-1
Time complexity: O(n) where n is equal to the input value Space complexity: O(n) where n is equal to the input value
def factorial(n) if n < 0 raise ArgumentError, "input must be a number greater than or equal to 0." elsif n == 1 || n == 0 return 1 else return n * factorial(n - 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend...
[ "0.64410794", "0.6349099", "0.63292474", "0.62709457", "0.6212594", "0.6197357", "0.60947734", "0.6091626", "0.60658485", "0.60566914", "0.604608", "0.5979372", "0.59596044", "0.59580886", "0.5955236", "0.59548664", "0.5942377", "0.5940883", "0.59325266", "0.5931426", "0.5918...
0.0
-1
Time complexity: O(n) where n is equal to the length of the input string not confident on this space complexity Space complexity: O(n ^ 2) where n is equal to the length of the input string ^ 2
def reverse(s) if s.length == 0 || s.length == 1 return s else return s[-1] + (reverse(s[0..-2])) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.le...
[ "0.7196423", "0.7016827", "0.6969499", "0.69601417", "0.6918013", "0.6892344", "0.679596", "0.67702615", "0.6769021", "0.67250615", "0.67249066", "0.671237", "0.66819394", "0.6672991", "0.6672047", "0.6663027", "0.6652527", "0.6639155", "0.66233814", "0.66161096", "0.6613908"...
0.0
-1
Time complexity: O(n) where n is the length of the string / 2 Space complexity: O(n) where n is the length of the string / 2
def reverse_inplace(s, i = 0, j = s.length - 1) if i >= j return s else temp = s[i] s[i] = s[j] s[j] = temp return reverse_inplace(s, i += 1, j -= 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.le...
[ "0.7368479", "0.6982561", "0.6924811", "0.68605447", "0.68355286", "0.6830137", "0.68191785", "0.68124175", "0.6801011", "0.67757624", "0.67549485", "0.6724466", "0.6713821", "0.6701605", "0.6696227", "0.66780865", "0.6677486", "0.66693985", "0.6640632", "0.66397876", "0.6638...
0.0
-1
Time complexity: O(n) where n is equal to the input value Space complexity: O(n) where n is equal to the input value
def bunny(n) if n == 0 return n else return 2 + bunny(n - 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend...
[ "0.6439253", "0.6346295", "0.63280505", "0.62682253", "0.6210843", "0.6194398", "0.60934883", "0.6089568", "0.6062753", "0.6055114", "0.6045158", "0.5977882", "0.5957202", "0.595457", "0.5951999", "0.59519684", "0.5939906", "0.59390396", "0.59309065", "0.5929551", "0.5917632"...
0.0
-1
Time complexity: O(n) where n equal the length of the string / 2 Space complexity: O(n) where n equals the length of the string / 2 + the length of the string
def nested(s) if s == "" return true elsif s.length == 1 || s[0] != "(" || s[-1] != ")" return false else return nested(s[1..-2]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.le...
[ "0.7331802", "0.70300156", "0.68401337", "0.68141806", "0.68093747", "0.67909294", "0.67875236", "0.67785925", "0.67568433", "0.67266583", "0.67088825", "0.6683158", "0.6679382", "0.6652103", "0.66408765", "0.6634489", "0.66305846", "0.66269195", "0.6617177", "0.6613322", "0....
0.0
-1
Time complexity: O(n) where n equals the length of the array Space complexity: O(n) where n equals the length of the array 2
def search(array, value) if array.empty? return false elsif array[0] == value return true else return search(array[1..-1], value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_2arrays(array_1, array_2)\n shared = array_1 & array_2\n shared_count = shared.count\n\n array_1_unshared = array_1 - shared\n array_2_unshared = array_2 - shared\n\n count_1 = array_1_unshared.count\n count_2 = array_2_unshared.count\n unshared = array_1_unshared + array_2_unshared\n unshared_...
[ "0.6799299", "0.66574824", "0.6575019", "0.6560275", "0.65202576", "0.6511761", "0.6506761", "0.6438735", "0.6408123", "0.64067805", "0.6380967", "0.6380908", "0.63776004", "0.6363869", "0.6358187", "0.6358187", "0.63490695", "0.6344432", "0.6334155", "0.6313326", "0.6309329"...
0.0
-1
Time complexity: O(n) where n equals the length of the string / 2 Space complexity: O(n) where n equals the length of the string / 2 + length of the string
def is_palindrome(s) if s == "" || s.length == 1 return true elsif s[0] != s[-1] return false else return is_palindrome(s[1..-2]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.le...
[ "0.73779607", "0.6979041", "0.69268066", "0.6899019", "0.6835063", "0.67928404", "0.6786649", "0.67838395", "0.67627114", "0.674795", "0.6712349", "0.6701798", "0.6697819", "0.66784", "0.6673212", "0.66660136", "0.6654557", "0.66522133", "0.6650673", "0.6638606", "0.66359186"...
0.0
-1
Time complexity: O(n) where n equals the number of digits in the smallest input Space complexity: O(n) where n equals the number of digits in the smallest input
def digit_match(n, m) if (n / 10 == 0) || (m / 10 == 0) return (n % 10 != m % 10) ? 0 : 1 else if (n % 10 == m % 10) return 1 + digit_match(n / 10, m / 10) else return digit_match(n / 10, m / 10) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_smaller(num)\n #declare variable for adding number\n small_num = 0\n \n # convert the number to a string so it can be used like an array\n num = num.to_s\n # find out how many digits on in the number so the for loop knows how many time to go though\n digits = num.length - 1\n\n # add each number t...
[ "0.6933907", "0.6855647", "0.6832603", "0.68015856", "0.68003947", "0.6738854", "0.6691145", "0.6678309", "0.66781497", "0.6672194", "0.66519356", "0.6618708", "0.6571057", "0.6530705", "0.6527114", "0.64831865", "0.6474865", "0.64671", "0.6462442", "0.6427308", "0.6409298", ...
0.0
-1
is initialized as an empty array
def initialize(name, artist = nil, genre = nil) #accepts a name for the new song @name = name # can set the name of a song self.artist=artist if artist self.genre=genre if genre #assigns a genre to the song (song belongs to genre)/ # invokes #genre= instead of simply assigning to a @genre instance variable to ensure that associations are #created upon initialization end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize; @ary = []; end", "def initialize\n @array = []\n end", "def initialize(size)\n @array = Array.new(size) {|index| nil}\n end", "def initialize arr = []\n super arr\n end", "def initialize\n @size = 10\n @array = Array.new(@size) { [] }\n @count = 0\n end", ...
[ "0.7898585", "0.7674258", "0.73142713", "0.71584094", "0.70799136", "0.6984154", "0.6974435", "0.6957906", "0.6925695", "0.68299866", "0.67893356", "0.67378724", "0.6609156", "0.66008097", "0.66008097", "0.6571506", "0.65654725", "0.6539893", "0.6538133", "0.6536542", "0.6510...
0.0
-1
GET /chatrooms/1 GET /chatrooms/1.json
def show @ingredients = Ingredient.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @chatroom = Chatroom.find(params[:id])\n @messages = @chatroom.messages.order(\"created_at DESC\")\n @user = User.find(session[:user_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chatroom }\n end\n end", "def index\n @chat_rooms ...
[ "0.7231149", "0.70668113", "0.7057458", "0.70471334", "0.7031382", "0.7031382", "0.70048255", "0.69007206", "0.68650013", "0.68282425", "0.6825339", "0.68191856", "0.6812616", "0.6773617", "0.67663", "0.6737885", "0.6735713", "0.67112976", "0.6698384", "0.6683038", "0.6668495...
0.0
-1
POST /ingredients POST /ingredients.json
def create @ingredient = Ingredient.new(ingredient_params) respond_to do |format| if @ingredient.save format.html { redirect_to recipes_path, notice: 'Ingredient was successfully created.' } else format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end", "def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantit...
[ "0.7749055", "0.7590346", "0.7465898", "0.74050695", "0.73933405", "0.7286979", "0.7167695", "0.716602", "0.71002847", "0.7087613", "0.70036024", "0.6972241", "0.69679314", "0.6920982", "0.6916151", "0.68945533", "0.68943995", "0.6876029", "0.68722105", "0.6858264", "0.678736...
0.6791807
20
Use callbacks to share common setup or constraints between actions.
def set_ingredient @ingredient = Ingredient.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def ingredient_params params.require(:ingredient).permit(:name) 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.6979893", "0.6781746", "0.6746611", "0.6742344", "0.6735229", "0.6592651", "0.65027124", "0.6498011", "0.648163", "0.647716", "0.64556813", "0.64386255", "0.63784456", "0.63756156", "0.636574", "0.6319542", "0.63004524", "0.6299559", "0.62925464", "0.62923217", "0.6289894"...
0.0
-1
override error_string to provide your own error_string
def error_string # This method should be overridden end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(string); end", "def error(string); end", "def error_message; end", "def error_message\n self[:error_message]\n end", "def custom_error_message\n message = component.dig('errors', schema_key, 'any')\n\n message % error_message_hash if message.present?\n end", "def error_message\...
[ "0.7827707", "0.7827707", "0.7783408", "0.73827076", "0.7237058", "0.7224651", "0.71808404", "0.7169038", "0.71550053", "0.7129184", "0.71234536", "0.7117986", "0.7097887", "0.70776105", "0.70490044", "0.70438844", "0.70438844", "0.7030537", "0.6996287", "0.699092", "0.697716...
0.87050015
0
Function to set the end time for the related TaskTimer when this class is instantiated.
def timer_ends_at return @end_date if @end_date # Check for last existing associated TaskTimer task_timer = TaskTimer.find_by(task: self) return task_timer.submitted_at if task_timer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gc_set_end_time\n if end_time.nil?\n self.end_time = start_time\n end\n end", "def end\n @end_time = Time.now.utc\n end", "def set_duration\n if self.end_time\n # self.duration = (end_time - start_time).to_i\n self.duration = (end_time - start_time).to_i\n else\n ...
[ "0.76091975", "0.6987602", "0.6728954", "0.67284", "0.6690645", "0.6672719", "0.65768534", "0.6509116", "0.6485155", "0.6482647", "0.6482647", "0.6482647", "0.6482647", "0.6482647", "0.6482647", "0.6481219", "0.6464445", "0.64365655", "0.6308823", "0.62586963", "0.6258202", ...
0.56071126
55
Confirms the correct user.
def admin_user unless logged_in? && current_user.admin? redirect_to root_url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end", "def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n...
[ "0.7474259", "0.73411936", "0.7317917", "0.7183303", "0.7174887", "0.7049758", "0.70130193", "0.7012358", "0.7006517", "0.7006201", "0.7003461", "0.69663024", "0.69136065", "0.6911695", "0.690295", "0.6892608", "0.68439376", "0.6842948", "0.68397075", "0.683463", "0.6826711",...
0.0
-1
============================ Validations declarations: ============================ ===================== Complex validations: =====================
def validate # first check whether combo fields have been selected is_valid = true if is_valid is_valid = ModelHelper::Validations.validate_combos([{:artist_name => self.artist_name}],self) end #now check whether fk combos combine to form valid foreign keys if is_valid is_valid = set_artist end #validates uniqueness for this record if self.new_record? && is_valid validate_uniqueness end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation; end", "def validation; end", "def is_valid; end", "def validate; end", "def validate; end", "def validate; end", "def validate; end", "def validate\n \n \n end", "def valid; end", "def valid?(_) true end", "def valid?(_) true end", "def validator; end", "def validate\r\n\...
[ "0.76046526", "0.76046526", "0.75440377", "0.75253373", "0.75253373", "0.75253373", "0.75253373", "0.74418646", "0.73552656", "0.7341772", "0.7341772", "0.73310477", "0.73254544", "0.72444105", "0.72444105", "0.72444105", "0.7225155", "0.7225155", "0.7225155", "0.7225155", "0...
0.0
-1
=========================== foreign key validations: ===========================
def set_artist artist = Artist.find_by_artist_name(self.artist_name) if artist != nil self.artist_name = artist return true else errors.add_to_base("combination of: 'artist_name' is invalid- it must be unique") return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_all_foreign_keys_valid!\n end", "def check_foreign_key(field)\n val = self.send(field)\n if val.is_a? ForeignKey\n add_foreign_key_message_to_errors(val)\n end\n end", "def check_add_foreign_key(*args); end", "def foreign_key_present?\n false\n end", "def forei...
[ "0.7600098", "0.7280537", "0.72237355", "0.72103435", "0.72103435", "0.71699786", "0.70691454", "0.70154715", "0.6979766", "0.69792753", "0.6944212", "0.6933209", "0.6933209", "0.6887509", "0.6855989", "0.68030375", "0.6676975", "0.6676975", "0.66574645", "0.65902704", "0.657...
0.0
-1
Run rsync on the guest to update a path either the whole mirror directory or individual files and folders within it.
def run(path) # Strip a leading / off the path to avoid any problems path.sub!(/^\//, '') # Build the source and destination paths source = "#{guest_sf_path}/#{path}" dest = "#{guest_path}/#{path}" # Check if the source is a directory on the host - if so, add a / for rsync if ((path != '') && (File.directory?(File.join(host_path, path)))) source << '/' dest << '/' end # Build the rsync command args = ['rsync -av'] if (delete) args << '--del' end args = args + exclude_args args << source args << dest cmd = args.join(' ') # Run rsync vm.channel.sudo(cmd) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rsync_command\n if @config[:rsync][:direction] == 'up'\n from = absolute_path(@config[:local_path])\n to = @config.ssh_user_and_host + ':' + @config[:remote_path]\n else\n from = @config.ssh_user_and_host + ':' + @config[:remote_path]\n ...
[ "0.7190866", "0.71836245", "0.7139224", "0.70701444", "0.7020124", "0.691624", "0.68774295", "0.68582654", "0.6824212", "0.6582331", "0.6550088", "0.6475137", "0.64403385", "0.64385206", "0.64195883", "0.6416944", "0.63959765", "0.63520414", "0.63400507", "0.633446", "0.63238...
0.78578454
0
returns an array of all ratings for that movie
def ratings Rating.all.find_all do |rating| rating.movie == self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movies\n movies = []\n @rating_list.each_value do |rating|\n movies << rating.movie_id\n end\n return movies\n end", "def movies u\n \tuser_ratings = @userdata[u.to_s.to_sym]\n \tsize = user_ratings.size\n \tmovies = []\n \tuser_ratings.each do |id, rating|\n ...
[ "0.8103832", "0.77226496", "0.75389254", "0.75133795", "0.7413586", "0.7261149", "0.7256989", "0.7256646", "0.7191895", "0.7166123", "0.7131912", "0.70842165", "0.7079114", "0.7001308", "0.69224685", "0.6905355", "0.68371296", "0.6831571", "0.6827702", "0.68020904", "0.678348...
0.7539278
2
should return all of the viewers who have left ratings for that movie.
def viewers self.ratings.collect do |rating| rating.viewer end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def viewers(rating)\n self.ratings.find_all do |ratiing|\n ratiing.viewer\n end\n #should return all of the viewers who have left ratings for that movie.\n end", "def viewers(rating)\n self.ratings.find_all do |ratiing|\n ratiing.viewer\n end\n #should return all of the viewers who h...
[ "0.8584941", "0.8584941", "0.7033009", "0.66294754", "0.65117866", "0.65102977", "0.6505248", "0.6488155", "0.63734674", "0.63567394", "0.63550246", "0.62993586", "0.62929606", "0.6246025", "0.6237934", "0.61417943", "0.6123599", "0.6119091", "0.60930973", "0.60617596", "0.60...
0.6505609
6
should return the average of all of the scores for the ratings of that particular movie.
def average_rating sum = 0 self.ratings.each do |rating| sum += rating.score end avg = sum/self.ratings.length avg.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_ratings\n movies.reduce(0) do |sum, movie|\n sum + movie.rating\n end / movies.length\n end", "def get_avg_rating(movie_ratings)\n sum = 0\n movie_ratings.each { |b| sum += b }\n @average_movie_rating = (sum.to_f / @movie_ratings.count.to_f).round(1)\n end", "d...
[ "0.85349166", "0.84603", "0.8066163", "0.8020591", "0.7717071", "0.76594913", "0.76391673", "0.7629024", "0.76203054", "0.7599001", "0.7561123", "0.74872446", "0.747402", "0.7472867", "0.7472867", "0.74702144", "0.7468282", "0.74638695", "0.74607694", "0.74583155", "0.7419632...
0.7906055
4
Instance method Update the email record
def save_email(user_id, checked) self.update!(user_id: user_id, checked: checked, primary: checked) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n set_email\n @email.update(email_params)\n redirect_to user_emails_path(current_user.id)\n end", "def update\n @email.update(valid_params)\n json_response(@email)\n end", "def email_update\n participant = Participant.first\n participant.email_update_token = Part...
[ "0.766028", "0.7603644", "0.7514171", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.71280223", "0.7090566", "0.7090566", "0.7049128", "0.69401336", "0.6936215", "0.6934408", "0.6907768", "0.6896463", "0.6894...
0.0
-1
Set the check email field like true
def verify_email() self.update!(checked: true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_email\n self.update!(checked: true)\n end", "def set_email_field(email)\n end", "def check_email\n self.email_address=~/^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i if email_address\n end", "def set_Email(value)\n set_input(\"Email\", value)\n end", "def set_Email(value)...
[ "0.769856", "0.7520827", "0.72554684", "0.7198137", "0.7197468", "0.71663177", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.70766807", "0.7076371", "0.7076371", "0.70754695", "0....
0.7857966
0
GET a word from user input IF the word starts with a vowel, add "way" to the end ELSE replace the word with its pig latin equivalent GET all of the consonants before the first vowel in the word SET the consonants at the end of the word and add "ay" ENDIF RETURN the piglatin word
def pig_latin_word(word) if word[0].downcase =~ /[aeiou]/ word << "way" else n = /[aeiou]/.match word.downcase n.to_s + n.post_match + n.pre_match + "ay" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pig_latin_name(word)\n# and returns a new string (pig latinified)\n# need to define vowels (can be an array?)\n vowels_list = vowels\n# break word into letters\n letters = word.split(\"\")\n# iterate through each letter of the word\n# until we hit a vowel\n letters.each do |letter|\n\n # check if first let...
[ "0.8255951", "0.824749", "0.8180688", "0.8153952", "0.8119525", "0.8115045", "0.81016654", "0.8096906", "0.80914706", "0.8073852", "0.8053871", "0.8051505", "0.799722", "0.7981735", "0.7978206", "0.79554546", "0.7938944", "0.7926668", "0.7863044", "0.78306586", "0.7793907", ...
0.8336075
0
Script: Single word converter to Pig Latin GET a sentence from user input SET new_sentence = to empty string sentence.split.EACH DO |word| IF the word starts with a vowel, add "way" to the end ELSE replace the word with its pig latin equivalent GET all of the consonants before the first vowel in the word SET the consonants at the end of the word and add "ay" ENDIF END.EACH RETURN the piglatin word
def pig_latin_sentence(sentence) new_sentence = "" sentence.split.each do |word| if word[0].downcase =~ /[aeiou]/ word << "way" else n = /[aeiou]/.match word.downcase word = n.to_s + n.post_match + n.pre_match + "ay" end new_sentence << word end new_sentence end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pig_latin_name(word)\n# and returns a new string (pig latinified)\n# need to define vowels (can be an array?)\n vowels_list = vowels\n# break word into letters\n letters = word.split(\"\")\n# iterate through each letter of the word\n# until we hit a vowel\n letters.each do |letter|\n\n # check if first let...
[ "0.83287865", "0.82588303", "0.81782144", "0.81060547", "0.8092713", "0.8078821", "0.807004", "0.80646074", "0.80640733", "0.8050418", "0.804713", "0.80242234", "0.80010414", "0.7986586", "0.798317", "0.79730606", "0.7969402", "0.7968942", "0.79601544", "0.7942724", "0.793276...
0.86851346
0
GET /players or /players.json
def index @players = Player.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n player = Player.all\n render json: players, status: 200\n end", "def index\n @players = Player.all\n render json: @players, status: 200\n end", "def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render ...
[ "0.74357766", "0.73628175", "0.7361891", "0.7326533", "0.72655135", "0.7222246", "0.71823573", "0.7154248", "0.70885545", "0.70676506", "0.7037785", "0.7037785", "0.7037785", "0.7037785", "0.7037785", "0.703365", "0.69465137", "0.6927269", "0.692551", "0.6922897", "0.6891783"...
0.6470831
60
GET /players/1 or /players/1.json
def show puts "show".black.on_yellow if request.headers["turbo-frame"] if params[:destroy].present? render partial: 'game_players', locals: { game: Player.find(session[:player_id]).game } end render partial: 'spy', locals: { player: Player.find(session[:player_id]) } else render 'show' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def players_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.players_get ...\"\n end\n # resource path\n local_var_path = \"/players\"\n\n # query parameters\n query_params = {}\n query_params[:'pag...
[ "0.7252168", "0.7110454", "0.7085891", "0.70745534", "0.7042634", "0.7029605", "0.70068127", "0.70068127", "0.70068127", "0.70068127", "0.70068127", "0.6993558", "0.6945824", "0.69417685", "0.68568516", "0.68563384", "0.685245", "0.6823018", "0.6793353", "0.6791838", "0.67832...
0.0
-1
POST /players or /players.json
def create @player = Player.new(player_params) respond_to do |format| if @player.save session[:player_id] = @player.id session[:new_player] = true if session[:creator] @player.game.update(creator: @player.id) end format.turbo_stream format.html { redirect_to @player.game, notice: "Player was successfully created." } format.json { render :show, status: :created, location: @player } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @player.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n player = Player.create(player_params)\n render json: player, status: 201\n end", "def create\n player = Player.new(player_params)\n if player.save\n render json: player, status: 201, location: [:api, player]\n else\n failed_to_create(player, \"player\")\n end\n end", ...
[ "0.7087224", "0.69804347", "0.6902252", "0.6814137", "0.68129593", "0.681034", "0.6777718", "0.6736179", "0.6706373", "0.66688454", "0.66688454", "0.66688454", "0.66688454", "0.66570526", "0.65727067", "0.65714306", "0.65641177", "0.65362555", "0.65301263", "0.65164566", "0.6...
0.61910826
59
PATCH/PUT /players/1 or /players/1.json
def update respond_to do |format| if @player.update(player_params) format.html { redirect_to @player, notice: "Player was successfully updated." } format.json { render :show, status: :ok, location: @player } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @player.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @player.update(player_params)\n render json: @player, status: 200\n end", "def update\n @player.update!(player_params) # anticipated possible exceptions rescued in BaseController\n render json: @player, status: 200\n end", "def update\n player = Player.find(params[:id])\n...
[ "0.7268271", "0.7261021", "0.7221691", "0.71977925", "0.71741134", "0.7149133", "0.71489894", "0.71489894", "0.71489894", "0.71489894", "0.71489894", "0.71489894", "0.71289855", "0.70750093", "0.7064649", "0.7064649", "0.7064649", "0.7064649", "0.70014244", "0.69794697", "0.6...
0.6834424
37
DELETE /players/1 or /players/1.json
def destroy @player.destroy respond_to do |format| format.turbo_stream format.html { redirect_to players_url, notice: "Player was successfully destroyed." } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n player = Player.find(params[:id])\n player.destroy\n head 204\n end", "def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to players_url }\n format.json { head :ok }\n end\n end", "def destroy\n ...
[ "0.74773043", "0.7452887", "0.7452887", "0.7451005", "0.7451005", "0.7451005", "0.7451005", "0.7451005", "0.7451005", "0.7451005", "0.7451005", "0.74416214", "0.7418203", "0.7394759", "0.73572797", "0.73572797", "0.73572797", "0.7354456", "0.73213655", "0.7271641", "0.7218916...
0.6569147
86
Use callbacks to share common setup or constraints between actions.
def set_player @player = Player.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def player_params params.require(:player).permit(:kind, :name, :game_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.
def get_middle(s) mid = (s.length - 1) / 2 s.length.odd? ? s[mid] : s[mid..mid+1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def middle_word(str)\n words = str.split(\" \")\n middle_word = words[words.size/2]\nend", "def middle_word(string)\n words = string.split\n word_count = words.length\n mid_index = word_count / 2\n if word_count == 0\n ''\n elsif word_count.even?\n # if even number of words, return the two words acr...
[ "0.8231874", "0.82223004", "0.8213033", "0.82055163", "0.8149259", "0.8145172", "0.81200206", "0.8092207", "0.80714226", "0.80012983", "0.7967915", "0.7931772", "0.7908239", "0.7883209", "0.78096324", "0.7796955", "0.77933353", "0.77825916", "0.774391", "0.7712696", "0.769848...
0.75132227
32
approve sets status to payment_pending
def approve @reservation.update_attribute(:status, 1) ReservationMailer.approve_request(@reservation).deliver redirect_to received_reservations_path + "#" + params[:current_tab] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def approve!\n raise 'not pending' unless self.status == 'PENDING'\n\n transaction do\n self.status = 'APPROVED'\n self.save!\n overlapping_pending_requests.update_all(status: 'DENIED')\n end\n end", "def approve(real_amount)\n self.real_amount = real_amount\n set_ok!\n ...
[ "0.7594567", "0.74795395", "0.74795395", "0.74132425", "0.74121356", "0.73538196", "0.72970426", "0.7183751", "0.7172353", "0.7140553", "0.7131953", "0.7115552", "0.71074885", "0.70539504", "0.7030368", "0.7005767", "0.6972011", "0.6960692", "0.6887495", "0.6879946", "0.68299...
0.6854838
20
Get the subject and content of the most recent email for the given user
def most_recent_email(email, username=nil, password=nil) imap = Net::IMAP.new( Property['email_imap_host'], :port => Property['email_imap_port'], :ssl => to_boolean(Property['email_imap_use_ssl']) ) imap.authenticate('LOGIN', user, password) imap.examine('INBOX') ids = imap.search(['TO', email]) subject, content = nil, nil unless ids.empty? content_attr = 'BODY[TEXT]' subject_attr = 'BODY[HEADER.FIELDS (SUBJECT)]' email_data = imap.fetch(ids.last, [content_attr, subject_attr]).first content = email_data.attr[content_attr] subject = email_data.attr[subject_attr] end imap.disconnect [subject, content] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latest_mail(options = {})\n return only_latest(mail(options))\n end", "def latest(user)\n public_replies(user).last\n end", "def getLastContent(user, contentType)\n last = nil\n for content in contentsMap[user] \n last = content if content.kind_of?(contentType) \n end\n return last\nend"...
[ "0.67292106", "0.6448829", "0.60396105", "0.60134554", "0.59183186", "0.58813286", "0.5840495", "0.58338284", "0.5831693", "0.57080626", "0.56958485", "0.5673607", "0.5645564", "0.564543", "0.56399524", "0.56399524", "0.5629418", "0.56185764", "0.56157994", "0.55770046", "0.5...
0.707036
0
This before filter prevents unauthorised users from deleting micro posts on a controller level
def authorized_user @micropost = Micropost.find(params[:id]) redirect_to root_path unless current_user?(@micropost.user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize_user_to_delete\n post = Post.find(params[:id])\n unless current_user == post.user || current_user.admin?\n flash[:alert] = \"You must be an admin to do that.\"\n redirect_to [post.topic, post]\n end\n end", "def authorize_destroy\n if forum?\n redirect_to home_url un...
[ "0.6466946", "0.64093566", "0.63590854", "0.6239449", "0.6221211", "0.6201139", "0.6197704", "0.6167134", "0.61654943", "0.61579293", "0.61572945", "0.61455226", "0.6126699", "0.6111707", "0.60966957", "0.6018561", "0.6015228", "0.6013909", "0.6009242", "0.60000545", "0.59949...
0.0
-1
Write a method that takes (1) an array of unsorted_scores and (2) the highest_possible_score in the game and returns a sorted array of scores efficiently.
def sort_scores(unsorted_scores, highest_possible_score) array = [] array << highest_possible_score unsorted_scores.sort.reverse.each { |score| array << score } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answer(unsorted_scores, highest_possible_score)\n score_counts = [0] * (highest_possible_score + 1) # array of 0's at indices 0..highest_possible_score\n unsorted_scores.each { |score| score_counts[score] += 1 } # populate score_counts\n sorted_scores = [] # populate the final sorted_scores\n highest_possi...
[ "0.81026304", "0.80752987", "0.7474369", "0.74736995", "0.7454375", "0.7354733", "0.72424555", "0.6959485", "0.66398615", "0.66072446", "0.6558812", "0.65584", "0.64215416", "0.6411531", "0.63647854", "0.6336766", "0.6297227", "0.6256809", "0.62562865", "0.62085277", "0.61961...
0.82529336
0
returns [91, 89, 65, 53, 41, 37] ANSWER: 1) Allocate an array num_counts where the indices represent numbers from our input array and the values represent how many times the index number appears. 2) In one pass of the input array, update num_counts as you go. 3) Allocate an array sorted_array where we'll store our sorted numbers. 4) In one inorder pass of num_counts put each number, the correct number of times, into sorted array.
def answer(unsorted_scores, highest_possible_score) score_counts = [0] * (highest_possible_score + 1) # array of 0's at indices 0..highest_possible_score unsorted_scores.each { |score| score_counts[score] += 1 } # populate score_counts sorted_scores = [] # populate the final sorted_scores highest_possible_score.downto(0) do |score| count = score_counts[score] (0...count).each { |time| sorted_scores << score } end return sorted_scores end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def counting_sort(arr)\n work_list = Array.new(arr.max+1, 0)\n arr.each { |i| work_list[i] += 1 }\n result = []\n work_list.each_with_index do |i, index|\n i.times {|j| result << index } if i != 0\n end\n result\nend", "def countingSort(arr)\n result = Array.new(100, 0)\n arr.each { |num| result[num] ...
[ "0.766997", "0.75210667", "0.7438237", "0.7344056", "0.7243776", "0.7174046", "0.7151799", "0.7033719", "0.7015635", "0.6930671", "0.6915538", "0.6877942", "0.6866007", "0.68077075", "0.6779658", "0.6767644", "0.67665845", "0.6747961", "0.67409384", "0.6711008", "0.6690008", ...
0.6103424
44
Called after a build is completed.
def completed(build, listener) sus_labels = get_label_config node = build.get_built_on node_labels = [] node.get_assigned_labels.each do |label| node_labels << label.name end intersecting_labels = sus_labels & node_labels if not intersecting_labels.empty? computer = node.to_computer logger.info("Taking single use slave '#{computer.get_display_name}' offline " + "because of labels (" + intersecting_labels.join(', ') + ")") cause = OfflineCause::ByCLI.new('Offlined by Single Use Slave Plugin') computer.set_temporarily_offline(true, cause) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completed(build, listener)\n end", "def after_finished\n end", "def finish()\n #This is a stub, used for indexing\n end", "def on_assembly_finished( builder, result )\n\t\tself.send_result( builder.assembly_id, result )\n\t\tsuper\n\tend", "def finished\n @finished = tr...
[ "0.7694057", "0.67876345", "0.6732683", "0.6601358", "0.6574763", "0.64659965", "0.6457019", "0.6375024", "0.6359134", "0.6334355", "0.6331718", "0.63259107", "0.6241421", "0.6234299", "0.6227479", "0.6219443", "0.62122995", "0.61758906", "0.61758906", "0.61336994", "0.612032...
0.5918796
39
TODO: store in memory
def publish!(entry) # no-op (for now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store; end", "def store; end", "def store; end", "def private; end", "def stored_data; end", "def storage; end", "def autorestore; end", "def store?; end", "def storage() @storage; end", "def memos; end", "def memos; end", "def cache; end", "def cache; end", "def cache; end", "def c...
[ "0.7072406", "0.7072406", "0.7072406", "0.6884851", "0.68829036", "0.6666949", "0.64047575", "0.63310766", "0.6205318", "0.6108217", "0.6108217", "0.59903383", "0.59903383", "0.59903383", "0.59903383", "0.59903383", "0.59903383", "0.59903383", "0.59358776", "0.59358776", "0.5...
0.0
-1
Rather than explicitly defining abstract methods for predicates like is_wall?, all world objects will return false from any is_foo? method, allowing only the specific world object to override their own methods to return true as needed.
def method_missing(method, *args, &block) return super(method, *args, &block) unless method.to_s =~ /^is_.+\?$/ self.class.class_eval do define_method(method) do |*args, &block| false end end self.send(method, *args, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def certain?\n fail NotImplementedError\n end", "def physical?\n fail NotImplementedError\n end", "def for_all?\n fail NotImplementedError\n end", "def allowed?() raise NotImplementedError end", "def magical?\n fail NotImplementedError\n end", "def abstract?; end", "def is_guy? \n re...
[ "0.6032753", "0.60170424", "0.59165144", "0.5857399", "0.58387995", "0.58285147", "0.58220017", "0.5773067", "0.56845653", "0.56667084", "0.5663156", "0.5626862", "0.56267995", "0.55807537", "0.5568488", "0.55281657", "0.54812986", "0.54812986", "0.54812986", "0.5472626", "0....
0.6110439
0
define a palavra para ser usada no jogo
def prepara_palavra(palavra) usagi=[] for t in 0..(palavra.length()-1) usagi.push(palavra[t]) end #puts usagi return usagi end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palabras\n end", "def palabras\n\tend", "def suivre; end", "def romeo_and_juliet; end", "def bellini; end", "def letzte_komponente\n \n end", "def terpene; end", "def wtfpyra (a)\n\t\tfullpyra (a)\n\t\treversefullpyra (a)\n\tend", "def relatorios\n end", "def reconstruir_palabras\n pal...
[ "0.72553545", "0.71607876", "0.63831276", "0.62444", "0.6063566", "0.5915483", "0.590442", "0.5879622", "0.5870954", "0.58140296", "0.5778587", "0.5744453", "0.5729888", "0.5729888", "0.5729888", "0.5729888", "0.57150006", "0.57150006", "0.57147765", "0.5678743", "0.5672843",...
0.0
-1
GET /materials GET /parts/1/materials
def index if params[:part_id] @materials = Material.find(:all, :conditions => ["part_id = ?", params[:part_id]]) else @materials = Material.all end respond_to do |format| format.html format.json { render :json => @materials } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve_materials(materials)\n return unless materials.present?\n\n show do\n title 'Retrieve Materials'\n note 'Please get the following items'\n table create_location_table(materials)\n end\n end", "def index\n @materials = Material.all\n end", "def index\n @component_mat...
[ "0.7532051", "0.715042", "0.69010574", "0.6878689", "0.67734635", "0.67734635", "0.6643587", "0.6635933", "0.6635933", "0.6617993", "0.66080743", "0.6584917", "0.65342194", "0.64845216", "0.6465933", "0.64136136", "0.6388731", "0.6246546", "0.62148476", "0.6214016", "0.617216...
0.8101705
0
GET /meetings/1 GET /meetings/1.json
def show redirect_to workshop_path(@meeting.workshop) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @meetings = Meeting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end", "def get_meetings\n prepare\n @api.get_meetings\n end", "def index\n @meetings = Meeting.all\n end", "def index\n @meetings = ...
[ "0.78839743", "0.74981296", "0.7383316", "0.7383316", "0.7383316", "0.7383316", "0.7383316", "0.7383316", "0.7325589", "0.72647816", "0.72443306", "0.7235783", "0.7235783", "0.7181052", "0.7170575", "0.7024749", "0.7015309", "0.6987953", "0.697331", "0.692443", "0.69225353", ...
0.0
-1