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
Create a perpendicular line segment from `point` to this line. The enpoints of the segment are `point` and the closest point in the line containing self. (If self is not a line, the point might not be in self.) Parameters: Point Returns: Segment or Point (if `point` is on this linear entity.)
def perpendicular_segment(point) point = Point.new(point[0], point[1]) if point.is_a?(Array) raise TypeError, 'Must pass only Point.' unless point.is_a?(Point) return point if self.contains?(point) l = self.perpendicular_line(point) p = Line.new(self.p1, self.p2).intersection(l).first Segment.new(point, p) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perpendicular_line(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n # any two lines in R^2 intersect, so blindly making\n # a line through p in an orthogonal direction will work\n Lin...
[ "0.8225504", "0.70821", "0.6511311", "0.626477", "0.62504977", "0.6168844", "0.61308825", "0.61068237", "0.60236984", "0.58613586", "0.5728332", "0.5645939", "0.5632888", "0.5596281", "0.5571096", "0.55376583", "0.5500705", "0.5459499", "0.5388227", "0.53776985", "0.53738713"...
0.86312026
0
The slope of this linear entity, or infinity if vertical. Returns: number or BigDecimal('Infinity')
def slope return @slope if defined?(@slope) dx = p1.x - p2.x dy = p1.y - p2.y if dy == 0 @slope = 0.0 elsif dx == 0 @slope = BigDecimal('Infinity') else @slope = dy / dx end @slope end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slope\n # we use memoization because calculating slope is expensive\n @slope ||= begin\n self.points.first.elems['ele'] - self.points.last.elems['ele']\n end\n end", "def right_slope\n if has_2012_tangents?\n dy = @value - @r_handle_y\n dx = @frame.to_f - @r_handle_x\n ...
[ "0.75769997", "0.69925845", "0.698149", "0.6925771", "0.65343696", "0.64142746", "0.61896574", "0.61753774", "0.6095524", "0.59483725", "0.5763084", "0.5751628", "0.5697652", "0.56845546", "0.56197655", "0.54453593", "0.5435432", "0.5424317", "0.5417772", "0.54037917", "0.537...
0.80134606
0
Test whether the point `other` lies in the positive span of `self`. A point x is 'in front' of a point y if x.dot(y) >= 0. Return 1 if other is behind self.p1 0 if other is self.p1 1 if other is in front of self.p1.
def span_test(other) other = Point.new(other[0], other[1]) if other.is_a?(Array) raise TypeError, 'Must pass only Point.' unless other.is_a?(Point) return 0 if self.p1 == other rel_pos = other - self.p1 return 1 if self.direction.to_point.dot(rel_pos) > 0 return -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def above? point\n dist(point) < 0\n end", "def crossing?(other)\n return false unless overlaps?(other)\n (@begin_pos <=> other.begin_pos) * (@end_pos <=> other.end_pos) == 1\n end", "def <=>(other_point)\n ret = self.x <=> other_point.x\n if ret == 0\n ret = self.y <=> other_...
[ "0.681593", "0.6459353", "0.6266166", "0.618994", "0.61693835", "0.6106745", "0.60814464", "0.6068847", "0.6044864", "0.60306454", "0.59991324", "0.5934906", "0.590183", "0.5874182", "0.58560777", "0.5825618", "0.5808378", "0.58009", "0.57949954", "0.579261", "0.5786244", "...
0.79392326
0
Project a point onto this linear entity. Parameters: Point Returns: Point
def projection_point(p) Point.project(p - p1, self.direction.to_point) + p1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def + (point)\n return Point2D.new(@x + point.x, @y + point.y)\n end", "def translate_to_point(*location)\n p = Point.new(*location)\n Line.new(p, Point.new(p.x + (x2 - x1), p.y + (y2 - y1)))\n end", "def get_real_point\n pos_x = x * get_scale(:x)\n pos_y = y * get_scale(:y)\n return ...
[ "0.6439536", "0.64016724", "0.62671804", "0.62531275", "0.6238202", "0.61554193", "0.6130743", "0.60945505", "0.60884243", "0.604438", "0.6041438", "0.602576", "0.5991536", "0.5950601", "0.59468573", "0.5943269", "0.5938668", "0.5906419", "0.5905031", "0.586535", "0.58483624"...
0.7030148
0
GET /chef_att_sources GET /chef_att_sources.json
def index @chef_att_sources = ChefAttSource.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_sources(source)\n get('account/sources', {'source' => source})\n end", "def set_chef_att_source\n @chef_att_source = ChefAttSource.find(params[:id])\n end", "def get_sources\n response = execute_get(\"/reference/source\")\n Source.from_array(decode(response))\n end", "def s...
[ "0.6506124", "0.6438375", "0.6337487", "0.6308791", "0.5974993", "0.595875", "0.5835252", "0.5693396", "0.5661304", "0.5649156", "0.5632889", "0.5631123", "0.5623438", "0.56028146", "0.5598365", "0.5591332", "0.5591332", "0.5526529", "0.55073154", "0.550322", "0.5498488", "...
0.7680949
0
GET /chef_att_sources/1 GET /chef_att_sources/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chef_att_sources = ChefAttSource.all\n end", "def set_chef_att_source\n @chef_att_source = ChefAttSource.find(params[:id])\n end", "def account_sources(source)\n get('account/sources', {'source' => source})\n end", "def sources(source: nil)\n params = {\n sour...
[ "0.74289924", "0.6581104", "0.61271465", "0.5957288", "0.5909113", "0.58604807", "0.57873416", "0.5728408", "0.5687003", "0.5674954", "0.5673652", "0.56078833", "0.55041754", "0.55041754", "0.54903215", "0.5462092", "0.54240894", "0.54178375", "0.5360022", "0.5320409", "0.531...
0.0
-1
POST /chef_att_sources POST /chef_att_sources.json
def create @chef_att_source = ChefAttSource.new(chef_att_source_params) respond_to do |format| if @chef_att_source.save format.html { redirect_to @chef_att_source, notice: 'Chef att source was successfully created.' } format.json { render :show, status: :created, location: @chef_att_source } else format.html { render :new } format.json { render json: @chef_att_source.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chef_att_sources = ChefAttSource.all\n end", "def set_chef_att_source\n @chef_att_source = ChefAttSource.find(params[:id])\n end", "def chef_att_source_params\n params.require(:chef_att_source).permit(:name, :room_category_id)\n end", "def add_file(filename)\n cookbook_fil...
[ "0.65819055", "0.6498356", "0.6212495", "0.58423376", "0.54849917", "0.54765195", "0.53522545", "0.52926165", "0.5242116", "0.52236", "0.521147", "0.5208082", "0.51942736", "0.516482", "0.515863", "0.5140078", "0.513903", "0.5134314", "0.5129223", "0.5115485", "0.5100279", ...
0.6860682
0
PATCH/PUT /chef_att_sources/1 PATCH/PUT /chef_att_sources/1.json
def update respond_to do |format| if @chef_att_source.update(chef_att_source_params) format.html { redirect_to @chef_att_source, notice: 'Chef att source was successfully updated.' } format.json { render :show, status: :ok, location: @chef_att_source } else format.html { render :edit } format.json { render json: @chef_att_source.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_chef_att_source\n @chef_att_source = ChefAttSource.find(params[:id])\n end", "def update\n @recipesource = Recipesource.find(params[:id])\n\n respond_to do |format|\n if @recipesource.update_attributes(params[:recipesource])\n format.html { redirect_to @recipesource, notice: 'Re...
[ "0.66478497", "0.59565675", "0.5771983", "0.57075083", "0.5705018", "0.5698289", "0.567931", "0.56761926", "0.56760156", "0.5658062", "0.5654592", "0.5654592", "0.56426144", "0.5640946", "0.56387424", "0.56387424", "0.5619299", "0.55983555", "0.55983555", "0.5593054", "0.5591...
0.727514
0
DELETE /chef_att_sources/1 DELETE /chef_att_sources/1.json
def destroy @chef_att_source.destroy respond_to do |format| format.html { redirect_to chef_att_sources_url, notice: 'Chef att source was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @heat_source = HeatSource.find(params[:id])\n @heat_source.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_sources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipesource = Recipesource.find(params[:id])\n @recipesource.de...
[ "0.6341756", "0.627089", "0.6207804", "0.61292887", "0.60908926", "0.6078523", "0.6031223", "0.6011156", "0.5957453", "0.59504426", "0.5938716", "0.59352875", "0.59279627", "0.59265554", "0.5926243", "0.5926243", "0.59166104", "0.5896977", "0.5888554", "0.5863904", "0.5862446...
0.75353223
0
Use callbacks to share common setup or constraints between actions.
def set_chef_att_source @chef_att_source = ChefAttSource.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 chef_att_source_params params.require(:chef_att_source).permit(:name, :room_category_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.69795185", "0.6782116", "0.6745877", "0.6742722", "0.67368543", "0.65932566", "0.65048057", "0.6497429", "0.6481512", "0.6478456", "0.6455591", "0.64391", "0.6379068", "0.6376498", "0.636542", "0.632084", "0.630046", "0.62998945", "0.62943697", "0.6293775", "0.629097", "...
0.0
-1
Returns integer value of current bitmask.
def to_i bitmask end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_i\n bitmask\n end", "def to_i\n @bits.to_i\n end", "def mask_to_i\n @mask_addr\n end", "def to_int\n return @val\n end", "def to_int\n return @val\n end", "def to_i\n\t\tbits.map(&:to_s).join.to_i(2)\n\tend", "def to_i\n return @val\n end", "def to_i\n ...
[ "0.84511834", "0.71516216", "0.65554523", "0.64882827", "0.64882827", "0.64085287", "0.6310285", "0.6310285", "0.62901556", "0.6195812", "0.61603034", "0.61302704", "0.60800195", "0.60652983", "0.60408646", "0.60408646", "0.6039827", "0.5988334", "0.5988334", "0.5988334", "0....
0.85865635
0
Returns an array of names of the currently enabled bits. class MyMask [:read]
def bits self.class.bits.select { |bit, _| include? bit }.keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end", "def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end", "def named_bits(options = {})\n options = {\n include_spacers: false\n }.merge(options)\n result = []\n\n # Shows the bits tha...
[ "0.6921265", "0.6505172", "0.6287696", "0.6284632", "0.6250429", "0.61612254", "0.6158887", "0.6129486", "0.61179715", "0.61078817", "0.6052681", "0.5987099", "0.5987099", "0.59568655", "0.5909259", "0.5851453", "0.5780129", "0.574534", "0.57068926", "0.56569093", "0.564366",...
0.68051666
1
Delegates to bits. class MyMask :read => :execute end mask.each =>
def each(&block) bits.each(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run!\n program.each do |instruction|\n next if instruction.chomp.strip.length.zero?\n\n if /^mask/.match?(instruction)\n mask.change instruction[7..]\n else\n parts = instruction.split(' = ')\n slot = parts.first.match(/\\d+/)[0]\n input_value = parts.last.to_i\n ...
[ "0.6998956", "0.6768436", "0.656682", "0.6181179", "0.6178114", "0.6014478", "0.5914053", "0.5842414", "0.57169676", "0.5679284", "0.5667941", "0.56651735", "0.56553376", "0.55605817", "0.5554633", "0.5554633", "0.54556286", "0.5441561", "0.54255533", "0.54192775", "0.5403388...
0.5902275
7
Returns +true+ if +other+ is an instance of the same class as +self+ and they have the same bitmask. class MyMask true a == c => false a == d => false
def ==(other) other.class == self.class && other.bitmask == bitmask end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n other.class == self.class && other.bitmask == bitmask\n end", "def ==(other)\n return false unless other.instance_of?(self.class)\n clxn == other.send(:clxn)\n end", "def ==(other)\n @bits == other.bits\n end", "def ===(other)\n other.is_a?(self)\n end...
[ "0.80837274", "0.67553264", "0.66499794", "0.6546436", "0.651546", "0.6490508", "0.6477033", "0.64768165", "0.64720607", "0.6467991", "0.6459234", "0.6459234", "0.6431611", "0.6428217", "0.64193135", "0.64174676", "0.64174676", "0.64174676", "0.64174676", "0.6406978", "0.6404...
0.8122797
0
Returns +true+ if bitmask is zero (no bits are enabled) and +false+ otherwise.
def empty? bitmask.zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty_bits?(_options = {})\n empty_bits.size > 0\n end", "def flagged?\n !(%w(flagged) & flags).empty?\n end", "def flagged?\n !(%w(flagged) & flags).empty?\n end", "def flags?\n !@flags.empty?\n end", "def is_valid?\n bit_set?(VALID_FLAG_BIT)\n end", "def ...
[ "0.61389315", "0.59964526", "0.59418875", "0.58812106", "0.5785461", "0.5752115", "0.5599859", "0.5546408", "0.55455923", "0.54748714", "0.5451395", "0.54233885", "0.5411666", "0.5371152", "0.5303733", "0.5303733", "0.5277769", "0.52524865", "0.5250246", "0.5244086", "0.52294...
0.7032167
0
Returns an object hash. Two Banditry::BanditMask objects have identical hashes if they have identical bitmasks and are instances of the same class.
def hash [bitmask, self.class].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [bitmask, self.class].hash\n end", "def maskhash\n return @maskhash\n end", "def hash\n to_h.hash ^ self.class.hash\n end", "def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end", "def hash\n type.hash ^ (id.hash >> 1)\n ...
[ "0.74264044", "0.6658333", "0.65627694", "0.6507684", "0.63185024", "0.62113327", "0.60361296", "0.60361296", "0.60361296", "0.60329926", "0.6003991", "0.59624827", "0.59439194", "0.5884272", "0.5838371", "0.5820363", "0.5809059", "0.57772106", "0.57651114", "0.57565534", "0....
0.75164384
0
constructeur de la classe joueur
def initialize( plateau_de_jeu , name) @plateau= plateau_de_jeu @pion = @@numero_pion @nom = name @@numero_pion += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constructor; end", "def initialize\n \n end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize\n\t\t\n\tend", "def construct\n end", "def initialize() end", "def initialize(name)\n @name ...
[ "0.7551723", "0.7193006", "0.7116875", "0.7116875", "0.7116875", "0.7116875", "0.7116875", "0.7089591", "0.70873606", "0.705179", "0.70379794", "0.70341575", "0.69960225", "0.69782364", "0.69782364", "0.69782364", "0.69782364", "0.69782364", "0.69782364", "0.69782364", "0.697...
0.0
-1
methode qui permet de garder la main tant qu'on a pas jouer un coup valide
def joue coup_valide = false until coup_valide do puts "#{nom}, entrez le numero de la colonne: " colonne = gets puts "#{nom} entrez le numero de ligne : " ligne = gets coup_valide = plateau.place(ligne.to_i ,colonne.to_i ,pion) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ajouterCoup(coup)\n if(coup.couleur != coup.case.couleur && coup.couleur < Couleur::ILE_1)\n coup.case.couleur = coup.couleur\n @grilleRaz = nil\n tabCoup.pop(tabCoup.size - @indiceCoup) #supprimer les coups annulés\n tabCoup.push(coup)\n @indiceCoup += 1\n\n socket = Fenetre1...
[ "0.6547619", "0.63347566", "0.6188776", "0.6133246", "0.61261255", "0.6059315", "0.59905446", "0.59635025", "0.59566694", "0.59284204", "0.5907775", "0.590076", "0.5897033", "0.58860487", "0.5859696", "0.58426404", "0.5842143", "0.5839154", "0.58135915", "0.58097506", "0.5809...
0.0
-1
For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
def abundance beginning = Time.now # stores all abundant number abundance_array = [] # stores all combinations of two abundant number sums abundance_sum_array = [] # stores all integers that cannot be calculated by sum of two abundant numbers non_abundance_array = [] # loop to find all abundant numbers and push into an array x = 1 while x <= 28123 y = 1 total = 0 while y < x if x%y == 0 total = total + y end y+=1 end if total > x abundance_array << x end x+=1 end p abundance_array.count # loop to find all abudant number sums number = 0 while number < abundance_array.count abundance_array.each do |x| sum = abundance_array[number] + x if abundance_array[number] != x abundance_sum_array << sum end end number+=1 end puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" puts 6965*6964 p abundance_sum_array.count # loop to find all numbers that cannot be found by adding 2 abundant numbers together x = 1 while x <= 28123 if !abundance_sum_array.include?(x) non_abundance_array << x end p x x+=1 end puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" p non_abundance_array.count final_total = 0 non_abundance_array.each do |x| total = total + x end puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" puts "The answer is: #{final_total}!" puts "This algorithm took #{Time.now-beginning} seconds to run" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def non_abundant_sums\n\t# get set of all sums of two abundant numbers\n\tabundant_sums = sums_of_two_abundants(MAX_VAL)\n\n\t# get sum of all numbers less than 28123 which are not a part of the abundant_sums set\n\tsum = 0\n\t(1..MAX_VAL).each{|num| sum += num unless abundant_sums.include?(num)}\n\n\tsum\nend", ...
[ "0.7790364", "0.76508576", "0.75090307", "0.75046164", "0.72679365", "0.71816087", "0.71672827", "0.70504206", "0.7038505", "0.7032592", "0.70247054", "0.70185566", "0.6998266", "0.69437546", "0.6942836", "0.69386923", "0.6905795", "0.6864631", "0.6863755", "0.6851097", "0.68...
0.65945965
32
GET /cars GET /cars.json
def index @cars = Car.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n authenticate_request!\n @cars = Car.all\n\n render json: @cars\n end", "def index\n @cars = Car.all\n\n render json: @cars\n end", "def index\n @cars = Car.all\n render json: @cars\n end", "def show\n authenticate_request!\n @car = Car.find(params[:id])\n...
[ "0.7958042", "0.7839653", "0.78389496", "0.75662494", "0.753759", "0.7269738", "0.72300875", "0.72300875", "0.72300875", "0.7156649", "0.69790447", "0.68863994", "0.6866144", "0.6850225", "0.6744585", "0.6734136", "0.66734433", "0.66706383", "0.66492844", "0.6522584", "0.6516...
0.67286855
20
GET /cars/1 GET /cars/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n authenticate_request!\n @car = Car.find(params[:id])\n render json: @car, status: 200\n end", "def index\n @cars = Car.all\n render json: @cars\n end", "def index\n @cars = Car.all\n\n render json: @cars\n end", "def show\n @car = Car.find(params[:id])\n\n res...
[ "0.77659756", "0.74941665", "0.7493949", "0.7470757", "0.7470757", "0.7470757", "0.7360313", "0.72520113", "0.71085286", "0.6946964", "0.69304955", "0.68701386", "0.6847627", "0.68135357", "0.67481256", "0.67481256", "0.6693237", "0.6639097", "0.66024715", "0.65971017", "0.65...
0.0
-1
POST /cars POST /cars.json
def create @car = Car.new(car_params) respond_to do |format| if @car.save format.html { redirect_to @car, notice: 'Car was successfully created.' } format.json { render :show, status: :created, location: @car } else format.html { render :new } format.json { render json: @car.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @car = Car.new(car_params)\n\n if @car.save\n render json: @car, status: :created, location: @car\n else\n render json: @car.errors, status: :bad_request\n end\n end", "def create\n @car = Car.new(car_params)\n respond_to do |format|\n if @car.save\n format.h...
[ "0.7438622", "0.7039278", "0.6978814", "0.6967631", "0.6955018", "0.6872519", "0.6872519", "0.6848824", "0.6736324", "0.6614085", "0.65081686", "0.63757163", "0.6372225", "0.63404775", "0.6339959", "0.6316645", "0.6284865", "0.62827843", "0.62768644", "0.6269303", "0.626063",...
0.69471365
11
PATCH/PUT /cars/1 PATCH/PUT /cars/1.json
def update respond_to do |format| if @car.update(car_params) format.html { redirect_to @car, notice: 'Car was successfully updated.' } format.json { render :show, status: :ok, location: @car } else format.html { render :edit } format.json { render json: @car.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n authenticate_request!\n\n @car = Car.find(params[:id])\n\n if @car.update(car_params)\n head :no_content\n else\n render json: @car.errors, status: :unprocessable_entity\n end\n end", "def update\n @car = Car.find(params[:id])\n\n if @car.update(car_pa...
[ "0.69883025", "0.6984634", "0.6730562", "0.6730562", "0.6656014", "0.6656014", "0.65831816", "0.6583065", "0.65779346", "0.6560947", "0.64915466", "0.6443269", "0.6409683", "0.6404342", "0.64001614", "0.6336937", "0.63240767", "0.63090634", "0.62988937", "0.6265211", "0.62249...
0.6513039
20
DELETE /cars/1 DELETE /cars/1.json
def destroy @car.destroy respond_to do |format| format.html { redirect_to cars_url, notice: 'Car was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @car = Car.find(params[:id])\n @car.destroy\n\n respond_to do |format|\n format.html { redirect_to cars_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @car = Car.find(params[:id])\n @car.destroy\n\n respond_to do |format|\n format.html { r...
[ "0.74194175", "0.74194175", "0.73847145", "0.73847145", "0.7329563", "0.7259847", "0.7257618", "0.7182242", "0.7152065", "0.71452343", "0.7139545", "0.70987505", "0.7031223", "0.70244026", "0.7015542", "0.6954804", "0.69474345", "0.6943497", "0.69072837", "0.686885", "0.68685...
0.7144551
22
Use callbacks to share common setup or constraints between actions.
def set_car @car = Car.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 car_params params.require(:car).permit(:name, :year, :image, :price) 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.69795185", "0.6782116", "0.6745877", "0.6742722", "0.67368543", "0.65932566", "0.65048057", "0.6497429", "0.6481512", "0.6478456", "0.6455591", "0.64391", "0.6379068", "0.6376498", "0.636542", "0.632084", "0.630046", "0.62998945", "0.62943697", "0.6293775", "0.629097", "...
0.0
-1
end initialize run items object
def run getPage getLocations printLocations end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(*args)\n super\n self.items ||= []\n end", "def initialize\r\n self.items = []\r\n end", "def initialize\n @items = []\n end", "def initialize\n @items = []\n end", "def initialize array_of_items\n\tend", "def initialize()\n @items = nil\n ...
[ "0.73654115", "0.735205", "0.7349762", "0.7315158", "0.728646", "0.72459894", "0.7217574", "0.713021", "0.700905", "0.69271463", "0.68644094", "0.6726995", "0.6722405", "0.6660407", "0.66098493", "0.6569327", "0.65690774", "0.65615183", "0.6550144", "0.65460914", "0.6492191",...
0.0
-1
end run get page as Nokogiri object
def getPage # get specific page from last argument page = @arguments[@arguments.length - 1] # get url for specific page url = "http://oldschoolrunescape.wikia.com/wiki/#{page}" # prints url for debugging # puts(url) # request page @page = HTTParty.get(url) # check to see if this was a valid request if @page.include? "This page does not exist. Mayhaps it should?" # if not valid request, abort abort("Incorrect input. Make sure you spelling is correct. The syntax is:\n\n\tOSQuery -m This_monster\n\nThe first letter of the item must be capitalized with the rest of the letters lowercase, and there must be an underscore between each word with no spaces.") end # -- end check for valid request end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_page\n @doc = Nokogiri::HTML(@html)\n end", "def fetch\n\t\tbegin\n\t\t\tresponse = RestClient.get(@url,:user_agent => @user_agent.get_user_agent)\n\t\t\tdoc = Nokogiri::HTML(response)\n\t\t\treturn doc\n\t\trescue Exception => e\n\t\t\tLogWriter.error(e)\n\t\t\tthrow e\n\t\tend\n\tend", "def...
[ "0.7705032", "0.7336612", "0.7261828", "0.713009", "0.70951366", "0.690861", "0.6889337", "0.6873605", "0.68549895", "0.68442816", "0.6838664", "0.679592", "0.6792495", "0.67885655", "0.676248", "0.6736884", "0.67167085", "0.6660647", "0.66542584", "0.66249514", "0.662219", ...
0.0
-1
end getPage get table of locations for this monster
def getLocations # create locations table locations = Array.new # turn page into Nokogiri object parsed_page = Nokogiri::HTML(@page) # get table of drop info from page locations = parsed_page.css("#mw-content-text").css("ul").css("li").css("a").children.map { |r| r.text } # prints table for debugging # puts("table = #{locations}") # save locations globally @locations = locations end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations; end", "def locations\n @locations = Location.where(fragment: @scenario.fragments).order(:id).page params[:page]\n end", "def getAllLocations()\n coll = self.coll_locations\n puts coll.find()\n coll.find.each { |row| puts row.inspect }\n end", "def _locations_ordered_for_text_dump...
[ "0.6401812", "0.6018758", "0.6014842", "0.59962714", "0.59294844", "0.5865375", "0.585738", "0.5828805", "0.58150476", "0.5791945", "0.5759057", "0.5759057", "0.5673639", "0.56026846", "0.5584741", "0.5568119", "0.5558268", "0.55519253", "0.55519253", "0.5532963", "0.5524712"...
0.72257155
0
end getLocations print Locations table
def printLocations puts("Locations for #{@arguments[@arguments.length - 1]}:") # print each location on its own line for i in 0..@locations.length - 1 puts("\t#{@locations[i]}") end # -- end for loop for printing locations end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAllLocations()\n coll = self.coll_locations\n puts coll.find()\n coll.find.each { |row| puts row.inspect }\n end", "def locations; end", "def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end"...
[ "0.7875192", "0.761616", "0.7317156", "0.7130742", "0.7106988", "0.698", "0.6926923", "0.6898764", "0.6861267", "0.68212104", "0.67966825", "0.6669528", "0.6612747", "0.6538792", "0.6507524", "0.648998", "0.6475416", "0.64692426", "0.64692426", "0.64344376", "0.64344376", "...
0.7329603
2
TODO not implemented yet...
def parse_ddm(ddm);end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def custom; end", "def custom; end", "def weber; end", "def internal; en...
[ "0.78406596", "0.6851946", "0.65930766", "0.65930766", "0.65930766", "0.65930766", "0.653857", "0.638945", "0.638945", "0.6363093", "0.6246695", "0.6246695", "0.6242242", "0.6168233", "0.6139521", "0.607513", "0.60717636", "0.6055234", "0.6055234", "0.60315675", "0.60247874",...
0.0
-1
They might be fun in your world, but not here. Get rid of them. Only the ending ones. 1450 > 145 960000 > 96 1050 > 105 1050 > 105 Zero alone is fine, don't worry about it. Poor guy anyway
def no_boring_zeros(num) return 0 if num == 0 new_num = num.to_s if new_num[-1] == "0" no_boring_zeros(new_num[0..-2]) else return new_num.to_i end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def low_toms\n [43]\n end", "def non_zero_digit; end", "def busqueda6\n 9899.step(999999999999999999999,9899){|x|break (x) unless (p x).to_s =~ /[^0-2]/}\nend", "def wtf_nums()\r\n\tthe_wtf_num = [37107287533902102798797998220837590246510135740250, 46376937677490009712648124896970078050417018260538,\r...
[ "0.61975116", "0.59022087", "0.5794581", "0.5721526", "0.5701823", "0.5621426", "0.562061", "0.560886", "0.5558011", "0.5503664", "0.54880804", "0.5485253", "0.54785603", "0.5463173", "0.54615545", "0.54385406", "0.5426616", "0.5425622", "0.5395346", "0.5390975", "0.5336127",...
0.5048128
88
def direct_move_ok? need this? col_move.abs <= Piece::Constants::MAX_COL_MOVE && need this? row_move.abs <= Piece::Constants::MAX_ROW_MOVE && direct_space_on_grid? end
def dir_sym if grid.include?(self.direction_vector.direction.leap) self.direction_vector.direction.leap elsif grid.include?(self.direction_vector.direction.normal) self.direction_vector.direction.normal else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_move?(proposed_row, proposed_col, solution)\n return true\nend", "def could_be_valid_move?\n return @board_gfx.is_draggingpiece_valid?\n end", "def legal_move?(board,from,to)\n\t\treturn false unless super(board,to)\n\t\tfrom_y = from[1]\n\t\tfrom_x = from[0]\n\t\tto_y = to[1]\n\t\tto_x = to[...
[ "0.8003332", "0.7993847", "0.79278386", "0.78864145", "0.78864145", "0.77782404", "0.7696855", "0.76833934", "0.7665292", "0.7664419", "0.7664202", "0.76580036", "0.76529586", "0.7646282", "0.7624448", "0.76230615", "0.7610852", "0.7610012", "0.7605868", "0.759676", "0.759627...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_astronaut @astronaut = Astronaut.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.6165422", "0.60457647", "0.5946384", "0.5916027", "0.58905005", "0.583495", "0.5777223", "0.56995213", "0.56995213", "0.56532377", "0.5621348", "0.5422839", "0.54118705", "0.54118705", "0.54118705", "0.53935355", "0.5379617", "0.53577393", "0.53407264", "0.53398263", "0.53...
0.0
-1
Only allow a trusted parameter "white list" through.
def astronaut_params params.require(:astronaut).permit(:firstname, :lastname, :birthdate, :superpower) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7122899", "0.7054107", "0.69478", "0.6902101", "0.67359334", "0.67178756", "0.66889167", "0.6677724", "0.6661157", "0.6555896", "0.6527207", "0.64584696", "0.64517015", "0.6450208", "0.644749", "0.6435074", "0.6413329", "0.6413329", "0.6391818", "0.6380081", "0.6380081", ...
0.0
-1
converte AFND para AFD
def converte # estados estados = ['q'] 1.upto(@estados.length) do |i| @estados.keys.combination(i).to_a.collect { |c| c.sort.join }.each do |a| estados << 'q' + a end end # alfabeto alfabeto = @alfabeto # função de transição transicao = [] estados.each do |estado| if estado == 'q' # vazio alfabeto.each { |el| transicao << [ 'q', el, 'q' ] } else alfabeto.each do |el| # verifica setas setas = [] estado[1,estado.length].each_char do |c| @transicao.each do |funcao| if funcao[0] == c and funcao[1] == el setas << funcao[2] end end end setas = setas.flatten.uniq.sort # adiciona setas no caso de 'e' setas.each do |c| @transicao.each do |funcao| if funcao[0] == c and funcao[1] == nil setas << funcao[2] end end end setas = setas.flatten.uniq.sort # acrescenta à função de transição transicao << [ estado, el, 'q' + setas.join ] end end end # estado inicial i = [@atual.nome] @transicao.each do |funcao| if funcao[0] == @atual.nome and funcao[1] == nil i << funcao[2] end end inicial = 'q' + i.flatten.uniq.sort.join # estados finais finais = [] estados.each do |estado| @finais.each do |final| finais << estado if estado.include? final end end finais.uniq! # simplifica, removendo os estados que não recebem nenhuma seta a_remover = [] (estados - [inicial]).each do |estado| encontrado = false transicao.each do |funcao| encontrado = true if funcao[2] == estado end a_remover << estado if not encontrado end a_remover.each do |estado| estados.delete estado r = [] transicao.each do |funcao| r << funcao if funcao[0] == estado end r.each { |x| transicao.delete x } finais.delete estado end return { K: estados, S: alfabeto, d: transicao, s: inicial, F: finais } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dfa\n fa.determinize\n end", "def afue_to_thermal_eff(afue)\n \n return afue # Per PNNL doc, Boiler Addendum 90.1-04an\n \nend", "def to_f(aNum)\r\n# - - - - - - - - - - - - - - - - - -\r\n return 0.0 + aNum\r\nend", "def efg\n return 0.0 if fg.zero? || fga.zero?\n\n ((fg.to_f + 0.5 *...
[ "0.6325439", "0.6099129", "0.572846", "0.5698772", "0.55874217", "0.5498887", "0.5446773", "0.54372144", "0.54354674", "0.54354674", "0.54354674", "0.54354674", "0.5432373", "0.54255164", "0.5329475", "0.52581", "0.5249401", "0.52393067", "0.52351195", "0.52351195", "0.523511...
0.0
-1
override parent method you can define a "custom field" in redmine named "Tags" to add tags to your feature files
def feature_files features = Redcukes::Issue.cucumber_features features.each do |feature| @tags = get_tags feature write_feature_file(build_feature_filename(feature), build_source(feature)) if is_valid?(feature) end # proceed as usual original_feature_files end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_tags\n raise NotImplementedError\n end", "def tag\n end", "def tag\n end", "def tag; end", "def tag; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def create_tags\n\tend", "def tag\n raise NotImplementedError\n end", ...
[ "0.70062184", "0.68605024", "0.68605024", "0.68155485", "0.68155485", "0.6812036", "0.6812036", "0.6812036", "0.6812036", "0.6812036", "0.6716317", "0.66413146", "0.66413146", "0.66129774", "0.6508502", "0.6466997", "0.64312965", "0.64312965", "0.64312965", "0.6415587", "0.63...
0.0
-1
Check if the feature is valid It must have at least a description
def is_valid?(feature) !feature.description.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_feat(feature) #:doc:\n # rubocop:enable Style/CommentedKeyword\n if feature.nil? || feature.empty?\n raise(\"Feature '#{feature_id}' could not be found\")\n return false\n end\n\n if feature[:geometry].nil?\n raise(\"No geometry found in '#{featur...
[ "0.6984743", "0.6984743", "0.68360966", "0.668437", "0.6681328", "0.66419995", "0.6571376", "0.6565108", "0.654424", "0.6516726", "0.6474283", "0.6448626", "0.64416224", "0.6427786", "0.6423468", "0.63469434", "0.6331054", "0.63120687", "0.62491506", "0.62427384", "0.621113",...
0.87552136
0
builds the path and filename to the feature for now, just cucumberjs tagged features go into a separate dir
def build_feature_filename(feature) features_subdir = "#{Rails.root}/#{get_tag_dir}" Dir.mkdir features_subdir unless Dir.exists?(features_subdir) "#{features_subdir}#{feature.id}_#{feature.subject.parameterize}.feature" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feature_files\n features = Redcukes::Issue.cucumber_features\n features.each do |feature|\n @tags = get_tags feature\n write_feature_file(build_feature_filename(feature), build_source(feature)) if is_valid?(feature)\n end\n # proceed as usual\n original_feature_files\n end", "def wr...
[ "0.7119631", "0.6975983", "0.6549208", "0.640171", "0.61919874", "0.6177367", "0.604678", "0.6040209", "0.59816724", "0.5981166", "0.5968745", "0.5963486", "0.5843787", "0.58051527", "0.5802598", "0.579359", "0.5791053", "0.5748768", "0.5662635", "0.56558055", "0.56481206", ...
0.77932125
0
checks if a given tag is in the feature
def has_tag(tag) @tags.include?("@#{tag}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_tag?(tag)\n tags.include?(tag.to_s)\n end", "def specifies?(tag)\n include?(tag)\n end", "def has_tag?(tag)\n self.tags.include?(tag)\n end", "def has_tag?(t)\n tags.include?(t)\n end", "def has_tag? (tag)\n\n @tags.include?(tag)\n end", "def tagged?(tag)...
[ "0.7809473", "0.7737755", "0.7704617", "0.76792955", "0.7585612", "0.7502675", "0.7431091", "0.74276584", "0.7325551", "0.7190395", "0.7181938", "0.715186", "0.71027976", "0.7068545", "0.70492154", "0.7040066", "0.7018544", "0.7017928", "0.70080096", "0.6981679", "0.69782174"...
0.76482075
4
creates the feature file
def build_source(feature) # clean up redmine text formatting description = feature.description.gsub(/<\/?code[^>]*>/ui,'').gsub(/<\/?pre[^>]*>/ui,'"""').gsub(/^$\n/, '') subject = "Feature: #{feature.subject}\n" "#{@tags.join(' ') + "\n" if @tags}#{subject}\n #{description}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_feature\n File.open(\"features/\"\"#{@feature.gsub(\" \", \"_\")}.feature\", \"w\") do |f|\n f.write(\"#{@tags}\\n\")\n f.write(\"Feature: #{@feature}\\n\")\n f.write(\"Description: #{@description}\\n\\n\")\n f.write(\"\\tScenario: #{@scenario}\\n\")\n end\n @steps.each do |st...
[ "0.7474269", "0.7212635", "0.70765406", "0.66374415", "0.66170794", "0.6538439", "0.64459664", "0.6441224", "0.63514864", "0.63120085", "0.63024163", "0.60871905", "0.6046818", "0.6028178", "0.6004429", "0.59729517", "0.59405166", "0.59263563", "0.58901316", "0.5850688", "0.5...
0.0
-1
Gets the tags from the custom field
def get_tags(feature) tags = [] feature.custom_fields.each { |field| tags = field.value if field.name = 'Tag' } tags end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags\n @fields.tag_list\n end", "def parse_meta_tags ( field_key )\n value = self[field_key]\n tags = parse_tags value\n return tags\n end", "def tags_field\n try_until -> { @tags_field } do\n send_message(Protocol::Device::GetTags.new)\n end\n @tags_...
[ "0.78187865", "0.73883814", "0.7242648", "0.70450723", "0.69797045", "0.69797045", "0.69797045", "0.69797045", "0.69797045", "0.6937105", "0.69308996", "0.69308996", "0.69308996", "0.69266325", "0.6857128", "0.68302476", "0.68302476", "0.6817687", "0.67336893", "0.67052937", ...
0.7556093
1
Writes the created feature file to filesystem
def write_feature_file(feature_file, feature_content) begin file = File.open(feature_file, 'w') file.write(feature_content) rescue IOError => e # some error occur, dir not writable etc. pp e ensure file.close unless file == nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_feature\n File.open(\"features/\"\"#{@feature.gsub(\" \", \"_\")}.feature\", \"w\") do |f|\n f.write(\"#{@tags}\\n\")\n f.write(\"Feature: #{@feature}\\n\")\n f.write(\"Description: #{@description}\\n\\n\")\n f.write(\"\\tScenario: #{@scenario}\\n\")\n end\n @steps.each do |st...
[ "0.79729074", "0.7631154", "0.6869838", "0.6820746", "0.6693166", "0.6263742", "0.6249097", "0.6205908", "0.61822003", "0.6134093", "0.61281866", "0.6126218", "0.61107874", "0.6103759", "0.60927075", "0.60764056", "0.6071514", "0.6067345", "0.6066454", "0.60549504", "0.605090...
0.7958332
1
basic loop checking values using RegEx
def letter_case_count(string) hash = { lowercase: 0, uppercase: 0, neither: 0 } str_arr = string.chars counter = 0 while counter < str_arr.size if str_arr[counter] =~ /[a-z]/ hash[:lowercase] += 1 elsif str_arr[counter] =~ /[A-Z]/ hash[:uppercase] += 1 else hash[:neither] += 1 end counter += 1 end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_scan(s, pattern); end", "def check_scan(s, pattern); end", "def run(value)\n REGEX =~ value\n end", "def each_match_range(range, regex); end", "def matching_lines(regex); end", "def match(input); end", "def validate_input(list)\n\n list.each { |i|\n if /[a-zA-Z]+\\d+/ !~ i\n ...
[ "0.66549355", "0.66549355", "0.63319427", "0.6298638", "0.6243065", "0.60207355", "0.59506506", "0.5939857", "0.59380525", "0.5900749", "0.58839655", "0.5870079", "0.5763974", "0.57131165", "0.56328934", "0.56121194", "0.56112456", "0.5600186", "0.5536846", "0.55280364", "0.5...
0.0
-1
Arrayeach method + RegEx
def letter_case_count(string) hash = { lowercase: 0, uppercase: 0, neither: 0 } str_arr = string.chars str_arr.each do |char| if char =~ /[a-z]/ hash[:lowercase] += 1 elsif char =~ /[A-Z]/ hash[:uppercase] += 1 else hash[:neither] += 1 end end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(items) \n out = []\n \n if items.is_a?(Array)\n items.each do |item|\n out << item.scan(@regex).flatten\n end\n \n elsif items.is_a?(String)\n out = items.scan(@regex).flatten#{|m| m.to_s}\n \n else\n out = items\n en...
[ "0.6829098", "0.67410696", "0.6354516", "0.6260793", "0.5934084", "0.57894915", "0.5783807", "0.5752102", "0.5721231", "0.57133585", "0.5711707", "0.56953293", "0.55916446", "0.54725623", "0.54711145", "0.5449701", "0.54063666", "0.53913474", "0.5386442", "0.537853", "0.53609...
0.0
-1
Course Solution using Enumerablecount and RegEx, this solution loops through the created character array three times checking the case or otherness of each character and assigning the quantity of matches to the appropriate key
def letter_case_count(string) counts = {} characters = string.chars counts[:lowercase] = characters.count { |char| char =~ /[a-z]/ } counts[:uppercase] = characters.count { |char| char =~ /[A-Z]/ } counts[:neither] = characters.count { |char| char =~ /[^A-Za-z]/ } counts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve(array)\n aplhabet = ('a'..'z').to_a\n array.map do |string|\n count = 0\n string.chars.each_with_index do |char, idx|\n count += 1 if char.downcase == aplhabet[idx]\n end\n count\n end\nend", "def solve(array)\n alphabet = ('a'..'z').to_a.join\n results = []\n \n array.each do |...
[ "0.728949", "0.71485275", "0.7032071", "0.70231646", "0.68916124", "0.6847759", "0.68456703", "0.6841863", "0.6822612", "0.6807971", "0.6784927", "0.6784927", "0.6767667", "0.67475975", "0.6735803", "0.67299336", "0.6722585", "0.66938746", "0.6693158", "0.66604507", "0.665770...
0.65805215
27
create the session resource ie, let user log in
def create #this references the funciton we made in user.rb user = User.authenticate(params[:session][:email], params[:session][:password]) if user.nil? flash[:login_error] = "Couldn't find a user with those credentials" redirect_to new_session_path else redirect_to user end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_session\n login, password = get_login_and_password\n create_session_with authenticate_user(login, password, :trace => true)\n end", "def create\n\t \t\tmodule_grand_access = permission_control(\"session\",\"create\")\n\t \t\tif module_grand_access\n\t \t\t\tsession = Session.new(session_params)...
[ "0.75247633", "0.7343531", "0.7310949", "0.7287345", "0.72437155", "0.72255594", "0.7224123", "0.72212076", "0.7185254", "0.71811426", "0.7109721", "0.7109721", "0.7109721", "0.7109721", "0.70737916", "0.70518243", "0.7034651", "0.6992562", "0.69785863", "0.69321156", "0.6921...
0.0
-1
TODO: add Array and Hash Predicates
def where(predicate = nil, &blk) predicate = blk if blk SelectedRelation.new(self, predicate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_array_hash\r\n # a = %w(brendan baird billy)\r\n # assert_equal(1047868961, a.hash)\r\n end", "def visit_array(h); end", "def array_flash(n)\nhash = Hash[\n'&','name: Set Intersection---Returns a new array\ncontaining elements common to the two arrays, with no duplicates.\n\n [ 1, 1, 3, 5 ] ___...
[ "0.58974636", "0.5866864", "0.5687214", "0.5531398", "0.5523922", "0.55186886", "0.54933274", "0.54529655", "0.54529655", "0.54529655", "0.5427366", "0.5401181", "0.53778774", "0.5321642", "0.53021014", "0.5279964", "0.52291834", "0.52271867", "0.52245533", "0.5219783", "0.52...
0.0
-1
TODO: check types for TypedRelation
def union_compatible?(other) header == other.header end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relation\n raise NotImplementedError\n end", "def load_type\n :relation\n end", "def child_relation; end", "def relation(rel, &relation_definition)\n raise NotImplementedError, 'relation is not supported yet'\n end", "def relation_types\n Spree::RelationType.whe...
[ "0.6612243", "0.63172644", "0.62681675", "0.61941594", "0.60874015", "0.5932903", "0.5925875", "0.5925875", "0.5925875", "0.5912087", "0.58734137", "0.58685535", "0.5848709", "0.5838171", "0.5838016", "0.5801433", "0.57990116", "0.57973874", "0.57675946", "0.5747781", "0.5738...
0.0
-1
TODO: Add union (|,+), intersection (&), cartiesianproduct (), difference ()
def union(other) if union_compatible?(other) UnitedRelation.new(self, other) else raise 'Cannot create a union with the given relation' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def union(lb)\n\n\n\n\n\n end", "def get_intersection\n end", "def intersection(a, b)\n negate(union(negate(a), negate(b)))\n end", "def intersection\n self.reduce(&:intersection)\n end", "def union itemA, itemB\n\tend", "def union(op_izq, op_der)\n op_izq | op_der # ese | es el ...
[ "0.72930115", "0.64227355", "0.6379334", "0.63671", "0.6357611", "0.6325143", "0.6177614", "0.61686486", "0.61510354", "0.61372894", "0.61220163", "0.61045253", "0.6037599", "0.6024567", "0.6021237", "0.6009552", "0.5982426", "0.5923801", "0.5923092", "0.5921562", "0.59146196...
0.0
-1
Aggregate functions Returns a set of the nonnil values of an attribute
def column(attr) @column ||= Set.new(body.map(&attr.to_sym).reject(&:nil?)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values; distinct_values.map(&:value).compact; end", "def aggregate_treat_undefined_attributes_as_default_value?; end", "def aggregate\n []\n end", "def collect_values_with_count\n\t\tvalues = Hash.new {|h,k| h[k]=0}\n\t\tself.class.ecore.eAllAttributes.each do |a|\n\t\t\tv = self.send(:\"#{a.name}\")...
[ "0.6337932", "0.5825207", "0.58032453", "0.574834", "0.57474846", "0.5720677", "0.5702056", "0.55732346", "0.5540988", "0.55369157", "0.55109215", "0.5466306", "0.54590434", "0.5453709", "0.5452071", "0.5390413", "0.53181475", "0.5312781", "0.530356", "0.5255928", "0.523926",...
0.0
-1
Returns the sum of the values of an attribute
def sum(attr) col = column(attr) if col.empty? 0 else col.reduce(&:+) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(attr)\n if empty?\n SpookAndPuff::Money.new('0')\n else\n map(&attr).sum\n end\n end", "def sum(attribute_name, options = {})\n calculate(:sum, attribute_name, options)\n end", "def sum_by(attribute)\n @legs.pluck(attribute).select{|i| i.is_a?(Numeric)}....
[ "0.75576866", "0.7242913", "0.7137388", "0.7073305", "0.6908036", "0.6610947", "0.66091955", "0.6521635", "0.64525217", "0.64498824", "0.6427323", "0.64214116", "0.6413156", "0.6382789", "0.63587123", "0.635853", "0.6348838", "0.63461626", "0.63461626", "0.6344431", "0.633127...
0.7681066
0
Returns the maximum value of an attribute
def max(attr) column(attr).max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_attribute_value(selector, attr_name); end", "def max_attribute_value(selector, attr_name); end", "def maximum(attribute_name, options = {})\n calculate(:max, attribute_name, options)\n end", "def max\n if valid?\n max_value\n end\n end", "def get_max\n @max\n end", "de...
[ "0.802674", "0.802674", "0.79846823", "0.7681853", "0.7576146", "0.75405496", "0.7512725", "0.74467325", "0.74348044", "0.7399936", "0.7393433", "0.73885244", "0.7354183", "0.7335825", "0.7335825", "0.73069346", "0.72632307", "0.72627217", "0.71865344", "0.7168997", "0.716879...
0.8343829
0
Returns the minimum value of an attribute
def min(attr) column(attr).min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def minimum(attribute_name, options = {})\n calculate(:min, attribute_name, options)\n end", "def get_min()\n @min\n end", "def get_min()\n @data.min\n end", "def minimum\n return @minimum\n end", "def get_min\n @min\n end", "def get_min()\n ...
[ "0.8150438", "0.77033466", "0.7595706", "0.75143695", "0.7511858", "0.74605256", "0.74578923", "0.7430035", "0.740534", "0.7321328", "0.7186737", "0.7097321", "0.70934504", "0.7086409", "0.70421445", "0.70251954", "0.6990474", "0.69184846", "0.6890527", "0.6890527", "0.688071...
0.822546
0
Returns the number of nonnil values of an attribute
def count(attr = nil) if attr.nil? super() else column(attr).count end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size_of attr\n real_attr = attribute_for attr\n raise LookupFailure.new(self, attr) unless real_attr\n AX.attr_count_of_element @ref, real_attr\n end", "def number_of_attributes\n\t\treturn self.attributes.size\n\tend", "def nitems\n count = 0\n i = 0\n lim = self.__size\n while i < l...
[ "0.70808285", "0.66704303", "0.6615052", "0.6504653", "0.64700985", "0.6447361", "0.6427156", "0.64194065", "0.6338265", "0.6336512", "0.63108844", "0.63044024", "0.63044024", "0.6258878", "0.62250537", "0.6198064", "0.61178577", "0.6116356", "0.6115909", "0.6107669", "0.6076...
0.6592946
3
Returns the mean value of an attribute
def mean(attr) n = count(attr) if n.zero? 0 else sum(attr) / n end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean\n get_mean\n end", "def mean\n @mean\n end", "def mean\n stats.mean\n end", "def mean\n\n end", "def average(attribute_name, options = {})\n calculate(:avg, attribute_name, options)\n end", "def get_mean\n end", "def mean\n Statistics.mean @data\n ...
[ "0.77493924", "0.75612783", "0.7534478", "0.7423698", "0.7419649", "0.73215526", "0.72858906", "0.7283091", "0.72768897", "0.71778154", "0.7110306", "0.7083795", "0.7073356", "0.7002428", "0.6919028", "0.6912412", "0.686452", "0.684389", "0.68189895", "0.6796644", "0.67716426...
0.8624842
0
TODO: Implement GroupedRelation see:
def group_by(*attrs) if block_given? body.group_by(&Proc.new) else attr = attrs.first or raise 'At least one attribute is required' if attrs.length == 1 body.group_by(&attr.to_sym) else h = body.group_by do |x| val = x.send(attr) attrs.drop(1).each do |attr| val = val.send(attr) end val end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_relations\n relations = EntityGroupRelationship.where(entity_id: self.id)\n relations.sort_by { |r| r[:position] }\n end", "def relation_for(group)\n return if group.class != Group\n self.group_relations.select { |r| r[:group_id] == group.id }.first\n end", "def groups\n groups = []\...
[ "0.66196156", "0.6346418", "0.632306", "0.63122654", "0.61491096", "0.5928088", "0.5892951", "0.58852583", "0.58764225", "0.58300287", "0.5802565", "0.5802565", "0.5802565", "0.57918125", "0.5746996", "0.5741931", "0.5731879", "0.5710178", "0.56917214", "0.5674888", "0.564817...
0.0
-1
returns a copy of itself that can be safely passed on and modified
def derive_child(field_hash:, name:, parent:) self.class.new( rectype: @rectype, namespace: @namespace.literal, field_hash: field_hash, parser: @parser, name: name, parent: parent ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy\n\t\t\treturn self.dup\n\t\tend", "def clone\n self\n end", "def clone\n self\n end", "def clone\n self.copy\n end", "def clone\n self.copy\n end", "def _clone\n self.class.new(self)\n end", "def clone\n other = dup\n other.freeze if self.frozen?\n ...
[ "0.7298583", "0.72137755", "0.7167206", "0.7110461", "0.7110461", "0.7003257", "0.7002958", "0.69824266", "0.69673747", "0.69114673", "0.6893094", "0.6812842", "0.6810113", "0.6810113", "0.6789327", "0.67702943", "0.67685604", "0.67620844", "0.67101836", "0.67101836", "0.6710...
0.0
-1
Return a new instance of Buffer.
def initialize(attributes = {}) @attributes = defaults.merge(attributes) @name = @attributes[:name] @back = @attributes[:back] @front = @attributes[:front] @previous = @attributes[:previous] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_buffer(contents)\n end", "def buffer(str)\n IntelligentBuffer.new(str)\n end", "def initialize(buffer = nil)\n @buf = buffer ? Bytes.force_binary_encoding(buffer) : Bytes.empty_byte_buffer\n @index = 0\n end", "def initialize(buffer = '', options = {})\n @buffer = buffer\n...
[ "0.68954456", "0.68840224", "0.6866448", "0.6837991", "0.6565954", "0.6565954", "0.6524022", "0.62839067", "0.62013656", "0.61880875", "0.617119", "0.60835606", "0.6061499", "0.60571456", "0.60571456", "0.60571456", "0.60391444", "0.6026357", "0.60103124", "0.59974957", "0.59...
0.0
-1
Return a boolean indicating content on the front buffer.
def front? front.any? { |k, v| k == :lines && v.any? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def front?\n return false if front.nil? || front.lines.empty?\n\n true\n end", "def front?\n (front.nil? || front.lines.empty?) ? false : true\n end", "def buffer?\n defined?(buffer_part_type)\n end", "def queued_messages?\r\n @pointer < @buffer.length\r\n end",...
[ "0.7754597", "0.7656268", "0.66995525", "0.6628653", "0.65874624", "0.65777105", "0.6550136", "0.6545369", "0.6545369", "0.6541708", "0.6450587", "0.64030904", "0.6394183", "0.6386081", "0.6361016", "0.6338", "0.63326794", "0.6321718", "0.62866217", "0.62588954", "0.6252582",...
0.6988242
2
Return a boolean indicating content on the back buffer.
def back? back.any? { |k, v| k == :lines && v.any? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def back?\n return false if back.nil? || back.lines.empty?\n\n true\n end", "def back?\n (back.nil? || back.lines.empty?) ? false : true\n end", "def buffer? \n !@_out_buf.nil?\n end", "def queued_messages?\r\n @pointer < @buffer.length\r\n end", "def ...
[ "0.7238239", "0.71316063", "0.7014958", "0.6780127", "0.67256", "0.6701148", "0.66064095", "0.6484557", "0.6393686", "0.63655555", "0.6357148", "0.6337894", "0.6337067", "0.63094616", "0.62971103", "0.6275343", "0.62324744", "0.62250805", "0.61889213", "0.6179436", "0.61734",...
0.6847889
3
Return a boolean indicating content on the previous buffer.
def previous? previous.any? { |k, v| k == :lines && v.any? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def previous?\n return false if previous.nil? || previous.lines.empty?\n\n true\n end", "def previous?\n (previous.nil? || previous.lines.empty?) ? false : true\n end", "def buffer_changed?\n @buffer_changed\n end", "def finished?\n @buffer.size == @size\n end",...
[ "0.71591204", "0.7023122", "0.70122194", "0.67143685", "0.6642144", "0.66067153", "0.6584156", "0.6564754", "0.65593153", "0.6500841", "0.649102", "0.6485667", "0.64485395", "0.6416536", "0.639324", "0.6379421", "0.63666695", "0.62827396", "0.62643194", "0.6200883", "0.616890...
0.65890646
6
Add the content to the back buffer, then update the repository. Returns boolean indicating that the repository was updated.
def add(content = {}) self.back = content update! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\n return if @blob.data == content\n repository.store(self, commit_message)\n end", "def add(content)\n @back = content\n\n store\n\n true\n end", "def write?\n return true unless added.zero?\n return false unless update?\n !(updated + removed).zero...
[ "0.64067596", "0.63158363", "0.59658045", "0.5942855", "0.58844304", "0.58517784", "0.5761874", "0.57341075", "0.5705523", "0.56873876", "0.56270874", "0.5621799", "0.5615901", "0.5610456", "0.55979365", "0.55680245", "0.5556738", "0.55415314", "0.5520374", "0.5513263", "0.54...
0.52314025
47
Return a boolean indicating content was swapped between buffers. It also resets the offsets (i.e. scroll/cursor position).
def swap return false unless back? # Offsets.update({ name: name }) self.previous = front self.front = back self.back = {} update! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap\n Vedeu.log(type: :buffer, message: \"Buffer swapping: '#{name}'\")\n\n @previous = front\n @front = back\n @back = nil\n\n store\n\n true\n end", "def swap\n Vedeu.log(type: :output, message: \"Buffer swapping: '#{name}'\")\n\n @previo...
[ "0.6525514", "0.6433577", "0.6258475", "0.6063727", "0.58576053", "0.5686023", "0.56184447", "0.5411158", "0.5324334", "0.5297789", "0.5294951", "0.5277108", "0.5263278", "0.5227276", "0.52202386", "0.51750827", "0.5168952", "0.5163446", "0.5158458", "0.5113675", "0.5108392",...
0.54881364
7
Return the default attributes of a Buffer.
def defaults { name: '', back: {}, front: {}, previous: {}, } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_attrs\n @default_attrs\n end", "def default_attributes\n cfg_get(:default_attributes)\n end", "def default_attributes\n cfg_get(:default_attributes)\n end", "def default\n attributes.default\n end", "def default_attrs\n attrs = model_class....
[ "0.68618524", "0.6402296", "0.6328186", "0.6131633", "0.61147594", "0.6075136", "0.59515566", "0.59491426", "0.589016", "0.5794473", "0.57393295", "0.5571755", "0.5555185", "0.5555185", "0.55164516", "0.5509187", "0.55085486", "0.548868", "0.54516137", "0.5432993", "0.5425242...
0.0
-1
Show suppliers for a company
def list_suppliers @company = Company.find(params[:company_id]) @pagetitle = "#{@company.name} - Suppliers" if(@company.can_view(getUser())) if(params[:q] and params[:q] != "") fields = ["email", "name"] q = params[:q].strip @q_org = q query = str_sql_search(q, fields) @suppliers = Supplier.paginate(:page => params[:page], :order => 'name', :conditions => ["company_id = ? AND (#{query})", @company.id]) else @suppliers = Supplier.paginate(:page => params[:page], :order => "name", :conditions => {:company_id => @company.id}) end else errPerms() end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_suppliers\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Suppliers\"\n \n if(@company.can_view(current_user))\n if(params[:search] and params[:search] != \"\") \n \n @suppliers = Supplier.where([\"company_id = ? and (ruc L...
[ "0.7828305", "0.7633895", "0.7097873", "0.70439583", "0.69740844", "0.6851192", "0.6768645", "0.6768645", "0.6768645", "0.6590524", "0.65310425", "0.6485815", "0.6478357", "0.64028263", "0.6375696", "0.6375696", "0.63577384", "0.6357462", "0.6322037", "0.6315859", "0.6314218"...
0.79186714
0
GET /suppliers GET /suppliers.xml
def index @pagetitle = "Suppliers" @companies = Company.find(:all, :conditions => {:user_id => getUserId()}, :order => "name") @path = 'suppliers' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n for...
[ "0.699765", "0.699765", "0.66151494", "0.6614756", "0.65525913", "0.65340596", "0.6512919", "0.6512919", "0.6512919", "0.6504384", "0.6482919", "0.63543296", "0.6316173", "0.6293126", "0.6268225", "0.61631536", "0.6155965", "0.6149218", "0.6120664", "0.6102776", "0.6098597", ...
0.61895245
15
GET /suppliers/1 GET /suppliers/1.xml
def show @supplier = Supplier.find(params[:id]) @pagetitle = "Suppliers - #{@supplier.name}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n for...
[ "0.7137171", "0.7137171", "0.6660931", "0.662825", "0.6598268", "0.6546924", "0.64401203", "0.63662136", "0.6342619", "0.6325037", "0.63064", "0.62460595", "0.6224935", "0.6224935", "0.6224935", "0.61754376", "0.6171295", "0.61583483", "0.6144992", "0.6108517", "0.61065406", ...
0.0
-1
GET /suppliers/new GET /suppliers/new.xml
def new @pagetitle = "New supplier" if(params[:company_id]) @company = Company.find(params[:company_id]) if(@company.can_view(getUser())) @supplier = Supplier.new @supplier.company_id = @company.id else errPerms() end else redirect_to('/companies') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @supplier = Supplier.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def new\n @catalogs_supply = Catalogs::Supply.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { re...
[ "0.7682572", "0.70920837", "0.7022739", "0.7003013", "0.6996816", "0.69179255", "0.6894502", "0.6778145", "0.67712945", "0.6729835", "0.6729835", "0.6725048", "0.6702118", "0.6700312", "0.6694577", "0.6691073", "0.667424", "0.6649426", "0.66485953", "0.6648093", "0.66379803",...
0.0
-1
POST /suppliers POST /suppliers.xml
def create @pagetitle = "New supplier" @company = Company.find(params[:supplier][:company_id]) @supplier = Supplier.new(params[:supplier]) respond_to do |format| if @supplier.save format.html { redirect_to(@supplier, :notice => 'Supplier was successfully created.') } format.xml { render :xml => @supplier, :status => :created, :location => @supplier } else format.html { render :action => "new" } format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @supplier = Supplier.new(params[:supplier])\n \n respond_to do |format|\n if @supplier.save\n flash.now[:notice] = 'Supplier was successfully created.'\n format.html { redirect_to(suppliers_path) }\n format.xml { render :xml => @supplier, :status => :created, :locat...
[ "0.6621547", "0.6447621", "0.61774474", "0.6129714", "0.6126737", "0.61229765", "0.60808897", "0.60699683", "0.60485643", "0.6028947", "0.60096514", "0.5887018", "0.587587", "0.58727294", "0.58484536", "0.5783927", "0.5773176", "0.57537305", "0.5735453", "0.5702839", "0.56905...
0.62616956
2
PUT /suppliers/1 PUT /suppliers/1.xml
def update @pagetitle = "Edit supplier" @supplier = Supplier.find(params[:id]) respond_to do |format| if @supplier.update_attributes(params[:supplier]) format.html { redirect_to(@supplier, :notice => 'Supplier was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @pagetitle = \"Edit supplier\"\n \n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n if @supplier.update_attributes(supplier_params)\n format.html { redirect_to(@supplier, :notice => 'Supplier was successfully updated.') }\n format.xml { head :ok }\n ...
[ "0.65476155", "0.65255153", "0.651738", "0.6490928", "0.64007556", "0.6171665", "0.6169146", "0.61633617", "0.615838", "0.61241406", "0.6120355", "0.6095352", "0.6087505", "0.6035432", "0.6032512", "0.60144037", "0.5996009", "0.59868985", "0.5980875", "0.5956054", "0.5948833"...
0.66623425
0
DELETE /suppliers/1 DELETE /suppliers/1.xml
def destroy @supplier = Supplier.find(params[:id]) # Erase supplier id for products from supplier products = Product.find(:all, :conditions => {:supplier_id => @supplier[:id]}) for product in products product.supplier_id = nil product.save end @company = @supplier.company @supplier.destroy respond_to do |format| format.html { redirect_to "/companies/suppliers/#{@company.id}" } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @supplier = Supplier.find(params[:id])\n @supplier.destroy\n\n respond_to do |format|\n format.html { redirect_to(suppliers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @warehouse_supplier = WarehouseSupplier.find(params[:id])\n @warehouse_supplier.des...
[ "0.71366525", "0.66658115", "0.6604435", "0.65774745", "0.65617216", "0.6550284", "0.64589226", "0.64329237", "0.6420457", "0.63684416", "0.63623995", "0.63248175", "0.63070196", "0.63054174", "0.62671995", "0.62368345", "0.62368345", "0.62368345", "0.62364316", "0.6231228", ...
0.6820624
1
TODO: should use factory pattern
def to_params @params = send("to_params_#{@event}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize() end", "def initialize; end", "def initialize; end", ...
[ "0.7293545", "0.6551402", "0.6551402", "0.652512", "0.652512", "0.652512", "0.652512", "0.61726034", "0.61726034", "0.61726034", "0.61726034", "0.61429894", "0.61356014", "0.61356014", "0.61356014", "0.61356014", "0.61356014", "0.61356014", "0.61356014", "0.61356014", "0.6135...
0.0
-1
GET /physics/1 GET /physics/1.json
def show @physic = Physic.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @physic } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @physic = Physic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @physic }\n end\n end", "def show\n @physician = Physician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json...
[ "0.5635962", "0.55613524", "0.5554818", "0.5535605", "0.5523244", "0.549443", "0.5476766", "0.54516757", "0.5399758", "0.5390574", "0.5359733", "0.53326", "0.5310682", "0.53092325", "0.5304288", "0.52766407", "0.52723163", "0.526071", "0.5252194", "0.5249889", "0.5232193", ...
0.6344527
0
GET /physics/new GET /physics/new.json
def new @physic = Physic.new respond_to do |format| format.html # new.html.erb format.json { render json: @physic } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @simulation = Simulation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @simulation }\n end\n end", "def new\n @physician = Physician.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @p...
[ "0.6757673", "0.6749141", "0.6739007", "0.67339367", "0.67116374", "0.67013794", "0.67004794", "0.6692643", "0.6677946", "0.6646122", "0.6625216", "0.6599563", "0.6598152", "0.6596177", "0.65900195", "0.65888447", "0.65871197", "0.65770406", "0.65654993", "0.6534826", "0.6523...
0.7472733
0
POST /physics POST /physics.json
def create @physic = Physic.new(params[:physic]) respond_to do |format| if @physic.save format.html { redirect_to @physic, notice: 'Physic was successfully created.' } format.json { render json: @physic, status: :created, location: @physic } else format.html { render action: "new" } format.json { render json: @physic.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @physio = Physio.new(physio_params)\n\n respond_to do |format|\n if @physio.save\n format.html { redirect_to @physio, notice: 'Physio was successfully created.' }\n format.json { render :show, status: :created, location: @physio }\n else\n format.html { render :new...
[ "0.5956087", "0.56120646", "0.55291975", "0.53277826", "0.5167275", "0.5154661", "0.51380163", "0.5124154", "0.511277", "0.505813", "0.5031423", "0.49913663", "0.49910885", "0.49558896", "0.4955525", "0.49529335", "0.49491885", "0.49410826", "0.49392918", "0.4929145", "0.4921...
0.5857387
1
PUT /physics/1 PUT /physics/1.json
def update @physic = Physic.find(params[:id]) respond_to do |format| if @physic.update_attributes(params[:physic]) format.html { redirect_to @physic, notice: 'Physic was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @physic.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @physio.update(physio_params)\n format.html { redirect_to @physio, notice: 'Physio was successfully updated.' }\n format.json { render :show, status: :ok, location: @physio }\n else\n format.html { render :edit }\n format.json { rend...
[ "0.6145819", "0.5836485", "0.5769126", "0.5743661", "0.5654453", "0.5654425", "0.56380695", "0.5615385", "0.56135476", "0.56135476", "0.55904657", "0.55869204", "0.5575013", "0.55723524", "0.5568806", "0.55511576", "0.55450565", "0.5537041", "0.5534894", "0.5532576", "0.55305...
0.6187376
0
DELETE /physics/1 DELETE /physics/1.json
def destroy @physic = Physic.find(params[:id]) @physic.destroy respond_to do |format| format.html { redirect_to physics_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @physio.destroy\n respond_to do |format|\n format.html { redirect_to physios_url, notice: 'Physio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @three.dest...
[ "0.6739573", "0.6695816", "0.66676563", "0.6640512", "0.6609226", "0.65712684", "0.6557685", "0.6552518", "0.65367675", "0.65334505", "0.6516351", "0.65149623", "0.65114665", "0.651146", "0.6504217", "0.64942294", "0.6488563", "0.6480207", "0.6477143", "0.6465519", "0.6446428...
0.73958176
0
Removes a user from a group. No action will be taken if the user is not already in the group.
def call(group_id, user_id) client.delete("/api/rest/v1/groups/#{group_id}/memberships/#{user_id}.json") true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_user!( user )\n user.remove_group!( self )\n end", "def remove_user_from_group(user, group)\n\t\t\tend", "def remove_user_from_group(group_id, user_id, options = {})\n delete(\"/groups/#{group_id}/users/#{user_id}\", options)\n end", "def remove_user(user)\n group_member...
[ "0.8529811", "0.8498814", "0.83057576", "0.81306493", "0.8059324", "0.8041021", "0.7743291", "0.76041365", "0.7592247", "0.75309664", "0.7528549", "0.746901", "0.7446797", "0.74158984", "0.7389798", "0.7384766", "0.73115474", "0.7307908", "0.73077196", "0.7301015", "0.7274904...
0.6858058
30
TODO: optionally pass in the info as strings/hash? Then site can be created in memory if it doesn't exist in file system. Is that needed?
def initialize load_site load_creds end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_site\n # see if the site already exists\n abort \"'#{site}' already exists\" if test ?e, site\n\n # copy over files from the data directory\n files = site_files\n\n files.keys.sort.each do |dir|\n mkdir dir\n files[dir].sort.each {|file| cp file}\n end\n nil\n end", "de...
[ "0.7162387", "0.65436184", "0.64535016", "0.634594", "0.62568617", "0.62032723", "0.6113121", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", "0.61128247", ...
0.0
-1
We now have remote pages, and can access them by fullpath or by id. We also have the index page, but it has no children. Let's build the rest of the tree structure using the id/parent_id keys
def add_page_to_tree(page) if !page.root? #puts "page: #{page}" #puts "page.fullpath: #{page.fullpath}" #puts "page.parent_id: #{page.parent_id}" page.parent = @remote_pages_by_id[page.parent_id] #puts "page.parent: #{page.parent}" #puts "page.parent.class: #{page.parent.class}" #puts "page.parent.children: #{page.parent.children}" page.parent.children << page end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :ac...
[ "0.648859", "0.64443094", "0.6298577", "0.6266028", "0.6199264", "0.60699034", "0.60632986", "0.6055194", "0.60217696", "0.59879905", "0.5973062", "0.5972318", "0.59627527", "0.5959831", "0.59342915", "0.5922409", "0.5888887", "0.58856684", "0.5866949", "0.5853851", "0.583789...
0.668431
0
Need to create a way to lookup local pages. We are using the fullpath as the unique key.
def add_local_page(page) @local_pages[page.fullpath] = page for child in page.children add_local_page child end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_pages\n @link_collector.local_pages\n end", "def localized_paths_for(page)\n return {} if page.path == \"index.html\"\n localized_paths = {}\n (langs).each do |locale|\n # Loop over all pages to find the ones using the same templates (proxied_to) for each language\n sitemap.resour...
[ "0.5937538", "0.5917049", "0.5913829", "0.5878341", "0.5865737", "0.58321995", "0.5818206", "0.57950324", "0.5768035", "0.57640284", "0.5753003", "0.57323223", "0.573011", "0.5728194", "0.57247704", "0.57247704", "0.5716364", "0.5699097", "0.5683247", "0.56799364", "0.5678081...
0.52796745
84
Dataset ID to timestamp
def datasetid_to_timestamp(datasetid) timestamped = datasetid.id @timestamped = timestamp.id.generation_time.strftime('%d-%m-%Y %H:%M') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timestamp\n timestamp_to_datetime(static_data(\"timestamp\"))\n end", "def time_id(time)\n time.strftime(\"%Y%m%d\")\n end", "def timestamp\n #data[\"timestamp\"] as? TimeInterval ?? 0\n timestamp = data[\"timestamp\"]\n timestamp.to_i || 0\n end", "def timestamp...
[ "0.63841987", "0.6361053", "0.62965274", "0.6198387", "0.61320615", "0.6108717", "0.6104109", "0.6017833", "0.6007954", "0.59296334", "0.5926516", "0.5926516", "0.5926516", "0.5926516", "0.5926516", "0.5926516", "0.59131527", "0.5912479", "0.59092563", "0.59087586", "0.590875...
0.8400559
0
GET /issues/1 GET /issues/1.json
def show @conference=Conference.find(params[:conference_id]) @issue = @conference.issues.find(params[:id]) @attachments=@issue.attachments.all respond_to do |format| format.html # show.html.erb format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gather_issues\n url = \"#{URL}/projects/foreman/issues.json?status_id=1&limit=100&release_id=#{@current_release_id}\"\n puts url\n uri = URI(URI.escape(url))\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend", "def issue(project, id)\n get(\"/projects/#{url_encode project}/issues/#{id}\")...
[ "0.7720709", "0.74033", "0.73966897", "0.7380725", "0.7281423", "0.7261354", "0.7195627", "0.71940756", "0.719402", "0.71918106", "0.71762854", "0.71762854", "0.71762854", "0.71762854", "0.71762854", "0.7152903", "0.7152387", "0.70704055", "0.7065273", "0.70614624", "0.705146...
0.0
-1
GET /issues/new GET /issues/new.json
def new @conference=Conference.find(params[:conference_id]) @issue = @conference.issues.new @issue.attendees.build @issue.attachments.build # @issue = Issue.new(:conference_id => @conference.id) respond_to do |format| format.html # new.html.erb format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end", "def new\n @issue = Issue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue...
[ "0.8183273", "0.7948658", "0.7575654", "0.75103587", "0.73972374", "0.7379584", "0.7312813", "0.7252048", "0.7151902", "0.7071816", "0.7046157", "0.6884826", "0.6884826", "0.6860261", "0.6860261", "0.6829619", "0.6823746", "0.6799665", "0.6796878", "0.6776327", "0.67496395", ...
0.0
-1
POST /issues POST /issues.json
def create @conference=Conference.find(params[:conference_id]) #@issue = @conference.issues.new(params[:issue]) @issue = @conference.issues.create(params[:issue]) respond_to do |format| if @issue.save format.html { redirect_to [@conference,@issue], notice: 'Issue was successfully created.' } format.json { render json: @issue, status: :created, location: @issue } else format.html { render action: "new" } format.json { render json: @issue.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @issue = Issue.new(issue_params)\n\n respond_to do |format|\n if @issue.save\n format.html { redirect_to issues_url, notice: 'Issue was successfully created.' }\n format.json { render json: @issue }\n else\n format.html { redirect_to issues_url, notice: 'There was ...
[ "0.71993804", "0.7070679", "0.70684", "0.70256984", "0.69812995", "0.69812995", "0.69812995", "0.69812995", "0.6976567", "0.68654734", "0.6784554", "0.67398095", "0.67250603", "0.6676758", "0.65035474", "0.6485462", "0.64839655", "0.6474562", "0.6469539", "0.64635193", "0.645...
0.6016681
61
PUT /issues/1 PUT /issues/1.json
def update @conference=Conference.find(params[:conference_id]) @issue = @conference.issues.find(params[:id]) respond_to do |format| if @issue.update_attributes(params[:issue]) format.html { redirect_to [@conference,@issue], notice: 'Issue was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @issue.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @issue = Issue.find(params[:id])\n\n respond_to do |format|\n if @issue.update_attributes(params[:issue])\n format.html { redirect_to @issue, notice: 'Issue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit...
[ "0.67929745", "0.67926174", "0.67782015", "0.6738446", "0.67185116", "0.65700734", "0.65700734", "0.65700734", "0.65700734", "0.65700734", "0.6565578", "0.6547651", "0.6490846", "0.6461722", "0.64603496", "0.63875073", "0.6346879", "0.6341915", "0.6338846", "0.6327602", "0.62...
0.62968606
20
DELETE /issues/1 DELETE /issues/1.json
def destroy @conference=Conference.find(params[:conference_id]) @issue = @conference.issues.find(params[:id]) @issue.destroy respond_to do |format| format.html { redirect_to conference_url(@conference) } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @issue = Issue.find(params[:id])\n @issue.destroy\n\n respond_to do |format|\n format.html { redirect_to issues_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @issue = Issue.find(params[:id])\n @issue.destroy\n\n respond_to do |format|\n f...
[ "0.7737208", "0.7737208", "0.7737208", "0.7737208", "0.77256703", "0.77085835", "0.7654074", "0.7585185", "0.75751466", "0.7548848", "0.74935967", "0.7480501", "0.7480501", "0.7447116", "0.7447116", "0.7447116", "0.7447116", "0.7447116", "0.7447116", "0.7446764", "0.7445747",...
0.64728355
98
This corrects for a quirk in XMLtoobject parsing; usually an XML element is converted to a hash with the element name as key and a hash as a value, but sibling XML elements with the same name are converted to a hash with the element name as key and an array of hashes as value. In cases where the number of elements is unknown, this can ensure that single or blank results still come wrapped in an array.
def as_collection @obj.is_a?(Array) ? self : self.class.new(self.to_a) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_hash(xml_result)\n return nil if xml_result.nil? or (xml_result.class != Hash) or xml_result[\"xmldata\"].nil?\n hash = xml_result[\"xmldata\"]\n\n key = hash.keys.first\n hash[key] = to_arr_if_needed hash[key]\n\n #fix same issue for orderDetails if more then one product for order...
[ "0.66041684", "0.655975", "0.62920326", "0.58911884", "0.58590627", "0.58007306", "0.5751426", "0.57035744", "0.5559118", "0.54860127", "0.54813904", "0.5477812", "0.54503495", "0.54446447", "0.5426759", "0.5426759", "0.5426759", "0.5426759", "0.5412981", "0.5412981", "0.5394...
0.0
-1
REPORTS EMAIL US 4742
def login_to_gmail(user_name, user_password) #@ui_new.set_input_val("#Email", user_name) @ui_new.set_input_val(".whsOnd.zHQkBf", user_name) sleep 2 #@ui_new.click("#next") @ui_new.click("#identifierNext") sleep 3 #@ui_new.set_input_val("#Passwd", user_password) @ui_new.set_input_val(".whsOnd.zHQkBf", user_password) sleep 2 #@ui_new.click("#signIn") @ui_new.click("#passwordNext") sleep 3 @ui_new.css(".z0 .T-I").wait_until(&:present?) expect(@ui_new.css(".z0 .T-I")).to be_present end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report_data\n ReportMailer.report_data\n end", "def mailer; end", "def trainee_report\n @user = @receiver\n @notification = @user.notifications.find_by(link: \"/reports/#{@report.id}\")\n subject = \"[FBC] #{@report.user.login_name}さんが日報【 #{@report.title} 】を書きました!\"\n mail to: @user.email, ...
[ "0.6026018", "0.6013216", "0.5971908", "0.5910152", "0.59094447", "0.5872802", "0.5871674", "0.5848576", "0.5832596", "0.58181465", "0.5813074", "0.5811303", "0.57995725", "0.5777764", "0.57400113", "0.5738032", "0.57252705", "0.57179505", "0.57148594", "0.5707027", "0.570670...
0.0
-1
Find the given executable in the available paths
def find_executable( bin, *paths ) paths = Launchy.path.split( File::PATH_SEPARATOR ) if paths.empty? paths.each do |path| file = File.join( path, bin ) if File.executable?( file ) then Launchy.log "#{self.name} : found executable #{file}" return file end end Launchy.log "#{self.name} : Unable to find `#{bin}' in #{paths.join(", ")}" return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_executable(bin,*paths)\n Application.find_executable(bin,*paths)\n end", "def find_executable(bin,*paths)\n paths = ENV['PATH'].split(File::PATH_SEPARATOR) if paths.empty?\n paths.each do |path|\n file = File.join(path,bin)\n if File.executable?(file) then\n ...
[ "0.82349926", "0.818236", "0.78633463", "0.7664089", "0.7620099", "0.76097697", "0.7604598", "0.7604598", "0.7521265", "0.74455506", "0.7285799", "0.72535944", "0.722603", "0.72100896", "0.71995896", "0.7184009", "0.7184009", "0.7184009", "0.7184009", "0.7184009", "0.7184009"...
0.83103687
0
1. get first letter of word and replace it with the next letter that occurs in the alphabet. 2. repeat with the next letter of the word until you reach the end of the word. 3. return the encrypted word.
def encrypt(word) new_word = "" # puts "Length of word in encrypt method #{word.length}" count = 0 # Set counter to 0 while count < word.length next_letter = word[count].next # edge case, # set "z" equal to "a" and not "aa" if word[count] == "z" next_letter = "a" end # leave space character unchanged. if word[count] == " " next_letter = " " end # print out next_letter character for debugging. # p "next_letter = #{next_letter}" new_word[count] = next_letter count += 1 # increment counter end p new_word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt(word)\n index = 0\n while index < word.length\n unless word[index] == \" \"\n if word[index] == \"z\"\n word[index] = \"a\"\n else\n word[index] = word[index].next!\n end\n end\n index += 1\n end\n return word\nend", "def decrypt (word)\n i = 0\n alphabet =...
[ "0.79028404", "0.7859153", "0.78276265", "0.7825218", "0.7823484", "0.7743787", "0.77155584", "0.77048683", "0.7701986", "0.76673096", "0.7659383", "0.7656785", "0.7651271", "0.7649218", "0.7618595", "0.7617928", "0.76063854", "0.75721323", "0.75635934", "0.75536746", "0.7514...
0.7919949
0
decrypt pseudocode 1. Use the encrypted word returned from the encrypt method 2. Take the first letter of the word and set it to the letter that precedes it in the alphabet 3. Repeat step to for the next letter until the end of the word.
def decrypt(word) # encryption key: # a b c d e f g h i j k l m n o p q r s t u v w x y z # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 alpha = "abcdefghijklmnopqrstuvwxyz" new_word = "" # puts "Length of word in decrypt method #{word.length}" count = 0 while count < word.length cur_letter = word[count] # Handle edge case if cur_letter == " " prev_letter = " " else # Get index of cur_letter in alphabet index_of_cur_letter = alpha.index(cur_letter) # puts "cur_letter = #{cur_letter}, at index #{index_of_cur_letter}" # print for debugging purpose. # set the index of previous letter to the index of current letter minus 1. index_of_prev_letter = index_of_cur_letter - 1 # puts "index_of_prev_letter = #{index_of_prev_letter}" prev_letter = alpha[index_of_prev_letter] # puts "prev_letter = #{prev_letter}" end new_word[count] = prev_letter count += 1 end p new_word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt (word)\n i = 0\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n while i < word.length\n position = alphabet.index(word[i])\n decrypted_letter = alphabet[position -1]\n word[i] = decrypted_letter\n i += 1\n end\n return word\nend", "def decrypt(word)\r\n \r\nposition = 0\r\nnewstring = \...
[ "0.84252506", "0.8171115", "0.81125903", "0.80678314", "0.80655664", "0.80433637", "0.80398417", "0.8022858", "0.8018155", "0.7988296", "0.79531395", "0.7791688", "0.7752652", "0.7728913", "0.765695", "0.7625507", "0.7611082", "0.7604287", "0.7581624", "0.7559076", "0.7554126...
0.8408193
1
GET /assets GET /assets.xml
def index @assets = @campaign.assets respond_to do |format| format.html # index.html.erb format.xml { render :xml => @assets } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end", "def list_assets\n get('/video/v1/assets')\n end", "def index\n @assets = Asset.find(:all)\n\n respond_to do |format|\n ...
[ "0.766882", "0.7315963", "0.7255824", "0.71050686", "0.6935153", "0.6924257", "0.69046664", "0.68881136", "0.68466556", "0.67834485", "0.6737458", "0.66746676", "0.66599834", "0.66599834", "0.66415435", "0.66150415", "0.66150415", "0.6613453", "0.6604568", "0.65537506", "0.65...
0.7104809
4
GET /assets/1 GET /assets/1.xml The show action works like a download
def show @asset = @campaign.assets.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @asset } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @asset.to_xml }\n end\n end", "def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.xml {render xml: @asset}\n format.jso...
[ "0.7727813", "0.77170676", "0.7671661", "0.7671661", "0.7620128", "0.7579006", "0.7444358", "0.7299478", "0.72903377", "0.72903377", "0.7217841", "0.708283", "0.7067846", "0.7000149", "0.69727886", "0.69713056", "0.6963559", "0.69226164", "0.68882406", "0.6870165", "0.683138"...
0.72584254
10
GET /assets/new GET /assets/new.xml
def new @asset = Asset.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @asset } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asset }\n end\n end", "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n format.xml ...
[ "0.76081854", "0.74269706", "0.7014312", "0.6973073", "0.6970339", "0.69685894", "0.696613", "0.696613", "0.69038856", "0.67468756", "0.6730728", "0.67229396", "0.6702703", "0.6701435", "0.6674513", "0.6660168", "0.66568863", "0.66337067", "0.6618057", "0.66146433", "0.661426...
0.76115644
0
POST /assets POST /assets.xml
def create @asset = Asset.new(params[:asset]) @asset.campaign_id = params[:campaign_id] file_dir = "#{FILE_STORAGE_PATH}/#{@campaign.id}" file_path = "#{file_dir}/#{@asset.name}" rescue_file_path = "#{FILE_STORAGE_PATH}/#{@asset.name}" if !File.exists?(file_dir) and !File.directory?(file_dir) Dir.mkdir(file_dir) if !File.exists?(file_dir) flash[:error] = "Directory #{file_dir} creation failed. Uploading the file to the global storage area." file_path = rescue_file_path end end if @asset.save! @asset.path = file_path @asset.url = FILE_URL_TEMPLATE.sub(':campaign_id', @campaign.id.to_s).sub(':asset_id',@asset.id.to_s) File.open(file_path, "wb") do |f| f.write(params[:asset][:path].read) unless params[:asset][:path].nil? end end respond_to do |format| if @asset.save flash[:notice] = "File #{@asset.name} has been successfully added to the campaign #{@campaign.name}." format.html { redirect_to(campaign_assets_url([@campaign, @asset])) } format.xml { render :xml => @asset, :status => :created, :location => @asset } else format.html { render :action => "new" } format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @asset = assets.build(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to user_asset_url(@asset) }\n format.xml { head :created, :location => user_asset_url(@asset) }\n else\n...
[ "0.6193998", "0.6134211", "0.6111537", "0.59586036", "0.5951087", "0.5928681", "0.5899147", "0.58949196", "0.5881975", "0.58126974", "0.5795135", "0.5778651", "0.57770455", "0.57389474", "0.57338536", "0.5731263", "0.5700603", "0.5698594", "0.5691174", "0.5639266", "0.5636452...
0.5142847
70
PUT /assets/1 PUT /assets/1.xml
def update @asset = Asset.find(params[:id]) respond_to do |format| if @asset.update_attributes(params[:asset]) flash[:notice] = "File #{@asset.name} was successfully updated." format.html { redirect_to(campaign_assets_url(@campaign)) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @asset.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @asset = Asset.find(params[:id])\n \n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = 'Asset was successfully updated.'\n format.html { redirect_to(@asset) }\n format.xml { head :ok }\n else\n format.html { render ...
[ "0.6664424", "0.65440893", "0.64578927", "0.6278036", "0.6271494", "0.62211996", "0.62104166", "0.62104166", "0.62104166", "0.6173647", "0.6097886", "0.5976722", "0.5962914", "0.5956891", "0.59273744", "0.59146416", "0.5911704", "0.5908549", "0.59011066", "0.589288", "0.58928...
0.64575076
3
DELETE /assets/1 DELETE /assets/1.xml
def destroy @asset = Asset.find(params[:id]) @asset.destroy() respond_to do |format| format.html { redirect_to(campaign_assets_url([@campaign, @asset])) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(assets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.h...
[ "0.73842037", "0.73842037", "0.73842037", "0.73258716", "0.7080477", "0.6886753", "0.68737334", "0.68737334", "0.68737334", "0.68737334", "0.6818887", "0.6818887", "0.6818887", "0.6818887", "0.6818887", "0.6812915", "0.67929417", "0.67886716", "0.67456704", "0.67203814", "0.6...
0.7132989
4