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
Validation test for gene merge Output: the slope of the line obtained by linear regression
def validation_test plot_matched_regions(@filename) slope = plot_2d_start_from(@filename) GeneMergeValidationOutput.new(slope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gene_merge_validation\n\n plot_matched_regions(@filename)\n slope = plot_2d_start_from(@filename)\n\n end", "def get_line(y)\n \n x = Array(1..y.size)\n # generate the linear regressions required to produce the linear equation\n ts = LineFit.new \n # this method does the work\n ts.setData(...
[ "0.7162314", "0.5453479", "0.53851265", "0.53439987", "0.5292024", "0.5285078", "0.5200652", "0.5145667", "0.51147425", "0.5066562", "0.50396675", "0.50374174", "0.5028959", "0.5000186", "0.4984361", "0.49827203", "0.49539873", "0.49420735", "0.4900149", "0.48917457", "0.4868...
0.6930509
1
Plots the histogram of the distribution of the middles of the hits Params: +output+: filename where to save the graph +clusters+: array of Cluster objects +middles+: array with values with potential multimodal distribution
def plot_merge_clusters(output, clusters = @clustersi, middles) max_freq = clusters.map{ |x| x.lengths.map{|y| y[1]}.max}.max R.eval "colors = c('red', 'blue', 'yellow', 'green', 'gray', 'orange')" R.eval "jpeg('#{output}_match_distr.jpg')" clusters.each_with_index do |cluster, i| cluster_values = cluster.lengths.sort{|a,b| a[0]<=>b[0]}.map{ |x| a = Array.new(x[1],x[0])}.flatten color = "colors[#{i%5+1}]" R.eval "hist(c#{cluster_values.to_s.gsub('[','(').gsub(']',')')}, breaks = 30, xlim=c(#{middles.min-10},#{middles.max+10}), ylim=c(0,#{max_freq}), col=#{color}, border=#{color}, main='Predction match distribution (middle of the matches)', xlab='position idx', ylab='Frequency')" R.eval "par(new=T)" end R.eval "dev.off()" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_histo_clusters(output, clusters = @clusters, predicted_length = @prediction.xml_length, \n most_dense_cluster_idx = @max_dense_cluster)\n begin\n raise TypeError unless clusters[0].is_a? Cluster and predicted_length.is_a? Fixnum\n\n lengths = clusters.map{ |c| c.lengt...
[ "0.7272279", "0.59896815", "0.5975609", "0.5975609", "0.53550607", "0.53550607", "0.5319849", "0.52916485", "0.52227646", "0.5083247", "0.48855948", "0.4876291", "0.48360842", "0.4809604", "0.48078868", "0.48035938", "0.47551394", "0.47483408", "0.4743495", "0.46621466", "0.4...
0.8123314
1
Plots lines corresponding to each hit highlights the matched region of the prediction for each hit Param +output+: location where the plot will be saved in jped file format +lst+: array of Sequence objects +predicted_seq+: Sequence objects
def plot_matched_regions(output, lst = @hits, predicted_seq = @prediction) max_len = lst.map{|x| x.xml_length.to_i}.max max_plots = 120 skip= lst.length/max_plots len = predicted_seq.xml_length R.eval "jpeg('#{output}_match.jpg')" R.eval "plot(1:#{lst.length-1}, xlim=c(0,#{len}), xlab='Prediction length (black) vs part of the prediction that matches hit x (red/yellow)',ylab='Hit Number', col='white')" R.eval "colors = c('yellow', 'red')" R.eval "colors2 = c('black', 'gray')" height = -1; lst.each_with_index do |seq,i| #if skip == 0 or i%skip == 0 #if i < max_plots height += 1 color = "colors[#{height%2+1}]" color2 = "colors2[#{height%2+1}]" R.eval "lines(c(1,#{len}), c(#{height}, #{height}), lwd=7)" seq.hsp_list.each do |hsp| R.eval "lines(c(#{hsp.match_query_from},#{hsp.match_query_to}), c(#{height}, #{height}), lwd=6, col=#{color})" end #end end R.eval "dev.off()" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_length(output, lst = @hits, predicted_seq = @prediction)\n max_len = lst.map{|x| x.xml_length.to_i}.max\n lst = lst.sort{|a,b| a.xml_length<=>b.xml_length}\n\n max_plots = 120\n skip= lst.length/max_plots\n\n R.eval \"jpeg('#{output}_len.jpg')\"\n R.eval \"plot(1:#{[lst.length-1,max_plot...
[ "0.6684869", "0.62019897", "0.62019897", "0.5565769", "0.5397257", "0.5397257", "0.5109807", "0.4992956", "0.48825315", "0.4812277", "0.47926494", "0.4722102", "0.4710924", "0.46905696", "0.4655519", "0.46242842", "0.46168122", "0.45717505", "0.4495243", "0.4480476", "0.44785...
0.8380212
1
Plots 2D graph with the start/end of the matched region offsets in the prediction Param +output+: location where the plot will be saved in jped file format +hits+: array of Sequence objects
def plot_2d_start_from(output, hits = @hits) pairs = @hits.map {|hit| Pair.new(hit.hsp_list.map{|hsp| hsp.match_query_from}.min, hit.hsp_list.map{|hsp| hsp.match_query_to}.max)} xx = pairs.map{|pair| pair.x} yy = pairs.map{|pair| pair.y} min_start = hits.map{|hit| hit.hsp_list.map{|hsp| hsp.match_query_from}.min}.min max_start = hits.map{|hit| hit.hsp_list.map{|hsp| hsp.match_query_from}.max}.max min_end = hits.map{|hit| hit.hsp_list.map{|hsp| hsp.match_query_to}.min}.min max_end = hits.map{|hit| hit.hsp_list.map{|hsp| hsp.match_query_to}.min}.max #calculate the likelyhood to have a binomial distribution #split into two clusters #hc = HierarchicalClusterization.new(pairs) #clusters = hc.hierarchical_clusterization_2d(2, 1) R.eval "jpeg('#{output}_match_2d.jpg')" R.eval "colors = c('red', 'blue')"; #clusters.each_with_index do |cluster, i| # x_values = cluster.objects.map{|pair| pair[0].x} # y_values = cluster.objects.map{|pair| pair[0].y} x_values = xx y_values = yy color = "'red'"#"colors[#{i%2+1}]" R.eval "plot(c#{x_values.to_s.gsub("[","(").gsub("]",")")}, c#{y_values.to_s.gsub("[","(").gsub("]",")")}, xlim=c(0,#{max_start+10}), ylim=c(0,#{max_end+10}), col=#{color}, main='Start vs end match 2D plot', xlab='from', ylab='to', pch=10)" R.eval "par(new=T)" #end R.eval "x = c#{xx.to_s.gsub("[","(").gsub("]",")")}" R.eval "y = c#{yy.to_s.gsub("[","(").gsub("]",")")}" R.eval "abline(lm(y~x, singular.ok=FALSE))" R.eval "slope = lm(y~x)$coefficients[2]" slope = R.pull "slope" R.eval "dev.off()" return slope end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_matched_regions(output, lst = @hits, predicted_seq = @prediction)\n\n max_len = lst.map{|x| x.xml_length.to_i}.max\n\n max_plots = 120\n skip= lst.length/max_plots\n len = predicted_seq.xml_length\n\n R.eval \"jpeg('#{output}_match.jpg')\"\n R.eval \"plot(1:#{lst.length-1}, xlim=c(0,#{le...
[ "0.8237184", "0.8237184", "0.663794", "0.6104982", "0.6104982", "0.5706175", "0.5691258", "0.5534429", "0.5451303", "0.5418845", "0.54171956", "0.53642803", "0.52308595", "0.5198663", "0.5097252", "0.50096875", "0.5006462", "0.49857378", "0.49852777", "0.4976789", "0.49689916...
0.7929727
3
GET /user_profs GET /user_profs.json
def index @user_profs = UserProf.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_info\n user = User.find_by(id: params[:id])\n progresses = user.progresses.select {|p| p.habit.user.id == params[:id]} \n \n render json: progresses\n end", "def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.htm...
[ "0.6449449", "0.6098734", "0.609093", "0.6032934", "0.59987545", "0.5979397", "0.59568655", "0.5929411", "0.58765864", "0.5866938", "0.58642995", "0.583865", "0.5815065", "0.5794771", "0.5767578", "0.57649016", "0.5755632", "0.57137054", "0.57055724", "0.5694492", "0.56871736...
0.666078
0
GET /user_profs/1 GET /user_profs/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @user_profs = UserProf.all\n end", "def user_info\n user = User.find_by(id: params[:id])\n progresses = user.progresses.select {|p| p.habit.user.id == params[:id]} \n \n render json: progresses\n end", "def show\n @prospective_user = ProspectiveUser.find(pa...
[ "0.6568097", "0.6520125", "0.62878555", "0.6166493", "0.6087699", "0.60699147", "0.6062079", "0.60473275", "0.60421115", "0.60397387", "0.6009392", "0.60060924", "0.5989632", "0.59664476", "0.5959644", "0.5949377", "0.59435225", "0.5937409", "0.59162486", "0.5906291", "0.5890...
0.0
-1
POST /user_profs POST /user_profs.json
def create @user_prof = UserProf.new(user_prof_params) respond_to do |format| if @user_prof.save format.html { redirect_to @user_prof, notice: 'User prof was successfully created.' } format.json { render :show, status: :created, location: @user_prof } else format.html { render :new } format.json { render json: @user_prof.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prospie_params\n #params.require(:prospy).permit(:user_id)\n end", "def create\n @usersprof = Usersprof.new(usersprof_params)\n\n respond_to do |format|\n if @usersprof.save\n format.html { redirect_to @usersprof, notice: 'Usersprof was successfully created.' }\n format.json ...
[ "0.64934653", "0.63458455", "0.62872964", "0.6278106", "0.62143296", "0.61471796", "0.607801", "0.60190815", "0.6017775", "0.5963893", "0.5913241", "0.5896683", "0.58910036", "0.5839835", "0.5772199", "0.5772152", "0.5738288", "0.5679526", "0.5660542", "0.5646848", "0.5633829...
0.6190117
5
PATCH/PUT /user_profs/1 PATCH/PUT /user_profs/1.json
def update respond_to do |format| if @user_prof.update(user_prof_params) format.html { redirect_to @user_prof, notice: 'User prof was successfully updated.' } format.json { render :show, status: :ok, location: @user_prof } else format.html { render :edit } format.json { render json: @user_prof.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @proyectos_user.update(proyectos_user_params)\n format.html { redirect_to @proyectos_user, notice: 'Proyectos user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n forma...
[ "0.6395326", "0.6344992", "0.63435876", "0.62153316", "0.61638474", "0.613757", "0.61265445", "0.61190313", "0.611427", "0.61089057", "0.60952926", "0.60903263", "0.6056137", "0.60409975", "0.6018409", "0.5999067", "0.59987885", "0.5993437", "0.5993437", "0.5991999", "0.59870...
0.6085813
12
DELETE /user_profs/1 DELETE /user_profs/1.json
def destroy @user_prof.destroy respond_to do |format| format.html { redirect_to user_profs_url, notice: 'User prof was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @usersprof.destroy\n respond_to do |format|\n format.html { redirect_to usersprofs_url, notice: 'Usersprof was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @proyectos_user.destroy\n respond_to do |format|\n format.html { r...
[ "0.67678934", "0.66955876", "0.6683446", "0.6648809", "0.65716386", "0.65551955", "0.65112215", "0.6479446", "0.6455628", "0.64520663", "0.6445305", "0.64249736", "0.64193344", "0.6419241", "0.6398846", "0.6398846", "0.6388694", "0.6385878", "0.63845015", "0.6370276", "0.6364...
0.6947756
0
Use callbacks to share common setup or constraints between actions.
def set_user_prof @user_prof = UserProf.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 user_prof_params params.require(:user_prof).permit(:name, :age, :male) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /accountadmin_languages GET /accountadmin_languages.xml
def index @accountadmin_languages = AccountadminLanguage.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @accountadmin_languages } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def languages\n get(\"/repos/show/#{owner.login}/#{name}/languages\")['languages']\n end", "def index\n @admin_languages = Language.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @admin_languages }\n end\n end", "def getLangs\r\n re...
[ "0.71310616", "0.6991055", "0.69547", "0.6926081", "0.68268365", "0.6675764", "0.65801525", "0.6528495", "0.6507384", "0.6496832", "0.6480434", "0.6469375", "0.6461403", "0.6315235", "0.6279427", "0.6275889", "0.62589943", "0.6235573", "0.6222273", "0.6214709", "0.618198", ...
0.73413813
0
GET /accountadmin_languages/1 GET /accountadmin_languages/1.xml
def show @accountadmin_language = AccountadminLanguage.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @accountadmin_language } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @accountadmin_languages = AccountadminLanguage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accountadmin_languages }\n end\n end", "def index\n @admin_languages = Language.all\n\n respond_to do |format|\n format.html # in...
[ "0.74364", "0.7145597", "0.6954677", "0.6734465", "0.6621887", "0.65871537", "0.6560833", "0.6464557", "0.6432614", "0.6424834", "0.63286036", "0.6300758", "0.62794876", "0.6222614", "0.62132907", "0.62096876", "0.61893016", "0.6123214", "0.6113174", "0.61019677", "0.60735667...
0.72254866
1
GET /accountadmin_languages/new GET /accountadmin_languages/new.xml
def new @accountadmin_language = AccountadminLanguage.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @accountadmin_language } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @admin_language = Language.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_language }\n end\n end", "def new\n @language = Language.new\n @locale_name = Language.where(iso_639_code: I18n.locale).first.name\n\n respond_to do ...
[ "0.775093", "0.75624675", "0.7512097", "0.74473727", "0.71104944", "0.70680565", "0.70216084", "0.6933433", "0.69149613", "0.6908075", "0.6818002", "0.6817489", "0.6765967", "0.6647083", "0.6589179", "0.6586824", "0.658488", "0.6567974", "0.65167767", "0.650669", "0.64991474"...
0.7785269
0
POST /accountadmin_languages POST /accountadmin_languages.xml
def create @accountadmin_language = AccountadminLanguage.new(params[:accountadmin_language]) respond_to do |format| if @accountadmin_language.save flash[:notice] = 'Language was successfully created.' format.html { redirect_to(@accountadmin_language) } format.xml { render :xml => @accountadmin_language, :status => :created, :location => @accountadmin_language } else format.html { render :action => "new" } format.xml { render :xml => @accountadmin_language.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @admin_language = Language.new(params[:admin_language])\n\n respond_to do |format|\n if @admin_language.save\n format.html { redirect_to(@admin_language, :notice => 'Language was successfully created.') }\n format.xml { render :xml => @admin_language, :status => :created, :lo...
[ "0.6271392", "0.61242443", "0.60882825", "0.6021925", "0.6004349", "0.5958889", "0.59531134", "0.5924908", "0.5920992", "0.59133804", "0.5904091", "0.5866294", "0.579996", "0.5743481", "0.5716031", "0.569688", "0.56830835", "0.56661934", "0.5661371", "0.5659403", "0.5641717",...
0.66308665
0
PUT /accountadmin_languages/1 PUT /accountadmin_languages/1.xml
def update @accountadmin_language = AccountadminLanguage.find(params[:id]) respond_to do |format| if @accountadmin_language.update_attributes(params[:accountadmin_language]) flash[:notice] = 'Language was successfully updated.' format.html { redirect_to(@accountadmin_language) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @accountadmin_language.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @admin_language = Language.find(params[:id])\n\n respond_to do |format|\n if @admin_language.update_attributes(params[:admin_language])\n format.html { redirect_to(@admin_language, :notice => 'Language was successfully updated.') }\n format.xml { head :ok }\n else\n ...
[ "0.66875863", "0.6339196", "0.63347596", "0.6203142", "0.6165329", "0.61635226", "0.61280257", "0.6094286", "0.6079223", "0.6045375", "0.6044631", "0.60355735", "0.6023909", "0.5990224", "0.59779996", "0.59668875", "0.596315", "0.59573567", "0.5949806", "0.59451103", "0.59256...
0.6877068
0
DELETE /accountadmin_languages/1 DELETE /accountadmin_languages/1.xml
def destroy @accountadmin_language = AccountadminLanguage.find(params[:id]) @accountadmin_language.destroy unless @accountadmin_language.errors.empty? flash[:notice] = "WARNING: Couldn't delete language because:" @accountadmin_language.errors.full_messages.each { |m| flash[:notice] << "<br/>" << m } end respond_to do |format| format.html { redirect_to(accountadmin_languages_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @admin_language = Language.find(params[:id])\n @admin_language.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_languages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @language = Language.find(params[:id])\n @language.destroy\n\n ...
[ "0.72751725", "0.6865204", "0.6865204", "0.67768013", "0.67136467", "0.6668759", "0.6599307", "0.65917444", "0.65749955", "0.6561734", "0.64327043", "0.64249367", "0.63969314", "0.6373211", "0.6369946", "0.6357765", "0.63500404", "0.63465", "0.6335696", "0.63244855", "0.63206...
0.72383875
1
Returns a function that given a builder, constructs an Ammendment
def xml_builder lambda do |builder| builder[:api].amend do builder[:api].requests do Array.wrap(amendments).each do |amendment| build_object builder, :amendments, amendment, :obj end build_object builder, :amend_options, amend_options, :api build_object builder, :preview_options, preview_options, :api end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def builder; end", "def builder; end", "def builder; end", "def build opts = nil, &blk\n builder.build opts, &blk\n end", "def build(builder = nil)\n if builder.nil?\n builder = Builder.new\n islocal = true\n else\n islocal = false\n end\n builder.position_a...
[ "0.649306", "0.649306", "0.649306", "0.61381567", "0.60702884", "0.60698706", "0.60583186", "0.6009755", "0.58988655", "0.5888387", "0.5829127", "0.58145237", "0.5807656", "0.5807656", "0.5747599", "0.57413185", "0.5709144", "0.5709144", "0.56850547", "0.56778854", "0.5668337...
0.67037624
0
Builds one node. Behavior differs based on whether value is a hash If value is a hash, a parent node is rendered and the call is applied to its children. If it is a child node, a child node is rendered.
def build_node(builder, child_ns, field, value) field = Zuora::Utils::Envelope.to_zuora_key field if value.respond_to?(:each) # Parent builder[:api].send(field) { build_nodes builder, value, child_ns } else # Child builder[child_ns].send(field, value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_node(value)\n klass = class_for_value(value)\n value = RDF::Node.new if value.nil?\n node = node_cache[value] if node_cache[value]\n node ||= klass.from_uri(value,parent)\n return nil if property_config[:class_name] && class_for_value(value) != class_for_property\n self.node_...
[ "0.61756784", "0.6169589", "0.5960126", "0.594672", "0.5928419", "0.59205437", "0.585914", "0.5740865", "0.5712952", "0.56933945", "0.5598244", "0.5565982", "0.55595213", "0.5523081", "0.55135155", "0.5502011", "0.54962146", "0.5483429", "0.5457715", "0.54228264", "0.5420901"...
0.61249906
2
Takes a hash and builds SOAP XML nodes. See build_node for behavior.
def build_nodes(builder, root, child_ns) root.each(&->(k, v) { build_node builder, child_ns, k, v }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_xml_from_hash(hash, base_type, collection_key)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.send(base_type) { process_simple_array(collection_key, hash, xml) }\n end\n\n builder.to_xml\n end", "def generate_xml_from_hash(hash, base_type, collection_key)\n builder = Nokog...
[ "0.69823146", "0.6897439", "0.65200585", "0.6433577", "0.6354556", "0.6310398", "0.62798303", "0.612074", "0.6014107", "0.5933683", "0.5823071", "0.5787899", "0.5769073", "0.56935716", "0.5635453", "0.5624086", "0.56131744", "0.5611895", "0.55980647", "0.5583027", "0.55706906...
0.5606163
18
Helper to recursively build XML from nested objects.
def build_object(builder, property_name, object, child_ns) raise 'Objects must respond to each' unless object.respond_to?(:each) object_name = Zuora::Utils::Envelope.to_zuora_key property_name builder[:api].send(object_name) do build_nodes builder, object, child_ns end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buildXmlFromObject(obj, parent_tag=nil)\n xml = \"\"\n has_parent = !parent_tag.nil?\n\n # Arrays are formatted with the parent tag\n # wrapping each of the array elements for some\n # reason\n if obj.is_a? Array\n obj.each do |e|\n xml += has_parent ? \"<#{parent_...
[ "0.72742313", "0.71159273", "0.6555127", "0.64874154", "0.64253056", "0.6297084", "0.6290881", "0.6276235", "0.6239569", "0.59886783", "0.5966372", "0.59327847", "0.5918534", "0.5849283", "0.58432364", "0.58249694", "0.5824222", "0.5806076", "0.58040285", "0.58033967", "0.580...
0.6238723
9
Returns a collection of User records for team of specified color
def users_for_team(color) team = team_by_color(color) team ? team.users : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users_for_team(color_id)\n team = team_by_color(color_id)\n team ? team.users : nil\n end", "def team_colors(user_team_name)\n game_hash.each do |k, team|\n if team[:team_name] == user_team_name\n return team[:colors]\n end\n end\nend", "def teams\n # find all my TeamColor relationsh...
[ "0.8116154", "0.6447643", "0.6364943", "0.6203593", "0.61838067", "0.61484474", "0.6139616", "0.6103306", "0.60972863", "0.6086105", "0.60741466", "0.60340726", "0.59888095", "0.5954497", "0.5953822", "0.5949379", "0.5930344", "0.5925358", "0.5921518", "0.59136426", "0.583834...
0.8260457
0
Returns true if game is in progress
def in_progress? self.status == 'active' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_has_started?\n game.move > 0\n end", "def finished?\n current_step > 1 && current_step >= game_length + 1\n end", "def finished?\n @turns_allowed < 0\n end", "def game_running?\n @game_running\nend", "def run_on_busy_tb?\n $game_message.busy?\n end", "def finished?\n ...
[ "0.81989074", "0.7592544", "0.75358003", "0.7510532", "0.73639727", "0.73320967", "0.7306314", "0.727434", "0.72632825", "0.7226301", "0.7215609", "0.7214246", "0.7213497", "0.7211079", "0.7205171", "0.71792614", "0.7161313", "0.71570456", "0.7129938", "0.7129938", "0.7115571...
0.66119766
88
Returns true if game is finished
def finished? self.status == 'finished' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished?\n game && game.count { |h| h[:finished] == true && h[:final] } == 6\n end", "def finished?\n current_step > 1 && current_step >= game_length + 1\n end", "def finished?\n @game.finished || @pass_order.size == @game.players.size\n end", "def game_finished?\n finished ...
[ "0.8157894", "0.8140047", "0.8134539", "0.8126047", "0.7973508", "0.7792383", "0.77889115", "0.773589", "0.7728748", "0.7669066", "0.7667263", "0.76317686", "0.7611752", "0.7592921", "0.7591231", "0.758491", "0.75336415", "0.7523917", "0.7501705", "0.74856246", "0.74652094", ...
0.0
-1
Returns score as string
def score_as_string(delimiter = ' /') str = [] self.teams.each do |t| str << t.score.to_s end str.join delimiter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def return_score(score)\n return \"#{score}\" \n end", "def score\n \"#{score1}-#{score2}\"\n end", "def to_s\n\t\t\"Score : Pseudo = #{@pseudo}, Points = #{@score}, Temps = #{@time}, Malus = #{@malus}\\n\"\n\tend", "def get_score\n \"#{@name} #{@lives}/3\"\n end", "def pretty_score\n ...
[ "0.7871547", "0.77757", "0.75705796", "0.73945516", "0.73276365", "0.72802496", "0.7242312", "0.71669877", "0.706918", "0.69916165", "0.68633884", "0.68596804", "0.68415505", "0.6839467", "0.6839467", "0.68209255", "0.68172926", "0.681267", "0.6773187", "0.6768213", "0.675480...
0.717597
8
Finishes the game, setting winners/losers
def finish transaction do winner = self.teams.where('score >= ?',5).first loser = self.teams.where('score < ?',5).first if winner and loser winner.win loser.lose self.status = 'finished' self.save end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end_game()\n get_winners()\n end", "def end_game\n @state = 'stop'\n @winner = true\n get_winning_player\n puts \"================ ===================== ===================\"\n puts \"-------------------- GAME OVER! ______________________________________\"\n puts \"_________...
[ "0.8114069", "0.77654237", "0.7622532", "0.75771743", "0.730909", "0.71837693", "0.7066831", "0.7048006", "0.7017069", "0.70125", "0.69997156", "0.6978587", "0.69279134", "0.692511", "0.6881135", "0.68468785", "0.68111384", "0.6771092", "0.6770426", "0.6708328", "0.66950446",...
0.6881833
14
Sets winner for the game
def set_winner(team) if team.win self.status = 'finished' self.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_determine_set_winner()\n @score_count.set_determine_set_winner()\n end", "def winner=(player)\n self.save && self.reload\n # The winner scores 1\n process_result(player, 1)\n # The other players score 0\n self.players.to_a.each do |one_player|\n unless one_player == player\n ...
[ "0.74516577", "0.74500674", "0.7417488", "0.7417488", "0.7187351", "0.70818615", "0.7067998", "0.70593655", "0.70200235", "0.69991946", "0.6922101", "0.68861485", "0.68593246", "0.6849187", "0.6827827", "0.6819448", "0.68065876", "0.6788338", "0.6770368", "0.6760744", "0.6748...
0.7470485
0
Finds the winning team for the game by score
def winning_team self.teams.order('score DESC').first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def winning_team\n f...
[ "0.7784258", "0.7776425", "0.77156854", "0.76649827", "0.7646874", "0.75718296", "0.753856", "0.73577046", "0.73303497", "0.732269", "0.731362", "0.7312433", "0.72945946", "0.728458", "0.72323257", "0.72146076", "0.72049946", "0.7197998", "0.7142061", "0.71299106", "0.7051559...
0.7679581
3
Written in 2013 by Peter Occil. Any copyright to this work is released to the Public Domain. Converts unit tests to the NUnit testing framework. Reads a UTF8 file to a string, ignoring the byte order mark.
def utf8read(x) File.open(x,"rb"){|f| if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf f.pos=0 # skip UTF-8 byte order mark end data=f.read ec1=Encoding::Converter.new("utf-8","utf-16",{ :undef=>:replace, :invalid=>:replace }) ec2=Encoding::Converter.new("utf-16","utf-8",{ :undef=>:replace, :invalid=>:replace, :replace=>"\uFFFD" }) data=ec1.convert(data) data=ec2.convert(data) return data } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def explicit_transcode(filename, from_encoding, to_encoding)\n puts ''\n puts `file test_files/#{filename}`\n puts \"transcoding from #{from_encoding.name} to #{to_encoding.name}\"\n\n file_str = read_file(filename)\n encoded_str = file_str.force_encoding(from_encoding).encode!(Encoding::UTF_8, from_encoding)...
[ "0.6556069", "0.61222476", "0.601842", "0.5935069", "0.58756906", "0.5827705", "0.582299", "0.5786851", "0.5759429", "0.56482124", "0.5643542", "0.5603456", "0.55767643", "0.55281657", "0.55041623", "0.54807335", "0.54708904", "0.5445826", "0.54374087", "0.5401329", "0.540022...
0.6196327
1
Writes a UTF8 string to a file
def utf8write(str,f) File.open(f,"wb:utf-8"){|ff| ff.write(str) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_utf(file, string, md)\n write_short(file, string.length, md)\n write(file, string, md)\n end", "def write(s)\n @file.write(s)\n end", "def brf_write(str)\n File.open(brf_file, 'w:UTF-8') { |f| f.write str }\n end", "def write(string, filename)\n Util::FileMutation.writ...
[ "0.74550915", "0.7235299", "0.7045385", "0.6838051", "0.67308277", "0.6697619", "0.6568848", "0.64812183", "0.6388018", "0.6361645", "0.6360129", "0.63529253", "0.6282842", "0.6271742", "0.6186248", "0.6177221", "0.61580527", "0.6097502", "0.6083698", "0.60427886", "0.6041100...
0.84723383
0
GET /commits GET /commits.json
def index @commits = Commit.joins(:repo).where("repos.user_id" => 1).order("created_at" => :desc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commits!\n response = @client.get_json(\"#{path}/commits\")\n @commits = response.map do |commit| \n Commit.new(client: @client, user: @user, repo: self, sha: commit['sha']) \n end\n @commits\n end", "def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n ...
[ "0.7845555", "0.7726259", "0.7603464", "0.74982595", "0.74982595", "0.74556094", "0.741974", "0.741108", "0.73717153", "0.73685825", "0.7324753", "0.7301729", "0.7210173", "0.71995455", "0.7159158", "0.70021", "0.6998252", "0.6954695", "0.6917154", "0.6897366", "0.6884207", ...
0.6655944
24
GET /commits/1 GET /commits/1.json
def show @commit = Commit.find(params[:id]) if !@commit || @commit.try(:repo).try(:user) != current_user redirect_to commits_path, alert: "commit not found" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_commits\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_commits(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get recent commit: #{ex.message} (#{ex.class})\"\n ...
[ "0.745821", "0.7405335", "0.7288144", "0.7235319", "0.7197497", "0.7169992", "0.708119", "0.7049726", "0.69932216", "0.69841516", "0.697522", "0.69207865", "0.69207865", "0.6840269", "0.68158793", "0.68048435", "0.67344284", "0.67099994", "0.6611551", "0.65759677", "0.6569615...
0.62502265
33
GET /qualifications GET /qualifications.json
def index @qualifications = Qualification.all respond_to do |format| format.html # index.html.erb format.json { render json: @qualifications } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qualifications\n @qualifications = Qualification.all\n end", "def index\n @qualifications = Qualification.all\n end", "def index\n @qualifications ||= Qualification.all\n end", "def show\n @qualification = Qualification.find(params[:id])\n\n respond_to do |format|\n format...
[ "0.7948029", "0.70647323", "0.70307547", "0.66601676", "0.6433836", "0.63250744", "0.6298371", "0.6283414", "0.62635106", "0.61398196", "0.6074767", "0.6037782", "0.60085976", "0.5965509", "0.5914665", "0.5883446", "0.585265", "0.585265", "0.585265", "0.5843954", "0.57935137"...
0.7210914
1
GET /qualifications/1 GET /qualifications/1.json
def show @qualification = Qualification.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @qualification } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qualifications\n @qualifications = Qualification.all\n end", "def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qualifications }\n end\n end", "def index\n @qualifications = Qualificati...
[ "0.7501599", "0.7344044", "0.71251506", "0.69884384", "0.67099285", "0.6482687", "0.6482687", "0.6482687", "0.64820164", "0.64567935", "0.6421062", "0.6362748", "0.63052964", "0.62307256", "0.60943234", "0.60909003", "0.6045383", "0.6040123", "0.60328096", "0.6028524", "0.599...
0.7340831
2
GET /qualifications/new GET /qualifications/new.json
def new @qualification = Qualification.new respond_to do |format| format.html # new.html.erb format.json { render json: @qualification } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @qualification = Qualification.new(params[:qualification])\n\n respond_to do |format|\n if @qualification.save\n format.html { redirect_to @qualification, notice: 'Qualification was successfully created.' }\n format.json { render json: @qualification, status: :created, locatio...
[ "0.72234327", "0.71787894", "0.6622708", "0.65698546", "0.6546859", "0.65240836", "0.65168405", "0.63966995", "0.6395806", "0.63932437", "0.6366755", "0.6353062", "0.6326201", "0.6312639", "0.6307363", "0.63071024", "0.6276693", "0.62624943", "0.6247574", "0.6242675", "0.6241...
0.7906973
0
POST /qualifications POST /qualifications.json
def create @qualification = Qualification.new(params[:qualification]) respond_to do |format| if @qualification.save format.html { redirect_to @qualification, notice: 'Qualification was successfully created.' } format.json { render json: @qualification, status: :created, location: @qualification } else format.html { render action: "new" } format.json { render json: @qualification.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def qualification_params\n params.require(:qualification).permit(:name, :experience, :project_id, :user_id)\n end", "def create\n @profile ||= Profile.find(params[:profile_id])\n @qualification = @profile.qualifications.new(qualification_params)\n @qualification.save\n end", "def qualificatio...
[ "0.7061001", "0.6930414", "0.6925278", "0.67445683", "0.6710166", "0.66898906", "0.66554725", "0.6480371", "0.6296001", "0.6269745", "0.62607026", "0.62558275", "0.6149648", "0.61309236", "0.6119616", "0.60779285", "0.59752166", "0.59752166", "0.59752166", "0.59537214", "0.59...
0.687265
3
PUT /qualifications/1 PUT /qualifications/1.json
def update @qualification = Qualification.find(params[:id]) respond_to do |format| if @qualification.update_attributes(params[:qualification]) format.html { redirect_to @qualification, notice: 'Qualification was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @qualification.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @qualification.update(qualification_params)\n format.html { redirect_to @qualification, notice: 'Qualification was successfully updated.' }\n format.json { render :show, status: :ok, location: @qualification }\n else\n format.html { render ...
[ "0.7187117", "0.70283407", "0.6899876", "0.68838537", "0.68838537", "0.68838537", "0.6830136", "0.665552", "0.6571172", "0.65701157", "0.65509605", "0.65021014", "0.6384791", "0.63282204", "0.62357026", "0.62281054", "0.6165247", "0.6118579", "0.60737824", "0.6054554", "0.604...
0.7301351
0
DELETE /qualifications/1 DELETE /qualifications/1.json
def destroy @qualification = Qualification.find(params[:id]) @qualification.destroy respond_to do |format| format.html { redirect_to qualifications_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @qualification = Qualification.find(params[:id])\n @qualification.destroy\n\n respond_to do |format|\n format.html { redirect_to(qualifications_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @qualification.destroy\n respond_to do |format|\n format.h...
[ "0.753164", "0.7381286", "0.72384614", "0.6919844", "0.68369436", "0.6691672", "0.66555166", "0.66540956", "0.66181755", "0.6607054", "0.65825015", "0.6530299", "0.6522036", "0.6495034", "0.64525306", "0.6389934", "0.63895386", "0.638682", "0.6382794", "0.63679487", "0.636740...
0.7708333
0
accepts an array of request headers and formats them
def pretty_print_requests(requests = [], fields = []) headers = requests.map do |request| pretty_print_headers request end headers.join + fields.join('&') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unify_headers(headers)\n lines = []\n headers.each_pair do |k, v|\n lines << v.map { |val| \"#{k}: #{val}\" }\n end\n\n logger.debug \"Unified headers #{lines.inspect}\" if logger_debug?\n lines.flatten.sort\n end", "def headers(hea...
[ "0.6942746", "0.6941549", "0.6851459", "0.67778504", "0.6755011", "0.6542981", "0.65371025", "0.65263015", "0.65259266", "0.6479189", "0.6472597", "0.6350045", "0.63428235", "0.6339399", "0.6331918", "0.63270843", "0.62933975", "0.6283394", "0.626664", "0.62427896", "0.621927...
0.0
-1
Gets the application version
def version app = detect_product(GSA) || detect_product(GOOGLEPODCASTS) app.version end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def application_version\n read('application_version')\n end", "def app_version\n return @app_version\n end", "def app_version\n return @app_version\n end", "def application_version\n return @application_version\n en...
[ "0.88064575", "0.864153", "0.864153", "0.8458564", "0.8458564", "0.8340475", "0.7966316", "0.7817149", "0.77130497", "0.7699396", "0.75557077", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.75355244", "0.751...
0.7684284
10
after_filter :cors_set_access_control_headers For all responses in this controller, return the CORS access control headers in dev mode.
def cors_preflight_check logger.debug 'cors_preflight_check' headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS,PUT, DELETE' headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version' headers['Access-Control-Max-Age'] = '1728000' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cors_set_access_control_headers\n response.headers['Access-Control-Allow-Origin'] = '*'\n response.headers['Access-Control-Allow-Credentials'] = 'true'\n response.headers['Access-Control-Allow-Methods'] = 'GET, PUT, POST, DELETE, OPTIONS, PATCH'\n response.headers['Access-Co...
[ "0.82762367", "0.81681025", "0.81681025", "0.8161418", "0.8141324", "0.81224257", "0.80895793", "0.80814576", "0.8052453", "0.8050458", "0.79954344", "0.799059", "0.7990148", "0.7988951", "0.7970666", "0.7962865", "0.7952658", "0.79409534", "0.7933955", "0.7933929", "0.793007...
0.0
-1
Requires http header Authorization: Token token=
def authenticate authenticate_or_request_with_http_token do |token, _options| @current_user = User.find_by token: token end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def token\n request.headers['Authorization']\n end", "def token\n request.headers[\"Authorization\"]\n end", "def get_token\n request.headers[\"Authorization\"]\n end", "def authorize_request\n unless request.headers['Authorization'].present?\n render json: {message: 'Missing Token'}, s...
[ "0.7747544", "0.77426326", "0.76316917", "0.7594905", "0.75709146", "0.7407922", "0.7404757", "0.73918426", "0.737886", "0.734607", "0.7223055", "0.7198926", "0.7197692", "0.71972364", "0.71911824", "0.7175449", "0.71531457", "0.7142499", "0.713808", "0.7129177", "0.71237254"...
0.0
-1
Review responds as a get request to review the resource before saving
def review respond_to do |format| format.js do @resource = StashEngine::Resource.find(params[:id]) check_required_fields(@resource) @review = Resource::Review.new(@resource) @resource.has_geolocation = @review.geolocation_data? @resource.save! end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @resource = Resource.find(params[:id])\n @reviews = Review.where(:resource_id => @resource.id).order('created_at DESC').all\n @new_review = Review.new(:resource_id => @resource.id) unless !user_signed_in? or Review.exists?(:resource_id => @resource.id, :reviewer_id => current_user.id)\n\n re...
[ "0.6902789", "0.6738987", "0.67336327", "0.66774476", "0.666766", "0.6663883", "0.6629197", "0.66290087", "0.6618846", "0.6604234", "0.6604234", "0.6604234", "0.65872544", "0.6540342", "0.6528173", "0.6504426", "0.6495801", "0.649523", "0.649523", "0.649523", "0.649523", "0...
0.70860565
0
TODO: move code to StashEngine::Resource?
def submission resource_id = params[:resource_id] resource = StashEngine::Resource.find(resource_id) return if processing?(resource) update_submission_resource_info(resource) StashEngine.repository.submit(resource_id: resource_id) resource.reload redirect_to(stash_url_helpers.dashboard_path, notice: resource_submitted_message(resource)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource; end", "def resource(*resources, &block); end", "def resource\n @resource ||= resource_set.createResource(uri)\n end", "def resources; end", "def resources; end", "def resources()\n end", "def resource\n @resource\n end", "def check_resource_semantics!; end", "def resource\n...
[ "0.6610153", "0.58753407", "0.5833817", "0.5827769", "0.5827769", "0.5816107", "0.58144236", "0.5804506", "0.57233894", "0.5679693", "0.5677968", "0.5677968", "0.5668843", "0.5658707", "0.56301475", "0.56301475", "0.56040907", "0.5536425", "0.5520835", "0.5514207", "0.5497572...
0.0
-1
The repeat method above has an optional num argument. If we call repeat without explicitly passing in a value for num, num will be implicitly passed in with the value 1. A fairly common design pattern is to set an arg to nil by default
def greet(person_1, person_2=nil) if person_2.nil? p "Hey " + person_1 else p "Hey " + person_1 + " and " + person_2 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeat(message, num = 1)\n message * num\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(param_integer, param_string)\n param_integer.times do\n puts \"param_stri...
[ "0.7192909", "0.69073945", "0.69073945", "0.69073945", "0.6839217", "0.6807949", "0.6807949", "0.67638403", "0.6761382", "0.6758051", "0.6715312", "0.6701545", "0.6692953", "0.6684767", "0.6677173", "0.6666384", "0.6658183", "0.66526514", "0.6652623", "0.6652623", "0.665201",...
0.0
-1
Best practice to have optional parameters listed after the required ones. So avoid writing code like this:
def greet(person_1="default", person_2) p person_1 + " and " + person_2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optionalParameters(a,b,*c)\n #some code\nend", "def optional_params\n return {}\n end", "def optional_parameters\n must_be_defined_in_derived_class\n end", "def method_with_optional_param(param = foo)\nend", "def optional(*params)\n @optional = params unless params.empty?\n ...
[ "0.7645771", "0.75626075", "0.7282525", "0.72685957", "0.70317495", "0.6956485", "0.69007856", "0.6845102", "0.6765135", "0.6711751", "0.6689671", "0.6618249", "0.6603022", "0.6593676", "0.6579482", "0.65780777", "0.65454656", "0.65358084", "0.6513561", "0.6485246", "0.648403...
0.0
-1
=> "default and Chao" Optional Hashes If you have a method that accepts a hash as an argument, you can omit the braces when passing in the hash:
def method(hash) p hash # {"location"=>"SF", "color"=>"red", "size"=>100} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def this_hash(hash ={})\n puts \"The value is #{hash[:this_one]}\"\nend", "def my_method_hash(attrs = {})\n puts \"Name is #{attrs[:name]}\"\nend", "def takes_hash(opts = {})\n c = opts[:c]\nend", "def with_defaults(other_hash); end", "def defaults(hash)\n { temperature: 10, altitude: 12000, pressure...
[ "0.7400586", "0.6627518", "0.65585095", "0.6421115", "0.61809546", "0.61707073", "0.6121819", "0.6112165", "0.61051846", "0.60624987", "0.5943962", "0.5884645", "0.5850762", "0.58341646", "0.5783391", "0.57826877", "0.5768501", "0.57611203", "0.5746911", "0.5744822", "0.57231...
0.60641056
9
"HelloHelloHelloHello" Give default values to parameters
def repeat_copy(str, n = 1) return str * n end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hello(name=\"World\") # Default parameter\n puts \"Hello #{ name }\"\nend", "def say_hello(your_name, my_name = \"Dory\")\n puts \"Hello #{your_name}, I'm #{my_name}!\"\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def greet(greeting=\"Hello\")\n\tgreeting\nend", "def hello(name = 'World'...
[ "0.7834861", "0.74132633", "0.73612475", "0.73612475", "0.72733", "0.72527367", "0.7243331", "0.71832305", "0.7155219", "0.7149471", "0.7145463", "0.7145463", "0.7145463", "0.7145463", "0.7145463", "0.7061239", "0.6969271", "0.6960337", "0.6957404", "0.69473875", "0.6936908",...
0.0
-1
GET /invoices/1/send_to_customer sends an invoice to customer manually
def send_to_customer # call service businessdocument.document_send and delay it for background processing @businessdocument.document_send redirect_to billing_businessdocument_path(@businessdocument), notice: t(:businessdocument_has_been_sent) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customer_receipt(invoice) \n @invoice = invoice\n mail(:to => invoice.customer.email, :subject => \"Invoice #{@invoice.invoice_number} receipt\")\n end", "def buyer_invoices\n logger.info(\"Will send email of BUYER JDE and ZLot csvs\")\n email = current_employee.present? ? current_emp...
[ "0.72857654", "0.709532", "0.6956806", "0.6892691", "0.68362474", "0.67970926", "0.6571786", "0.6521722", "0.64215696", "0.6420487", "0.6384276", "0.63605106", "0.6358709", "0.6347584", "0.6323477", "0.62596315", "0.6240743", "0.6207065", "0.6186935", "0.61235267", "0.611535"...
0.6858704
4
GET /invoices/1/pdf Generate pdf
def create_pdf @new_businessdocument = @businessdocument.create_pdf redirect_to billing_businessdocument_path(@new_businessdocument), notice: t(:pdf_generation_started) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_pdf\n respond_with(invoice)\n end", "def invoice_as_pdf\n invoice_id = params['invoice_id']\n invoice = ChargeBee::Invoice.retrieve(invoice_id).invoice\n if invoice.subscription_id != @subscription_id\n redirect_to \"/400\"\n return\n end\n result = ChargeBee::Invoice.pdf(inv...
[ "0.8303803", "0.8104104", "0.7938259", "0.7926014", "0.79146355", "0.7864249", "0.7850897", "0.78246075", "0.7781346", "0.77704483", "0.7733634", "0.7718848", "0.7670431", "0.75879115", "0.7584193", "0.7581878", "0.75606996", "0.7531382", "0.752582", "0.75240725", "0.751135",...
0.0
-1
GET /invoices/1/download open pdf in browser
def download @businessdocument.create_pdf if !@businessdocument.pdf_exists? # @businessdocument.create_pdf end send_file(@businessdocument.pdf.path, filename: @businessdocument.pdf_file_name, type: 'application/pdf', disposition: 'inline') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_pdf\n send_file(\n \"#{Rails.root}/public/cv_eric_merlin.pdf\",\n filename: \"cv_eric_merlin.pdf\",\n type: \"application/pdf\"\n )\nend", "def download_document\n doc_name = Event::Document::MAPPING[params[:name].to_sym]\n pdf = File.new(\"public/documents/#{doc_name}\")\n pdf_d...
[ "0.7673284", "0.76025194", "0.75857466", "0.7577809", "0.7523866", "0.7512258", "0.741906", "0.74072886", "0.73831", "0.7254704", "0.72506005", "0.72425866", "0.7231885", "0.7228934", "0.7218981", "0.7186346", "0.71779674", "0.71310467", "0.71160895", "0.7113405", "0.71051264...
0.7595604
2
Package download in views/billing/datevdownload.xlsx.axlsx POST /datevexport
def datevdownload if params[:account][:export_fixed_at_start_date] date_from = params[:account][:export_fixed_at_start_date] else date_from = Date.today.beginning_of_month end if params[:account][:export_fixed_at_end_date] date_to = params[:account][:export_fixed_at_end_date] else date_to = Date.today.end_of_month end #@contacts = Billing::Businessdocument.joins(:contact).where("businessdocuments.type='Billing::Invoice' or businessdocuments.type='Billing::Cancellation'") @contact_ids = '' @businessdocumentpositions = Billing::Businessdocumentposition.includes(:businessdocument, :vat).where("(businessdocuments.type='Billing::Invoice' or businessdocuments.type='Billing::Cancellation') and invoice_number IS NOT NULL and invoice_date >= '#{date_from}' AND invoice_date <= '#{date_to}'").order("businessdocuments.invoice_number, businessdocuments.id, businessdocumentpositions.position, businessdocumentpositions.id") @businessdocuments = Billing::Businessdocument.where("(businessdocuments.type='Billing::Invoice' or businessdocuments.type='Billing::Cancellation') and invoice_date >= '#{date_from}' AND invoice_date <= '#{date_to}'").order("businessdocuments.invoice_number, businessdocuments.id") @account = current_tenant if params[:account][:export_fixed_at_start_date] and params[:account][:export_fixed_at_end_date] @account.tax_consultant_id = params[:account][:tax_consultant_id] @account.tax_consultant_client_id = params[:account][:tax_consultant_client_id] @account.revenue_account = params[:account][:revenue_account] @account.export_fixed_at_start_date = params[:account][:export_fixed_at_start_date] @account.export_fixed_at_end_date = params[:account][:export_fixed_at_end_date] @account.save end respond_to do |format| format.xlsx { authorize_feature! 'csv_export' response.headers['Content-Disposition'] = 'attachment; filename=' + "EXTF_#{I18n.t(:invoicelist)}-#{Date.today}.xlsx" } # format.csv { # authorize_feature! 'csv_export' # response.headers['Content-Disposition'] = 'attachment; filename=' + "#{I18n.t(:datevexport_csv_filename, startdate: @account.export_fixed_at_start_date.to_s, enddate: @account.export_fixed_at_end_date.to_s, createdate: Date.today.to_s)}.csv" # } format.csv do require 'zip' authorize_feature! 'csv_export' # create tmp_file with account id to ensure unique filenames tmp_dir = Rails.root.join('tmp', @account.id.to_s) Dir.mkdir(tmp_dir) unless File.exists?(tmp_dir) tmp_dir = Rails.root.join(tmp_dir, current_user.id.to_s) Dir.mkdir(tmp_dir) unless File.exists?(tmp_dir) start_date_short = (l @account.export_fixed_at_start_date, format: '%Y%m%d').to_s end_date_short = (l @account.export_fixed_at_end_date, format: '%Y%m%d').to_s today_short = (l Date.today, format: '%Y%m%d').to_s zip_file_name = "DATEV-Export_#{t(:from)}_#{start_date_short}_#{t(:until)}_#{end_date_short}_erstellt_#{today_short}.zip" filename_accounts = "EXTF_GP_Stamm_#{(l Date.today, format: '%Y%m%d')}.csv" filename_batch = "EXTF_Buchungsstapel_#{(@account.export_fixed_at_start_date.blank? ? '' : (l @account.export_fixed_at_start_date, format: '%Y%m%d').to_s)}_bis_#{(@account.export_fixed_at_end_date.blank? ? '' : (l @account.export_fixed_at_end_date, format: '%Y%m%d').to_s)}.csv" zip_file_path = Rails.root.join(tmp_dir, zip_file_name) File.delete(zip_file_path) if File.exist?(zip_file_path) Zip::ZipFile.open(zip_file_path.to_s, Zip::ZipFile::CREATE) do |zipfile| zipfile.get_output_stream(filename_accounts) { |f| f.write BusinessdocumentExportDatevCsv.new.get_contacts(@account, @businessdocumentpositions) } zipfile.get_output_stream(filename_batch) { |f| f.write BusinessdocumentExportDatevCsv.new.get_invoicepositions(@account, @businessdocumentpositions, date_from, date_to) } end send_file(zip_file_path, :type => 'application/zip', :disposition => 'attachment', :filename => zip_file_name) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download\n filename = params[:filename]\n send_file(\n \"#{Rails.root}/public/\" << filename << '.xlsx',\n filename: filename << '.xlsx'\n )\n end", "def download\n ExtensionVersion.increment_counter(:web_download_count, @version.id)\n Extension.increment_c...
[ "0.67708486", "0.672056", "0.6529861", "0.6529749", "0.6483607", "0.6438452", "0.643319", "0.64226675", "0.6372611", "0.63592315", "0.63389826", "0.62215203", "0.62150884", "0.6206289", "0.6169322", "0.6126547", "0.60959524", "0.6072549", "0.605817", "0.60444844", "0.6028141"...
0.7509038
0
Use callbacks to share common setup or constraints between actions.
def set_businessdocument # find any invoice.type by using Businessdocument as object class # so that search for STI object is NOT used @businessdocument = Billing::Businessdocument.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Ensure clean slate for testing +dir_or_file+ string path to a file or folder
def delete_directory_or_file(dir_or_file) if File.exist?(dir_or_file) FileUtils.rm_rf(dir_or_file) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_clean\n # Standard stuff\n assert_equal('/a/b/c', Pathname.new('/a/b/c').cleanpath)\n assert_equal('b/c', Pathname.new('./b/c').cleanpath)\n assert_equal('a', Pathname.new('a/.').cleanpath) # ***\n assert_equal('a/c', Pathname.new('a/./c').cleanpath)\n assert_equal('a/b', Pathnam...
[ "0.6760241", "0.6703122", "0.6620381", "0.6620381", "0.6620381", "0.6620381", "0.6620381", "0.6620381", "0.6356493", "0.63382465", "0.6169266", "0.6156721", "0.6154439", "0.615166", "0.61379486", "0.6115591", "0.60979897", "0.6069582", "0.6053151", "0.6053151", "0.6050403", ...
0.5853566
30
GET /interests GET /interests.xml
def index @interests = Interests.for_person(@person) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @interests } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @interest = Interest.find(params[:id])\n @interests = Interest.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def show\n @interests = Interests.find(params[:id])\n\n respond_to do |format|\n forma...
[ "0.73247635", "0.7179015", "0.6898394", "0.68887776", "0.68433845", "0.68433845", "0.68056345", "0.6803127", "0.67621666", "0.6751417", "0.6739361", "0.67297786", "0.65149987", "0.65114975", "0.6498129", "0.6489336", "0.64816064", "0.6431844", "0.64009035", "0.619042", "0.615...
0.71666723
2
GET /interests/1 GET /interests/1.xml
def show @interests = Interests.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @interests } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @interest = Interest.find(params[:id])\n @interests = Interest.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def index\n @interests = Interests.for_person(@person)\n\n respond_to do |format|\n fo...
[ "0.7378799", "0.7182912", "0.6681448", "0.6628751", "0.66265684", "0.6598339", "0.65426904", "0.6539564", "0.6406856", "0.6406856", "0.63889605", "0.63889605", "0.63749534", "0.62731373", "0.62235135", "0.6219584", "0.62033457", "0.6193669", "0.61063373", "0.6099474", "0.6059...
0.7290608
1
GET /interests/new GET /interests/new.xml
def new @interests = Interests.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @interests } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interes...
[ "0.7976331", "0.7459569", "0.7439511", "0.7424835", "0.7245862", "0.7232691", "0.69799864", "0.69603586", "0.69603586", "0.69304556", "0.6802353", "0.6800757", "0.6750831", "0.671535", "0.6632261", "0.6619029", "0.6617881", "0.6580456", "0.6573817", "0.65705746", "0.65601116"...
0.7799041
1
POST /interests POST /interests.xml
def create @interests = Interests.new(params[:interests]) @interests.person = @person respond_to do |format| if @interests.save flash[:notice] = 'Interests saved.' format.html { redirect_to(welcome_path(:id => @person)) } format.xml { render :xml => @interests, :status => :created, :location => @interests } else format.html { render :action => "new" } format.xml { render :xml => @interests.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n flash[:notice] = 'Interest was successfully created.'\n format.html { redirect_to(@interest) }\n format.xml { render :xml => @interest, :status => :created, :location => @inter...
[ "0.6998455", "0.6863823", "0.6807102", "0.67724216", "0.666766", "0.64777946", "0.6349124", "0.6344012", "0.63039637", "0.629234", "0.6265842", "0.6186481", "0.61811817", "0.6152584", "0.6152584", "0.6152584", "0.6152584", "0.6152584", "0.6138903", "0.6109719", "0.60970086", ...
0.69209045
1
PUT /interests/1 PUT /interests/1.xml
def update @interests = Interests.for_person(@person)[0] respond_to do |format| if @interests.update_attributes(params[:interests]) flash[:notice] = 'Interests updated.' format.html { redirect_to(person_path(:id => @person)) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @interests.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n ...
[ "0.69573444", "0.68996733", "0.67652136", "0.6645751", "0.6608416", "0.64342076", "0.6425807", "0.6425807", "0.6425807", "0.6425807", "0.6425807", "0.6333603", "0.624587", "0.6181125", "0.61621267", "0.61246186", "0.61246043", "0.6105461", "0.6084546", "0.60615796", "0.603918...
0.6832172
2
DELETE /interests/1 DELETE /interests/1.xml
def destroy @interests = Interests.find(params[:id]) @interests.destroy flash[:notice] = 'Interests was successfully removed.' respond_to do |format| format.html { redirect_to(interests_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleteInterest(interest)\n \n end", "def deleteInterest(interest)\n \n end", "def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to(interests_url) }\n format.xml { head :ok }\n end\n end", "def destr...
[ "0.7588674", "0.7588674", "0.7526527", "0.7018914", "0.7006266", "0.6992471", "0.696033", "0.69563323", "0.6913918", "0.6838638", "0.6757879", "0.67156816", "0.67156816", "0.66807324", "0.6675333", "0.657795", "0.6521716", "0.6515893", "0.6414979", "0.6313341", "0.6308665", ...
0.7322105
3
GET /milestones GET /milestones.json
def index @query_params = {} build_query_params(params) build_query_milestone_params @conditions = [] @conditions << Milestone.arel_table[:name].matches("%#{@query_params[:name]}%") if @query_params[:name] if @conditions.length > 0 conditions = @conditions[0] @conditions.each_with_index do |item, index| conditions = conditions.or(item) if index > 0 end @conditions = conditions end respond_to do |format| format.html { set_milestones_grid(@conditions) } format.json { render json: Milestone.where(@conditions) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def milestones\n process_list_response( send(:get , \"/api/v1/milestones.json\")[:body] , Unfuddled::Milestone)\n end", "def milestones\n Sifter.\n get(api_milestones_url).\n fetch(\"milestones\", []).\n map { |m| Sifter::Milestone.new(m) }\n end", "def milestones\n Sifter...
[ "0.8953888", "0.87799984", "0.87799984", "0.77689886", "0.7767631", "0.77345437", "0.7697864", "0.74830014", "0.73003775", "0.7264003", "0.7244795", "0.7105223", "0.70548993", "0.69542956", "0.6925593", "0.69081163", "0.6863697", "0.6858224", "0.6831006", "0.68283266", "0.682...
0.5870765
52
GET /milestones/1 GET /milestones/1.json
def show @tabs = TABS @current_tab = params[:tab] @current_tab ||= TABS.first.to_s @current_tab = @current_tab.to_sym end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def milestones\n process_list_response( send(:get , \"/api/v1/milestones.json\")[:body] , Unfuddled::Milestone)\n end", "def milestones\n Sifter.\n get(api_milestones_url).\n fetch(\"milestones\", []).\n map { |m| Sifter::Milestone.new(m) }\n end", "def milestones\n Sifter...
[ "0.8470175", "0.80540234", "0.80540234", "0.78466713", "0.7653229", "0.7350533", "0.7342438", "0.7339569", "0.73345834", "0.7163086", "0.6931923", "0.69217247", "0.69071525", "0.6864418", "0.6864418", "0.6864418", "0.685886", "0.6816129", "0.6753839", "0.6740727", "0.66990125...
0.0
-1
POST /milestones POST /milestones.json
def create @milestone = Milestone.new(milestone_params) respond_to do |format| if @milestone.save set_milestones_grid format.html { redirect_to @milestone, notice: t('activerecord.success.messages.created', model: Milestone.model_name.human) } format.js else format.html { render :new } format.js { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @milestone = @project.milestones.build(milestone_params)\n\n respond_to do |format|\n if @milestone.save\n format.html { redirect_to @project,\n notice: 'Milestone was successfully created.' }\n format.json { render :show, status: :created, location: @mile...
[ "0.77556205", "0.7744407", "0.7744407", "0.773434", "0.7550007", "0.72189975", "0.717191", "0.717191", "0.7011282", "0.6871754", "0.6871754", "0.68058", "0.67613375", "0.6740176", "0.6738575", "0.6727557", "0.66582716", "0.66557217", "0.66485554", "0.663058", "0.65278935", ...
0.69193953
9
PATCH/PUT /milestones/1 PATCH/PUT /milestones/1.json
def update respond_to do |format| if @milestone.update(milestone_params) set_milestones_grid format.html { redirect_to @milestone, notice: t('activerecord.success.messages.updated', model: Milestone.model_name.human) } format.js else format.html { render :edit } format.js { render :edit } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @milestone.update(milestone_params)\n format.html { redirect_to @project,\n notice: 'Milestone was successfully updated.' }\n format.json { render :show, status: :ok, location: @milestone }\n else\n format.html { render...
[ "0.7219105", "0.7160296", "0.70967346", "0.67704314", "0.6579752", "0.6573653", "0.6519023", "0.6509904", "0.6474514", "0.6433083", "0.6419906", "0.6401148", "0.63900864", "0.63900864", "0.63900864", "0.6387928", "0.6255867", "0.5982729", "0.5968229", "0.5968229", "0.5938877"...
0.6642068
4
DELETE /milestones/1 DELETE /milestones/1.json
def destroy @milestone.destroy respond_to do |format| set_milestones_grid format.html { redirect_to milestones_url, notice: t('activerecord.success.messages.destroyed', model: Milestone.model_name.human) } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_milestone(id)\n record \"/milestones/delete/#{id}\"\n end", "def delete_milestone(id)\n record \"/milestones/delete/#{id}\"\n end", "def destroy\n @milestone = Milestone.find(params[:id])\n @milestone.destroy\n\n respond_to do |format|\n format.html { redirect_to goals_url }\n ...
[ "0.8247626", "0.8247626", "0.80305856", "0.77580154", "0.7658031", "0.76493794", "0.75572014", "0.73156536", "0.71579605", "0.70234287", "0.68257195", "0.6725004", "0.6552566", "0.65483725", "0.65213645", "0.64805526", "0.6469241", "0.6464999", "0.6464999", "0.6381303", "0.63...
0.7098453
9
Use callbacks to share common setup or constraints between actions.
def set_milestone @milestone = Milestone.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 milestone_params params.require(:milestone).permit( :name, :description, :project_id, :gitlab_id, :is_existing_on_gitlab, ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /work_packages GET /work_packages.json
def index @work_packages = WorkPackage.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @workpackages = Workpackage.all\n end", "def search\n request_params = prepare_search_params\n if request_params[:packages].empty?\n return render json: {\n messeage: 'please provide us with packages to provide you with dependencies',\n },\n status: 200\n...
[ "0.6941309", "0.6542672", "0.65065", "0.6340153", "0.62667143", "0.6228042", "0.61018765", "0.60437053", "0.5977421", "0.58878654", "0.5882257", "0.587973", "0.587973", "0.587973", "0.587973", "0.586858", "0.5856872", "0.58245623", "0.5777104", "0.5749526", "0.57399756", "0...
0.71046615
0
GET /work_packages/1 GET /work_packages/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @work_packages = WorkPackage.all\n end", "def index\n @workpackages = Workpackage.all\n end", "def index\n @imei_packages = ImeiPackage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imei_packages }\n end\n end", "def index\...
[ "0.69764215", "0.68542945", "0.6357129", "0.63565683", "0.62428945", "0.62253845", "0.61936796", "0.61436105", "0.61303914", "0.6115098", "0.60363996", "0.5992109", "0.5942583", "0.5914462", "0.5914462", "0.5914462", "0.5914462", "0.59019417", "0.58908516", "0.5865094", "0.58...
0.0
-1
POST /work_packages POST /work_packages.json
def create @work_package = WorkPackage.new(work_package_params) respond_to do |format| if @work_package.save format.html { redirect_to @work_package, notice: 'Work package was successfully created.' } format.json { render :show, status: :created, location: @work_package } else format.html { render :new } format.json { render json: @work_package.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @package = Package.create(package_params)\n\n render json: @package\n end", "def upload_packages(packages)\n test_payload.set(:packages, packages)\n end", "def work_package_params\n params.require(:work_package).permit(:name, :code, :target_release_date, :actual_release_date, :...
[ "0.62287194", "0.6214725", "0.61898893", "0.61234283", "0.60861236", "0.6077661", "0.604046", "0.60361046", "0.5995479", "0.5994883", "0.59894294", "0.5872085", "0.57523894", "0.5732152", "0.57237864", "0.56794673", "0.5678207", "0.56582165", "0.5647082", "0.5647082", "0.5639...
0.6902761
0
PATCH/PUT /work_packages/1 PATCH/PUT /work_packages/1.json
def update respond_to do |format| if @work_package.update(work_package_params) format.html { redirect_to @work_package, notice: 'Work package was successfully updated.' } format.json { render :show, status: :ok, location: @work_package } else format.html { render :edit } format.json { render json: @work_package.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @workpackage.update(workpackage_params)\n format.html { redirect_to @workpackage, notice: 'Workpackage was successfully updated.' }\n format.json { render :show, status: :ok, location: @workpackage }\n else\n format.html { render :edit }\n ...
[ "0.68443775", "0.66956806", "0.6568633", "0.65577054", "0.6402791", "0.63782513", "0.63372356", "0.6319601", "0.6312043", "0.6303012", "0.62943643", "0.62943643", "0.6290491", "0.6283344", "0.62733775", "0.6258883", "0.6252919", "0.6241532", "0.6149962", "0.6114376", "0.61003...
0.6989703
0
DELETE /work_packages/1 DELETE /work_packages/1.json
def destroy @work_package.destroy respond_to do |format| format.html { redirect_to work_packages_url, notice: 'Work package was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @workpackage.destroy\n respond_to do |format|\n format.html { redirect_to workpackages_url, notice: 'Workpackage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @package.status = nil\n @package.save!\n respond_to do |format...
[ "0.7135017", "0.7070336", "0.67931443", "0.6768601", "0.67151797", "0.67015094", "0.66676486", "0.6656663", "0.6648366", "0.6621619", "0.66083694", "0.6593745", "0.6550797", "0.65484905", "0.6535015", "0.65336853", "0.65336853", "0.6501791", "0.6498213", "0.6490787", "0.64609...
0.7239032
0
Use callbacks to share common setup or constraints between actions.
def set_work_package @work_package = WorkPackage.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def work_package_params params.require(:work_package).permit(:name, :code, :target_release_date, :actual_release_date, :release_gate_id, :market_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
We consider the max size here as just enough to leave room for one more metric of the largest size possible. This is a shortcut that allows us to use a native Ruby `Queue` that doesn't allow peeking. The tradeoff here is that we might fit in less metrics than possible into a batch. The alternative is to use our own `Queue` implementation that allows peeking, and to consider the next metric size when calculating whether the metric can be accomodated in this batch.
def size_exhausted? @size >= (MAX_BYTES - Defaults::Metric::MAX_BYTES) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maximum_queued_data_size\n super\n end", "def set_maximum_queued_data_size(opts)\n opts = check_params(opts,[:sizes])\n super(opts)\n end", "def queue\n @queue ||= SizedQueue.new @queue_size\n end", "def queue_size(queue)\n prioritized?(queue) ? z_queue_size(qu...
[ "0.6249281", "0.62166446", "0.6122428", "0.60860187", "0.606205", "0.60612565", "0.59234047", "0.5897113", "0.587205", "0.58125544", "0.5782061", "0.5778589", "0.576882", "0.5766599", "0.57250804", "0.5722035", "0.57174814", "0.5691875", "0.5641947", "0.56194955", "0.5615526"...
0.58560705
9
GET /admin/settings/administrators GET /admin/settings/administrators.json
def index @administrators = @administrators_active @administrators_count = @administrators.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @admin_administrators = Admin::Administrator.page(params[:page])\n end", "def get_project_administrators(pro...
[ "0.74805427", "0.74805427", "0.74805427", "0.7083171", "0.6964955", "0.68697417", "0.67350686", "0.6713641", "0.6697658", "0.668888", "0.66510576", "0.6584749", "0.6533029", "0.6517003", "0.6517003", "0.6517003", "0.6517003", "0.6517003", "0.6517003", "0.6507078", "0.6494066"...
0.7096502
3
GET /admin/settings/administrators/1 GET /admin/settings/administrators/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = @administrators_active\n @administrators_count = @administrators.size\n end", "def get_...
[ "0.7235944", "0.7235944", "0.7235944", "0.6881596", "0.68115485", "0.6748862", "0.65998214", "0.64424926", "0.6426496", "0.64081013", "0.64081013", "0.64014906", "0.6363366", "0.6362465", "0.63442427", "0.62438464", "0.6239319", "0.6228264", "0.62197316", "0.6217154", "0.6187...
0.0
-1
POST /admin/settings/administrators POST /admin/settings/administrators.json
def create @administrator.inviter = current_administrator respond_to do |format| if @administrator.save format.html { redirect_to %i[admin settings root], notice: t('.success') } format.json { render :show, status: :created, location: @administrator } else format.html { render :new } format.json { render json: @administrator.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = Administrator.all\n end", "def index\n @administrators = @administrators_active\n @administrators_count = @administrators.size\n end", "def crea...
[ "0.6773768", "0.6773768", "0.6773768", "0.65305805", "0.6409909", "0.6397603", "0.6143635", "0.610416", "0.60664326", "0.60488206", "0.60092664", "0.6009247", "0.5981911", "0.59804696", "0.5972902", "0.5955584", "0.5952398", "0.592023", "0.5882176", "0.58265865", "0.58222437"...
0.61825776
6
PATCH/PUT /admin/settings/administrators/1 PATCH/PUT /admin/settings/administrators/1.json
def update respond_to do |format| if @administrator.update(administrator_params) format.html { redirect_to %i[admin settings root], notice: t('.success') } format.json { render :show, status: :ok, location: @administrator } else format.html { render :edit } format.json { render json: @administrator.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_admin\n update admin_client\n end", "def update\n respond_to do |format|\n if @adminstrator.update(adminstrator_params)\n format.html { redirect_to adminstrators_url, notice: 'Administrator #{adminstrator.name} was successfully updated.' }\n format.json { render :show...
[ "0.6963431", "0.6442149", "0.64379805", "0.6340148", "0.6332723", "0.62423325", "0.6232906", "0.6213557", "0.61851025", "0.6184727", "0.6174744", "0.6173596", "0.61704475", "0.6167417", "0.61298794", "0.611935", "0.6109138", "0.6106608", "0.6098768", "0.6090976", "0.6090976",...
0.63042647
5
POST /admin/settings/administrators/1/deactivate POST /admin/settings/administrators/1/deactivate.json
def deactivate @administrator.deactivate respond_to do |format| format.html { redirect_to %i[admin settings root], notice: t('.success') } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deactivate\n admin = Administrator.find_by_user_id(params[:id])\n admin.status = false\n admin.save\n @users = User.all\n render 'index'\n end", "def deactivate\n verify_post_request\n require_parameters :login\n\n Api.users.deactivate(params[:login])\n\n hash={}\n re...
[ "0.69145244", "0.6763341", "0.66272485", "0.65687096", "0.65687096", "0.6561953", "0.6524926", "0.64215547", "0.64099467", "0.6365327", "0.631776", "0.6303133", "0.62894124", "0.6265659", "0.62330854", "0.6231841", "0.61217356", "0.6100453", "0.6089182", "0.607351", "0.602590...
0.7794959
0
POST /admin/settings/administrators/1/reactivate POST /admin/settings/administrators/1/reactivate.json
def reactivate @administrator.reactivate respond_to do |format| format.html { redirect_to %i[admin settings root], notice: t('.success') } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin_reactivate\n user = User.find(params[:id])\n authorize! :edit, @user #prevent other users from disabling OTP on another user.\n user.deactivated = false\n user.save!\n flash[:notice] = \"Successfully Reactivated user.\"\n redirect_back(fallback_location: '/')\n end", "def reactivate(...
[ "0.7329737", "0.65727955", "0.6567745", "0.6449345", "0.6449345", "0.64226526", "0.6311828", "0.62371266", "0.6216966", "0.6085419", "0.6049639", "0.604923", "0.59419364", "0.57976013", "0.57674724", "0.5756072", "0.5754018", "0.57458055", "0.57458055", "0.57458055", "0.57458...
0.80057216
0
PATCH/PUT /admin/settings/administrators/1/resend_confirmation_instructions PATCH/PUT /admin/settings/administrators/1/resend_confirmation_instructions.json
def resend_confirmation_instructions respond_to do |format| @administrator.send_confirmation_instructions format.html { redirect_to %i[admin settings root], notice: t('.success') } format.json do render :resend_confirmation_instructions, status: :ok, location: @administrator end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resend_confirmation_instructions; end", "def resend_confirmation_instructions\n pending_any_confirmation do\n send_confirmation_instructions\n end\n end", "def send_reconfirmation_instructions\n end", "def resend_confirmation_instruction!\n self.confirmed_at = nil\n ...
[ "0.7099448", "0.6960477", "0.68655545", "0.68103915", "0.6779737", "0.6638233", "0.65677965", "0.63996446", "0.632692", "0.6253309", "0.6223015", "0.6195038", "0.6185369", "0.61625516", "0.6092888", "0.60904473", "0.60697937", "0.60658604", "0.60459954", "0.60129637", "0.6009...
0.7994699
0
Never trust parameters from the scary internet, only allow the white list through.
def administrator_params params.require(:administrator).permit(permitted_fields) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Phase 2 Time Complexity: O(n)
def second_anagram?(str1, str2) arr1 = str1.split("") arr2 = str2.split("") arr1.each do |char| index = arr2.index(char) return false if index.nil? arr2.delete_at(index) end arr2.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two\n first = 1\n second = 2\n third = 0\n acc = second #initialized to first even term\n begin\n third = first + second\n if third > 4000000\n break\n end\n puts third\n if third%2 == 0\n acc+=third\n end\n first = second\n second = third\n end while true\n acc\nend", ...
[ "0.6257112", "0.6232388", "0.6156652", "0.61215365", "0.6108328", "0.60845214", "0.6083681", "0.60562", "0.6030865", "0.6030161", "0.6029027", "0.6020144", "0.6016798", "0.6016576", "0.60005224", "0.59919375", "0.5985322", "0.59851867", "0.5960613", "0.59582794", "0.5950033",...
0.0
-1
Phase 3 Time Complexity: O(1)
def third_anagram?(str1, str2) str1.split("").sort == str2.split("").sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def three_sum(nums)\n n = nums.length\n result =...
[ "0.6819859", "0.665879", "0.6475547", "0.6360718", "0.63157874", "0.6304463", "0.62071896", "0.61505127", "0.61023146", "0.60559654", "0.5982682", "0.59487647", "0.59413296", "0.5925705", "0.59253114", "0.59100646", "0.5848274", "0.5838559", "0.5826031", "0.58072525", "0.5792...
0.0
-1
Phase 4 Time Complexity: O(n)
def fourth_anagram?(str1, str2) helper(str1) == helper(str2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def four_sum(arr, target)\n arr = arr.sort\n size = arr.size\n...
[ "0.6511681", "0.6402463", "0.63196546", "0.6240216", "0.61900073", "0.60784423", "0.60690975", "0.60501784", "0.60402894", "0.6030159", "0.60023713", "0.59986794", "0.5992503", "0.59165335", "0.59136117", "0.59109885", "0.590876", "0.58997893", "0.58789456", "0.5877405", "0.5...
0.0
-1
After the Mutation service object initilized add additional attribute execution_chain to work with rollback fuctionality. The execution_chain attribute populates with an array of successfully completed services that could be used for initiate rollback each of them. This logic developed for operations which doesn't have transactions as in Relational DB's. In our case it's used for rollback the chain of calls to external system.
def initialize *_args super @service_logger = case logger when 'sidekiq' Sidekiq::Logging.logger else Rails.logger end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_rollback(&block)\n existing_rollback = task_call_frames.last.rollback\n task_call_frames.last.rollback = lambda { block.call ; existing_rollback.call }\n end", "def set_executed_command_chain\n #return the executed commmands up our call stack\n callchain.each do |c|\n ...
[ "0.5656756", "0.55873233", "0.53990096", "0.52495605", "0.52456087", "0.52456087", "0.52456087", "0.52456087", "0.52456087", "0.5217681", "0.5217681", "0.5212229", "0.5205774", "0.51961845", "0.5170439", "0.5121152", "0.5120694", "0.51156366", "0.50988024", "0.50794065", "0.5...
0.0
-1
Helper methods for colored mutation services logs with specific headers
def service_log status: :processed, message: colors_list = { failure: :red, success: :green, info: :cyan, warning: :yellow } log_header = ActiveSupport::LogSubscriber.new.send(:color, "[SERVICE #{status.to_s.upcase}]", colors_list[status]) service_logger.warn "#{log_header} #{message}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def colorize_logging; end", "def colored\n\n bold = \"\\x1b[1m\"\n color = \"\\x1b[34m\"\n reset = \"\\x1b[0m\"\n\n pattern = []\n pattern << \"#{bold}#{color}[AWS\"\n pattern << \":service\"\n pattern << \":http_response_status\"\n pattern ...
[ "0.66215354", "0.6443038", "0.6347082", "0.6179734", "0.61417717", "0.6024676", "0.60080683", "0.5924151", "0.59017515", "0.5783973", "0.5778351", "0.57722485", "0.576263", "0.5737295", "0.5729081", "0.57049453", "0.5698821", "0.5676818", "0.5653869", "0.5631962", "0.56293356...
0.6279096
3
The service_backtrace used for printing first 20 rows of error backtrace. This backtrace shows what happen if error occures, but service will be completed and doesn't crash.
def service_backtrace exception service_logger.error exception.backtrace.first(20).map { |row| row.prepend("\t") }.join("\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_backtrace; end", "def backtrace\n Spec::deprecate(\"ExampleGroupProxy#backtrace\",\"ExampleGroupProxy#location\")\n @backtrace\n end", "def backtrace\n @process_error.h['trace'].split(/\\n/)\n end", "def full_backtrace=(_arg0); end", "def backtrace; end", "def back...
[ "0.7060403", "0.67074394", "0.66042143", "0.6600954", "0.65787214", "0.6574482", "0.6525877", "0.6448566", "0.63309324", "0.63161975", "0.63109785", "0.628733", "0.6277836", "0.6217464", "0.6162976", "0.61127836", "0.60272", "0.6020623", "0.60202", "0.5989852", "0.5960987", ...
0.83768326
0
another method that solves the same problem recursively:
def fibs_rec(n, fib_array=[0,1]) return [0] if n == 1 return fib_array if fib_array.length == n fib_array << fib_array[-1] + fib_array[-2] fibs_rec(n, fib_array) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursive_solution\n\n end", "def recursive => nil", "def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t...
[ "0.81387126", "0.7375381", "0.6398132", "0.63517714", "0.6272942", "0.6250436", "0.61950517", "0.6178718", "0.61520916", "0.6148234", "0.6145824", "0.61231995", "0.6115137", "0.60530233", "0.6020639", "0.59869903", "0.5950025", "0.59403604", "0.5933993", "0.59170556", "0.5913...
0.0
-1
Runs the content through [HTML::Pipline]( Takes a `:pipeline` option as well as any additional context options.
def run(content, params={}) # Get options options = {:pipeline => []}.merge(params) filters = options.delete(:pipeline).map do |f| if self.class.is_filter(f) f else key = self.class.filter_key(f) filter = HTML::Pipeline.constants.find { |c| c.downcase == key } # possibly a custom filter if filter.nil? Nanoc.const_get(f) else HTML::Pipeline.const_get(filter) end end end HTML::Pipeline.new(filters, options).to_html(content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_pipe\n @html = RDoc::Markup::ToHtml.new @options\n\n parser = RDoc::Text::MARKUP_FORMAT[@options.markup]\n\n document = parser.parse $stdin.read\n\n out = @html.convert document\n\n $stdout.write out\n end", "def call\n # mode = (context[:gfm] != false) ? :gfm : :markdown\n ...
[ "0.58315176", "0.55462366", "0.54008114", "0.5360826", "0.52495533", "0.5187018", "0.51539683", "0.50975823", "0.50672984", "0.505009", "0.5034325", "0.5028221", "0.5026435", "0.499514", "0.49940765", "0.4973061", "0.49595392", "0.49524269", "0.49464312", "0.4929494", "0.4869...
0.5812649
1
enum role: [ :admin, :vendor_admin, :vendor_user1, :vendor_user2, :vendor_user3 ] def password_required? super if confirmed? end
def receive_emails_pop self.config_emails.each do |config_email| case (config_email.server_email) when 'pop.gmail.com' Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) else "" end Net::POP3.start(config_email.server_email, config_email.port, config_email.username, ConfigEmail.decryption(config_email.password_encrypted)) do |pop| if pop.mails.empty? puts 'No mails.' else pop.each_mail do |mail| UserMailer.current_vendor_config_email(config_email) UserMailer.receive(mail.pop) mail.delete end pop.finish end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password_required?\n super if confirmed?\n end", "def password_required?\n super if confirmed?\n end", "def password_required?\n super if confirmed?\n end", "def password_required?\n super if confirmed?\n end", "def password_required?\n super if confirmed?\n end", "def...
[ "0.7587783", "0.7587783", "0.7587783", "0.7586986", "0.7586986", "0.7586986", "0.7586986", "0.7586986", "0.7586986", "0.7572577", "0.7557866", "0.74767166", "0.74449927", "0.71883756", "0.69481343", "0.6894244", "0.68710566", "0.68543583", "0.6816331", "0.68024284", "0.680183...
0.0
-1
Writes and returns channel using rabbit mq adapter, only one per thread
def set_up_channel amqp_conn = Bunny.new amqp_conn.start channel = amqp_conn.create_channel end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def channel\n\n Thread.current['_boss_amqp_channel'] ||= amqp_connect.create_channel\n end", "def publish_channel\n @publish_channel ||= ::AMQP::Channel.new(connection)\n end", "def create_channel\n AMQP::Channel.new(@amqp_client)\n end", "def push_to_amqp\n\n AMQP.start(APP_CONFIG...
[ "0.73412085", "0.70836294", "0.68006855", "0.65371335", "0.6458237", "0.63374096", "0.629586", "0.6290396", "0.6256613", "0.621752", "0.621752", "0.6170459", "0.6163856", "0.6108814", "0.60711145", "0.60465854", "0.60258484", "0.59683794", "0.5943968", "0.5933747", "0.5933747...
0.63719344
5
take input from exchange and bind to new output queue, given names
def bind_exchange_to_queue(channel, exchange_in_name, queue_name) exchange_source = channel.fanout(exchange_in_name) queue_output = channel.queue(queue_name) queue_output.bind(exchange_source) return queue_output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bind_exchange_to_exchange(channel, exchange_in_name, queue_name, exchange_out_name)\n exchange_source = channel.fanout(exchange_in_name)\n queue_current = channel.queue(queue_name)\n queue_current.bind(exchange_source)\n exchange_output = channel.fanout(exchange_out_name)\n return queue_current, exchange_...
[ "0.7192201", "0.6284884", "0.6249239", "0.5860504", "0.5840899", "0.57250166", "0.5656589", "0.5618754", "0.55825126", "0.55345726", "0.5509621", "0.54475856", "0.54234564", "0.54231006", "0.53656083", "0.5289029", "0.5284582", "0.5270912", "0.52686554", "0.52610326", "0.5236...
0.7096879
1
take input from exchange and bind to new output exchange, given names return current queue, output exchange
def bind_exchange_to_exchange(channel, exchange_in_name, queue_name, exchange_out_name) exchange_source = channel.fanout(exchange_in_name) queue_current = channel.queue(queue_name) queue_current.bind(exchange_source) exchange_output = channel.fanout(exchange_out_name) return queue_current, exchange_output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bind_exchange_to_queue(channel, exchange_in_name, queue_name)\n exchange_source = channel.fanout(exchange_in_name)\n queue_output = channel.queue(queue_name) \n queue_output.bind(exchange_source)\n return queue_output\nend", "def bind_queue_to_exchange\n queue.bind(exchange)\n end", "def bi...
[ "0.7342924", "0.63037765", "0.5949117", "0.5823705", "0.5787928", "0.57558864", "0.57338554", "0.5705814", "0.5656514", "0.56459343", "0.56221664", "0.5570653", "0.5555181", "0.5550495", "0.5506798", "0.5476174", "0.5457657", "0.54527754", "0.54268986", "0.5423247", "0.541827...
0.75473565
0
loop through queue, compute result of input via function, and output to exchange
def deploy_function_to_exchange(queue_current, exchange_out, user_func = function) queue_current.subscribe(block: true, manual_ack: false) do |delivery_info, metadata, payload| input = payload result = user_func.call(input) exchange_out.publish(payload, reply_to: metadata[:reply_to], correlation_id: metadata[:correlation_id]) puts "#{input} became #{output}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queue(_); end", "def queue(_); end", "def do_work\n until @worker_input_queue.empty?\n @output_queue << yield(@worker_input_queue.pop)\n end\n end", "def queue; end", "def queue; end", "def b_f_s(queue)\n queue.shift\n end", "def processMessage\n\n loop do...
[ "0.6760612", "0.6760612", "0.67561686", "0.6556926", "0.6556926", "0.64046013", "0.61760485", "0.6139552", "0.6129376", "0.6103421", "0.60515076", "0.59920895", "0.59871536", "0.597226", "0.59600264", "0.59191924", "0.59188676", "0.5915236", "0.59043765", "0.58820987", "0.583...
0.6643077
3
insert the current node after the specified node. Update all references
def insert_after(pr) unless pr.next.nil? nx = pr.next set_next(nx) nx.set_prev(self) end set_prev(pr) pr.set_next(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insertAfter(node, new_node)\n end", "def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n node = find node\n node_after = node.next\n node_inserted = Node.new value\n node.next = node_inserted...
[ "0.7908245", "0.774397", "0.76457626", "0.7613146", "0.7568108", "0.75499094", "0.74804777", "0.7460144", "0.7333225", "0.72159326", "0.7211909", "0.706774", "0.7040283", "0.70007", "0.69979155", "0.69239944", "0.6896983", "0.6840696", "0.68011886", "0.6791633", "0.6749661", ...
0.6854356
17
Returns the correctly formatted way of describing how a batsman was out: Used in displaying the scorecards:
def outDescription begin if (self.howout_before_type_cast == 0 || self.howout_before_type_cast == 1 || self.howout_before_type_cast > 7) then #description is enough, as these ways of getting out do # not relate to any fielders. howout elsif (self.howout_before_type_cast == 2) then #bowled out "b #{self.bowler.name}" elsif (self.howout_before_type_cast == 3) then if (self.bowler.name != self.fielder.name) then #caught by a different fielder to the bowler "c #{self.fielder.name} b #{self.bowler.name}" else #caught and bowled both by the bowler "c & b #{self.bowler.name}" end elsif (self.howout_before_type_cast == 4) then "lbw b #{self.bowler.name}" elsif (self.howout_before_type_cast == 5) then "run out (#{self.fielder.name})" else "stumped #{self.fielder}" end rescue NoMethodError #Something went wrong - perhaps the user entered an invalid #combination, such as Caught, but left the bowler field blank "ERROR - PLEASE EDIT THIS INNINGS AND CORRECT IT" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s()\r\n\t\tres = \"Printing Statistic -#{self.object_id}-\\n\\t\"\r\n\t\tres += \" - Time : #{@time}\\n\\t\"\r\n\t\tres += \" - Penalty : #{@penalty}\\n\\t\"\r\n\t\tres += \" - isFinished : #{@isFinished}\\n\\t\"\r\n\t\tres += \" - Used help : #{@usedHelp}\\n\\t\"\r\n\t\tres += \" - Nb Stars : ...
[ "0.6762591", "0.67080784", "0.66433436", "0.65389395", "0.64943826", "0.64773643", "0.6425354", "0.6414597", "0.6397676", "0.63851905", "0.6357476", "0.6354567", "0.63506436", "0.63432914", "0.63208836", "0.63100505", "0.62937176", "0.62919694", "0.6241702", "0.62383133", "0....
0.6145126
28
PUT /authentications/1 PUT /authentications/1.xml
def put @authentication = Authentication.find(params[:id]) respond_to do |format| if @authentication.update_attributes(params[:authentication]) flash[:notice] = 'Authentication was successfully updated.' format.html { redirect_to(@authentication) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @authentication.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user...
[ "0.58538514", "0.57461745", "0.5729117", "0.56564534", "0.54559034", "0.54064345", "0.5370258", "0.53227305", "0.52938575", "0.5291079", "0.5252821", "0.5247945", "0.5232201", "0.52026814", "0.5197311", "0.5174347", "0.515969", "0.5158898", "0.5158898", "0.51403683", "0.51314...
0.5794676
1
== Instance Methods =====================================================
def user?(user) self.user_id == user.id if user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def initialize\n\t\t\n\tend", "def initialize\n \n end", "def initialize\n\n end", "def initialize\n\n end", "def initialize\r\n\r\n end", "def implementation; end", "def implementation; end", "def initialize\n end", "def initialize\n end", "def initialize\n ...
[ "0.84468544", "0.73226625", "0.7320286", "0.72967416", "0.72967416", "0.72934955", "0.72732323", "0.72732323", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7161583", "0.71429914", "0.71429...
0.0
-1