query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Updates attributes and saves the record. Updates and .save.
def update(...) assign_attributes(...) save end
[ "def update_attributes(attrs = {})\n write_attributes(attrs); save\n end", "def update_attributes(attrs = {})\n set_attributes(attrs); save\n end", "def update_attributes(attrs)\n self.attributes = attrs\n save\n end", "def update\n record.assign_attributes(data)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new TimeOfDay object. TimeOfDay.new("08:00") => 08:00 TimeOfDay.new("x8:00") => raises InvalidTimeOfDayFormat
def initialize(time_of_day) match = /^([0-2]?\d):([0-5]\d)$/.match(time_of_day) raise InvalidTimeOfDayFormat if match.nil? @hour = match[1].to_i @minute = match[2].to_i raise InvalidTimeOfDayFormat if (@hour > HOURS_ONE_DAY) || (@hour == HOURS_ONE_DAY && @minute > 0) end
[ "def parseTimeOfDay(time_of_day:String, verbose:boolean = false)\n creation = TimeOfDay.create\n if verbose\n puts \"-\\t\" + time_of_day\n end\n hours = time_of_day.split(' ')\n hours.each do |hour|\n if !Hour.find_by(name: hour)\n if verbose\n puts \"Error: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds the given +minutes+ to +self+. t = TimeOfDay.new("08:00") => 08:00 t.add_minutes(60) => 09:00 t = TimeOfDay.new("23:50") => 08:00 t.add_minutes(20) => 00:10
def add_minutes(minutes) new_minutes = @minute + minutes hours_to_add = (@minute + minutes) / 60 new_hour = @hour + hours_to_add @hour = new_hour % HOURS_ONE_DAY @minute = new_minutes % ONE_HOUR_IN_MINUTES self end
[ "def minutes=(minutes)\r\n\t\tif minutes.respond_to?( :to_i )\r\n\t\t\t@time += ( minutes.to_i * 60 )\r\n\t\tend\r\n\t\treturn self\r\n\tend", "def advance_minutes(mins)\n self + (mins * 60)\n end", "def plus_minutes(minutes)\n Duration.new(@millis + (minutes.to_i * MINUTES))\n end", "def add_mins...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if +self+ is equal to +other+. TimeOfDay.new("08:00") == TimeOfDay.new("08:00") => true
def ==(other) self.hour == other.hour && self.minute == other.minute end
[ "def ==(other_time)\n @hours == other_time.hours && @minutes == other_time.minutes\n end", "def same?(other)\n other.hour == @hour and other.minute == @minute and other.second == @second and other.millis == @millis\n end", "def ==(other)\n other.is_a?(Time) ? to_time == other : @hms == other.to_h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns difference in minutes between +self+ and +other+. TimeOfDay.new("08:00").minutes_till(TimeOfDay.new("09:00")) => 60 TimeOfDay.new("23:00").minutes_till(TimeOfDay.new("01:00")) => 120 TimeOfDay.new("23:00").minutes_till(TimeOfDay.new("01:00"), :overflow => false) => raises TimeOfDayOutOfRange
def minutes_till(other, options = {}) options[:overflow] = true if options[:overflow].nil? if options[:overflow] if self > other (self.minutes_till(TimeOfDay.new("24:00"))) + other.to_i else other.to_i - self.to_i end else raise TimeOfDayOutOfRange ...
[ "def difference_in_minutes time_one, time_two\n time_one_with_resetted_date = reset_date_for_time time_one\n time_two_with_resetted_date = reset_date_for_time time_two\n (time_one_with_resetted_date - time_two_with_resetted_date) / 60\n end", "def overlap_duration(other)\n # Return 0 if no overlap\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an active record scope for a given atribute agains a value
def scope(attribute, value) attribute.eq(value) end
[ "def create_with_scope(name)\n attribute = self.attribute\n lambda {|model, values| model.filter(attribute.to_sym => values)}\n end", "def create_with_scope(name)\n attribute = self.attribute\n define_scope(name, lambda {|values| {:conditions => {attribute => values}}})\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Override string initializer to check for a valid value
def initialize(value) str_value = value.is_a?(Numeric) ? self.class.values[value.to_i] : value.to_s raise_invalid(value) unless self.class.valid?(str_value) super(str_value) end
[ "def initialize(str, cfg)\n @cfg = cfg\n @str = str_from_input(str) # may raise\n @value = value_from_str\n validate\n end", "def initialize(str, value=nil)\n @string = str\n @symbol = str[-1]\n @value = value\n end", "def require_string(value)\n if va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check for valid '?' and '!' methods
def respond_to_missing?(method_name, include_private = false) name = method_name.to_s return true if name.chomp!('?') name.chomp!('!') && self.class.valid?(name) end
[ "def question_mark_method?\n if self.scan(/[a-zA-Z|_]\\w*\\?/).empty?\n return false\n end\n\n true\n end", "def bang_method?\n method_name.to_s.end_with?('!')\n end", "def safe_method?( method )\n return true if attribute_names.include? method\n return true if ['full_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Throw an exception for comparasion between different enums
def raise_comparison(other) raise EnumError, "Comparison of #{self.class.name} with #{self.inspect} failed" end
[ "def raise_comparison(other)\n raise EnumSetError, \"Comparison of #{self.class.name} with #{self.inspect} failed\"\n end", "def enum_comparable?(e_s_or_v)\r\n Enum === e_s_or_v && e_s_or_v.type == self ||\r\n Symbol === e_s_or_v && has_symbol?(e_s_or_v) ||\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write a method to_initials that takes in a person's name string The method returns a string representing their initials.
def to_initials(name) # Write your code here end
[ "def to_initials(name)\n array = name.split(' ')\n initials = ''\n array.each { |part| initials += part[0] }\n initials\n end", "def initials\n \"#{self.first_initial}#{self.last_initial}\" # e.g., \"JF\"\n end", "def initials\n initials = name.split(/\\s+/).map { |n| n[0].chr }.join('')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An example of checking superclass
def check_superclass(var) puts "#{var} --> #{var.superclass}" end
[ "def superclass?\n !@superclass.nil?\n end", "def sub_class?\n self.superclass != Object\n end", "def validate_subclass\n superclass_name = 'Player'\n\n begin\n # ensure AI inherits from Player\n raise unless self.class.superclass.name == superclass_name\n\n # ensure...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates mock RDF data to be validated against SHACL shapes.
def fake_data_generator(query, output_document) ############ # Removed this, as it is not necessary ############ #uris_hash = Hash.new #uris_hash.default_proc = proc {|k| k} #File.foreach(query_document_location) {|line| # case line # when /^PREFIX (\w+:) (<.+)>/i #if the line...
[ "def shacl_validator(rdf_graph, shacl_document)\n shacl_shapes = Hash.new\n responsive_endpoints = Array.new\n graph = RDF::Graph.load(rdf_graph)\n File.foreach(shacl_document) {|line|\n case line\n when /^EU/\n @endpoint_url = line.match(\"^EU\\t(.+)\\n\")[1]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses the SHACL and linkeddata gems to validate the fake data against a database of SHACL shapes.
def shacl_validator(rdf_graph, shacl_document) shacl_shapes = Hash.new responsive_endpoints = Array.new graph = RDF::Graph.load(rdf_graph) File.foreach(shacl_document) {|line| case line when /^EU/ @endpoint_url = line.match("^EU\t(.+)\n")[1] when /^SH/ ...
[ "def quick_validate\n puts \"\\nDoing some validation\"\n expected_diff = '010700000000000000' # ?\n IMPORT_TABLES.each_key do |t|\n GeographicAreasGeographicItem.where(data_origin: t.to_s).limit(9).each do |i|\n if i.geographic_item.valid_geometry?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /admin/interviews/1 GET /admin/interviews/1.json
def show @admin_interview = Interview.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @admin_interview } end end
[ "def index\n @interviews = current_user.interviews\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end", "def index\n \n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /admin/interviews/new GET /admin/interviews/new.json
def new @admin_interview = Interview.new respond_to do |format| format.html # new.html.erb format.json { render json: @admin_interview } end end
[ "def new\r\n @interview = Interview.new\r\n\r\n respond_to do |format|\r\n format.html { render \"/users/interviews/new\" }# new.html.erb\r\n format.json { render json: @interview }\r\n end\r\n end", "def new\n @s = Script.find(params[:id])\n @interview = @s.interviews.bui...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /admin/interviews/1 PUT /admin/interviews/1.json
def update @admin_interview = Interview.find(params[:id]) respond_to do |format| if @admin_interview.update_attributes(params[:interview]) format.html { redirect_to [:admin, @admin_interview], notice: 'Entrevista atualizada com sucesso' } format.json { head :no_content } else ...
[ "def update\n @interview = Interview.find_by_slug(params[:id])\n\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n format.html { redirect_to admin_interviews_path, notice: 'Interview was successfully updated.' }\n format.json { head :no_content }\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /admin/interviews/1 DELETE /admin/interviews/1.json
def destroy @admin_interview = Interview.find(params[:id]) @admin_interview.destroy respond_to do |format| format.html { redirect_to admin_interviews_url } format.json { head :no_content } end end
[ "def destroy\n @interview = Interview.find_by_slug(params[:id])\n @interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_path, notice: 'Interview was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @interview = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /app_requests GET /app_requests.json
def index @app_requests = AppRequest.all end
[ "def index\n @app_requests = AppRequest.all(:order => \"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @app_requests }\n end\n end", "def get_appoitment\n\t\tid = params[:id]\n\t\t#user_token = params[:user_token]\n\t\turl = \"https://...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /app_requests POST /app_requests.json
def create @app_request = AppRequest.new(app_request_params) @app_request.order_uid = SecureRandom.uuid tm_response = faraday.post do |req| req.url uri.path req.headers['Content-Type'] = 'application/json' req.headers['X-API-KEY'] = @app_request.public_key req.body = @app_request.to...
[ "def create_application(application_id, request)\n start.uri('/api/application')\n .url_segment(application_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def post_billing_codes\n\t\tid = params[:id]\n\t\t#user_token = params[:u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /app_requests/1 PATCH/PUT /app_requests/1.json
def update respond_to do |format| if @app_request.update(app_request_params) format.html { redirect_to @app_request, notice: 'App request was successfully updated.' } format.json { render :show, status: :ok, location: @app_request } else format.html { render :edit } forma...
[ "def update_application(application_id, request)\n start.uri('/api/application')\n .url_segment(application_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end", "def patch *args\n make_request :patch, *args\n end", "def api_patch(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /app_requests/1 DELETE /app_requests/1.json
def destroy @app_request.destroy respond_to do |format| format.html { redirect_to app_requests_url, notice: 'App request was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end", "def destroy\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_ur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Recursively diff two directories This will walk through dir1 and diff matching paths in dir2
def test_dirs(desc, dir1, dir2) test_missing_files(desc, dir1, dir2) dir_files(dir1).each do |file| file2 = file.sub(dir1, dir2) if File.exist?(file2) if diff = diff_file(file, file2) @failures << { desc: "#{desc}\nDiff of file: #{file.sub(dir1+'/', '')}\n", result: forma...
[ "def diff_dirs(dir1, dir2)\n mattching_dir_files(dir1, dir2).each do |file|\n a = File.join(dir1, file)\n b = File.join(dir2, file)\n diff_files(a,b)\n end\n end", "def compareDirs(iDir1, iDir2)\n rResult = false\n\n # First, the contents\n lDir1Content...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /genotypes GET /genotypes.json
def index @genotypes = Genotype.paginate(:page => params[:page], :per_page => 10) respond_to do |format| format.html # index.html.erb format.json { render json: @genotypes } end end
[ "def show\n @genotype = Genotype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @genotype }\n end\n end", "def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /genotypes/1 GET /genotypes/1.json
def show @genotype = Genotype.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @genotype } end end
[ "def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genotype }\n end\n end", "def index\n @genotypes = Genotype.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /genotypes/new GET /genotypes/new.json
def new @genotype = Genotype.new respond_to do |format| format.html # new.html.erb format.json { render json: @genotype } end end
[ "def create\n @genotype = Genotype.new(params[:genotype])\n\n respond_to do |format|\n if @genotype.save\n format.html { redirect_to @genotype, notice: 'Genotype was successfully created.' }\n format.json { render json: @genotype, status: :created, location: @genotype }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /genotypes POST /genotypes.json
def create @genotype = Genotype.new(params[:genotype]) respond_to do |format| if @genotype.save format.html { redirect_to @genotype, notice: 'Genotype was successfully created.' } format.json { render json: @genotype, status: :created, location: @genotype } else format.html ...
[ "def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genotype }\n end\n end", "def create\n @iotype = Iotype.new(iotype_params)\n\n # write iotype to database\n if @iotype.save\n redirect_to iotypes_path, :notic...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /genotypes/1 PUT /genotypes/1.json
def update @genotype = Genotype.find(params[:id]) respond_to do |format| if @genotype.update_attributes(params[:genotype]) format.html { redirect_to @genotype, notice: 'Genotype was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } ...
[ "def create\n @genotype = Genotype.new(params[:genotype])\n\n respond_to do |format|\n if @genotype.save\n format.html { redirect_to @genotype, notice: 'Genotype was successfully created.' }\n format.json { render json: @genotype, status: :created, location: @genotype }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /genotypes/1 DELETE /genotypes/1.json
def destroy @genotype = Genotype.find(params[:id]) @genotype.destroy respond_to do |format| format.html { redirect_to genotypes_url } format.json { head :ok } end end
[ "def destroy\n json_destroy(genre)\n end", "def destroy\n @gene_type = GeneType.find(params[:id])\n @gene_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gene_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gen = Gen.find(params[:id]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Filter translations according to the specified scope.
def filter(translations, scopes) scopes = scopes.split(".") if scopes.is_a?(String) scopes = scopes.clone scope = scopes.shift if scope == "*" results = {} translations.each do |scope, translations| tmp = scopes.empty? ? translations : filte...
[ "def filter\n translation_ids = params[:translations].to_s.split(',')\n @translations = load_translations.where(id: translation_ids)\n render\n end", "def filter(translations, scopes)\n scopes = scopes.split(\".\") if scopes.is_a?(String)\n scopes = scopes.clone\n scope = scopes.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds a table in the DB.
def find_table(table) raise IMDB::DatabaseExceptions::TableDoesNotExist.new(table) unless @tables[table] @tables[table] end
[ "def findTable(name)\r\n tables.each {|x|\r\n if x.name.eql? name\r\n return x\r\n end\r\n }\r\n return nil\r\n end", "def find(name)\n all_tables.find{ |t| t.name == name }\n end", "def find(table, id_to_find)\n result = DATABASE.execute(\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Overrides the initialize method to set the default value of the equation_solver_class instance variable for this class.
def initialize super @equation_solver_class = SolitonProject::KDeVEquationSolver end
[ "def solve_equation\n print(\"\\nGenerating data...\\n\")\n @equation_solver = @equation_solver_class.new(\n @initial_condition,\n @parameters[:number_of_temporal_points] - 1,\n @parameters[:x_interval],\n @parameters[:t_interval]\n )\n @equation_solver.setup\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a positive half period sine wave as the initial condition using the supplied amplitude, period and spatial_offset parameters.
def generate_initial_condition initial_condition_elements = [] num_wave_points = ( (@parameters[:period]/2) / @parameters[:x_interval] ).to_i num_zero_points_before = ( @parameters[:spatial_offset] * @parameters[:number_of_spatial_points] ...
[ "def sine_wave freq, pos\n Math.sin(2 * Math::PI * pos / (OUTPUT_FREQUENCY / freq))\nend", "def sine_wave_point(x)\n return @parameters[:amplitude] * Math.sin(\n (2 * Math::PI / @parameters[:period]) * x\n )\n end", "def generate_waveform\n waveform = []\n 1.upto(500) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the value of the sine wave at the value of _x_ such that the maximum value of x maps to theta = pi.
def sine_wave_point(x) return @parameters[:amplitude] * Math.sin( (2 * Math::PI / @parameters[:period]) * x ) end
[ "def sin\n apply_lambda_flat(->(x){Math.sin(x)})\n end", "def sine_term(x, term_num)\n n = 1 + (term_num * 2)\n term = x**n / factorial(n)\n term * term_sign(term_num)\n end", "def sine_wave freq, pos\n Math.sin(2 * Math::PI * pos / (OUTPUT_FREQUENCY / freq))\nend", "def sin(x, prec)\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO, make controllers and lights available through external object, as opposed to passing it around
def initialize(controllers, lights) #start_scheduler @controllers = controllers @devices = lights # this variable is used to @rh_context ||= {} end
[ "def sensors\r\n SensorsController.instance\r\n end", "def lights\n @lights ||= add_all_lights\n end", "def devices\r\n DevicesController.instance\r\n end", "def initialize controller\n @controller = controller\n end", "def main\r\n MainController.instance\r\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /api/auth_ip_address_groups/1 GET /api/auth_ip_address_groups/1.json
def show render json: @auth_ip_address_group, status: :ok end
[ "def get_groups_for_ip_address_with_http_info(ip_address, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyInventoryGroupsGroupMembersApi.get_groups_for_ip_address ...'\n end\n # verify the required parameter 'ip_address' is set\n if @api_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /api/auth_ip_address_groups/1 PATCH/PUT /api/auth_ip_address_groups/1.json
def update if @auth_ip_address_group.update_attributes(auth_ip_address_group_params) render json: @auth_ip_address_group, status: :ok else render_error(@auth_ip_address_group, :unprocessable_entity) end end
[ "def patch_group(group_id, request)\n start.uri('/api/group')\n .url_segment(group_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end", "def patch_update\n group = @company.public_send(ScimRails.config.scim_groups_scope).find(par...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /api/auth_ip_address_groups/1 DELETE /api/auth_ip_address_groups/1.json
def destroy @auth_ip_address_group.destroy head :no_content end
[ "def zonegroups_delete zgID: \n call_adglare_api 'zonegroups_delete', { zgID: zgID }\n end", "def destroy\n @auth_ip_address.destroy\n head :no_content\n end", "def delete!\n response = @connection.csreq(\"DELETE\",@connection.svrmgmthost,\"#{@connection.svrmgmtpath}/shared_ip_groups/#{URI.esca...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /mispronunciations/1 GET /mispronunciations/1.json
def show @mispronunciation = Mispronunciation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @mispronunciation } end end
[ "def destroy\n @mispronunciation = Mispronunciation.find(params[:id])\n @mispronunciation.destroy\n\n respond_to do |format|\n format.html { redirect_to mispronunciations_url }\n format.json { head :no_content }\n end\n end", "def new\n @mispronunciation = Mispronunciation.new\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /mispronunciations/new GET /mispronunciations/new.json
def new @mispronunciation = Mispronunciation.new respond_to do |format| format.html # new.html.erb format.json { render :json => @mispronunciation } end end
[ "def create\n @mispronunciation = Mispronunciation.new(params[:mispronunciation])\n\n respond_to do |format|\n if @mispronunciation.save\n format.html { redirect_to @mispronunciation, :notice => 'Mispronunciation was successfully created.' }\n format.json { render :json => @mispronunciation...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /mispronunciations POST /mispronunciations.json
def create @mispronunciation = Mispronunciation.new(params[:mispronunciation]) respond_to do |format| if @mispronunciation.save format.html { redirect_to @mispronunciation, :notice => 'Mispronunciation was successfully created.' } format.json { render :json => @mispronunciation, :status =...
[ "def destroy\n @mispronunciation = Mispronunciation.find(params[:id])\n @mispronunciation.destroy\n\n respond_to do |format|\n format.html { redirect_to mispronunciations_url }\n format.json { head :no_content }\n end\n end", "def new\n @mispronunciation = Mispronunciation.new\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /mispronunciations/1 PUT /mispronunciations/1.json
def update @mispronunciation = Mispronunciation.find(params[:id]) respond_to do |format| if @mispronunciation.update_attributes(params[:mispronunciation]) format.html { redirect_to @mispronunciation, :notice => 'Mispronunciation was successfully updated.' } format.json { head :no_content ...
[ "def destroy\n @mispronunciation = Mispronunciation.find(params[:id])\n @mispronunciation.destroy\n\n respond_to do |format|\n format.html { redirect_to mispronunciations_url }\n format.json { head :no_content }\n end\n end", "def create\n @mispronunciation = Mispronunciation.new(params[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /mispronunciations/1 DELETE /mispronunciations/1.json
def destroy @mispronunciation = Mispronunciation.find(params[:id]) @mispronunciation.destroy respond_to do |format| format.html { redirect_to mispronunciations_url } format.json { head :no_content } end end
[ "def destroy\n @abreviation = Abreviation.find(params[:id])\n @abreviation.destroy\n\n respond_to do |format|\n format.html { redirect_to abreviations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nomenclature.destroy\n respond_to do |format|\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Work out review stars
def indesign_review_stars( article ) if article.review? && (article.review_rating.to_i > 0) text = "<ParaStyle:Reviews\\:Review Rating>" text << (0..article.review_rating.to_i-1).collect{|n| "r"}.join return text.html_safe else return "" end end
[ "def stars\r\n Review.convert_points_to_stars points\r\n end", "def rate stars, person, review\n \tif stars > 5\n \t\tstars = 5\n \telsif stars < 0\n \t\tstars = 0\n \tend\n \t@ratings[person] = [stars, review]\n end", "def average_star_rating\n number = reviews.count\n total = reviews.reduce(0...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
monkey_trouble? We have two monkeys, a and b, and the parameters a_smile and b_smile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble. ==== Attributes a_smile true only if monkey a is smiling b_smile true only if monkey b is smili...
def monkey_trouble?(a_smile, b_smile) (a_smile && b_smile) || ( !a_smile && !b_smile) end
[ "def monkey_trouble? (a_smile, b_smile)\n\tif a_smile\n\t\treturn false\n\tend\n\n\tif b_smile\n\t\treturn false\n\tend\n\n\tif a_smile\n\t\tif b_smile\n\t\t\treturn true\n\t\tend\n\tend\n\n\tif !a_smile\n\t\tif !b_smile\n\t\t\treturn true\n\t\tend\n\tend\n\nend", "def monkey_trouble(a_smile, b_smile)\n a_sm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
sum_double Given two int values, return their sum. Unless the two values are the same, then return double their sum. ==== Attributes a an integer b an integer TODO write sum_double
def sum_double(a, b) if (a != b) a+b else 2 * (a + b) end end
[ "def sum_double(a, b)\n\tif a == b\n\t\treturn 2*(a+b)\n\tend\n\treturn a + b\nend", "def sum_double(val_a, val_b)\n # (a == b) ? 2 * (a + b) : (a + b)\n (val_a + val_b) * (val_a == val_b ? 2 : 1)\n end", "def sum_double (a,b)\n\t\n\tif a != b \n\t\treturn a + b \n\tend \n\n\tif a = b \n\t\treturn ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds 1 or more commands to the cron tab commands can be a string or an array period should be a valid crontab period use_sudo can be set to true if you want to edit the root crontab.
def add_to_crontab(commands,period,use_sudo=false) send_cmd = use_sudo ? :sudo : :run tmp_cron="/tmp/cron.tmp" self.send(send_cmd, "rm -f #{tmp_cron} && touch #{tmp_cron}") run "(#{use_sudo ? 'sudo ' : ''}crontab -l || true) > #{tmp_cron}" cron_lines = [*commands].map{|cmd| "#{period} #{cmd}"} add_to_file(t...
[ "def sudo_add_to_crontab(commands,period)\n add_to_crontab(commands, period, true)\nend", "def add_crons crons\n end", "def create_cron\n cron_edit = CronEdit.new\n command = cron_edit.add_command create_cron_command, Environment.ruby\n puts \"--> added command to cron\"\n puts \" #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds 1 or more commands to the cron tab of root commands can be a string or an array period should be a valid crontab period
def sudo_add_to_crontab(commands,period) add_to_crontab(commands, period, true) end
[ "def add_to_crontab(commands,period,use_sudo=false)\n send_cmd = use_sudo ? :sudo : :run\n tmp_cron=\"/tmp/cron.tmp\"\n self.send(send_cmd, \"rm -f #{tmp_cron} && touch #{tmp_cron}\")\n run \"(#{use_sudo ? 'sudo ' : ''}crontab -l || true) > #{tmp_cron}\"\n cron_lines = [*commands].map{|cmd| \"#{period} #{cmd}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.waitlist_mailer.product_sold.subject
def product_sold @greeting = "Hi" mail to: "to@example.org" end
[ "def subject_for(key)\n I18n.t(:subject, scope: [:mailer, key])\n end", "def subject_for\n ActiveSupport::Deprecation.warn \"subject_for\"\n I18n.t(:\"subject\", scope: [:notifications, :mailer],\n default: [:subject])\n end", "def deliver_invitation(options = {})\n super...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check data: make sure various types are known and have corresponding organization category set.
def checkData(dbName) @db = @conn[dbName] @edorg_collection = @db[EDORG_COLLECTION] @edorg_collection.find.each do |row| type = row[TYPE_FIELD] body = row[BODY_FIELD] orgcats = body[ORGCAT_FIELD] if type == TYPE_VALUE_SCHOOL and not orgcats.include?(ORGCAT_VALUE_SCHOOL) puts("Error: missing...
[ "def verify_types(test_data)\n test_types = test_data[CoreOrgData::ORG_RECORD_TYPES.name]\n errors = []\n test_types = [{CoreOrgData::ORG_RECORD_TYPE.name => ''}] unless test_types\n test_types.each do |test_type|\n index = test_types.index test_type\n text_values_match?(test_type[CoreOrgData:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializer, which will register the file format and save any options given as a hash. format:: The file format instance options:: A hash of options that can be used by a specific Source implementation
def initialize(format, options = {}) @options = options @file_format = format end
[ "def initialize(format, options = {})\n @file_format = format\n @options = options\n end", "def initialize(format, options = {}) \n @line_definitions = {}\n @options = options\n @source_files = options[:source_files]\n @parsed_requests = 0\n @requests ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function is called to actually produce the requests that will be send into the pipeline. The implementation should yield instances of RequestLogAnalyzer::Request. options:: A Hash of options that can be used in the implementation.
def each_request(options = {}, &block) # :yields: request return true end
[ "def each_request(options = {}, &block) # :yields: :request, request\n\n case @source_files\n when IO\n if @source_files == $stdin\n puts \"Parsing from the standard input. Press CTRL+C to finish.\" # FIXME: not here\n end\n parse_stream(@source_files, options, &block)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Was the transaction cancelled? Unfortunately, we can't distinguish "user abort" from "idle too long".
def cancelled? status_code == 'ABORT' end
[ "def cancelled?\n status_code == 'ABORT'\n end", "def cancelled?\n cancelled\n end", "def cancelled?\n return @cancelled\n end", "def canceled?\n @state == :cancel\n end", "def is_cancelled\n return @is_cancelled\n end", "def cancel?\n s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Authorization number (only if completed?).
def auth_id params['TxAuthNo'] end
[ "def add_authorization_number(params, authorization)\n return params.merge!(:vpc_TransactionNo => authorization)\n end", "def authorization_status\n @json_body['authorization_status']\n end", "def delete_authorization(number)\n delete(\"/authorizations/#{number}\", {}, 3, true, true)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Was the Gift Aid box checked?
def gift_aid? params['GiftAid'] == '1' end
[ "def active_check_box\n active?\n end", "def is_checked(locator)\n return get_boolean(\"isChecked\", [locator,])\n end", "def check\n get_checkbox.check\n end", "def is_checked\n return @is_checked\n end", "def add_monogram_checked?\n add_mg_sec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Result of 3D Secure checks. Possible values: OK:: Authenticated correctly. NOTCHECKED:: Authentication not performed. NOTAVAILABLE:: Card not authcapable, or auth is otherwise impossible. NOTAUTHED:: User failed authentication. INCOMPLETE:: Authentication unable to complete. ERROR:: Unable to attempt authentication due...
def buyer_auth_result params['3DSecureStatus'] end
[ "def buyer_auth_result\n params['3DSecureStatus']\n end", "def check_card_3d_secure(params)\n connection('3DSecure/checkCard')\n request_method('get', params)\n end", "def support_3des_auth?\n # Ask for authentication\n buffer = [CMD_3DES_AUTH, 0x00]\n\n begin\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Last four digits of credit card.
def credit_card_last_4_digits params['Last4Digits'] end
[ "def card_number_last_four_digits\n hash[\"CardNumberLastFourDigits\"]\n end", "def last_four\n @card_number.chars.last(4).join\n end", "def credit_card_last_4_digits\n params['Last4Digits']\n end", "def last_four\n card_number.slice(-4,4)\n end", "def last_four\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the full name of the character, including the prefix and suffix. character.full_name => "Adries the Explorer"
def full_name [prefix, name, suffix].join("") end
[ "def full_name\n \"#{prename} #{name}\"\n end", "def full_name\n self.name ? \"#{self.name.split(' ')[0..-2].join(' ')}, #{self.name.split(' ')[-1]}\" : ''\n end", "def full_name\n return \"#{first_name} #{last_name}\"\n end", "def full_name\n name\n end", "def full_name\n if original...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public : Helper method for the ApiFaultDetail constructor to initialize the batch errors array
def initialize_batch_errors(batch_errors_hash) return if batch_errors_hash.nil? if batch_errors_hash[:batch_error].is_a?(Array) self.batch_errors = [] batch_errors_hash[:batch_error].each do |be| self.batch_errors << init_batch_error(be) end elsif batch_errors_hash[:batch_error].is...
[ "def initialize_batch_errors(batch_errors_hash)\n\t\t\t\treturn if batch_errors_hash.nil?\n\t\t\t\t\n\t\t\t\tif batch_errors_hash[:batch_error].is_a?(Array)\n\t\t\t\t\tself.batch_errors = []\n\t\t\t\t\tbatch_errors_hash[:batch_error].each do |be|\n\t\t\t\t\t\tself.batch_errors << BingAdsApi::BatchError.new(be)\n\t\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dataset Action :pull_result_hooks([], [res]) Pull the hook specific to the type of result
def hook__pull_result_hooks(_hook_args, event_args) pull_hook(:"on_result_ready_#{event_args.first}", *event_args) pull_hook(:on_processing_ready) if next_task(nil, false).nil? end
[ "def hook__pull_result_hooks(_hook_args, event_args)\n pull_hook(:\"on_result_ready_#{event_args.first}\", *event_args)\n pull_hook(:on_preprocessing_ready) if done_preprocessing?\n end", "def run_after_each_hooks( env, result )\n hooks = env[:hooks][:after_each]\n hooks += env[:hooks][:after_sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check existent WMID or not Params: wmid
def wmid_exist?(wmid) request(:find_wm, :wmid => Wmid.new(wmid))[:retval] == 1 end
[ "def wmid\n # memoize\n @wmid ||=\n begin\n res = @@worker.request(:find_wm, :purse => self, :wmid => \"\")\n res[:retval] == 1 ? Wmid.new(res[:wmid]) : nil\n end\n end", "def pid_hwm(pid)\n res = `grep \"VmHWM\" /proc/#{pid}/status`.split[1]\n if res.match(\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generic function for request to WMTinterfaces
def request(iface, opt ={}) raise ArgumentError, "should be hash" unless opt.kind_of?(Hash) # Use self wmid when not defined opt[:wmid] ||= @wmid # Do request res = https_request(iface, make_xml(iface, opt)) # Parse response doc = Nokogiri::XML(res) parse_retval(iface, doc) make_r...
[ "def getHttpService; raise NotImplementedError; end", "def extended_interfaces; end", "def getServiceTypes( )\n\n # parameter TypeCheck\n\n # BIMserver request\n request( { } )\n end", "def included_interfaces; end", "def method_missing(method_name, *args, &block)\n RTSP::Server.log...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current track
def current_track reload @tracks[@current_track_index] end
[ "def current_track\n IITTrack.new(@ole.CurrentTrack)\n end", "def current_track\n if @_itunes_api == :win32ole\n tmp_track = @_itunes.currenttrack\n elsif @_itunes_api == :appscript\n tmp_track = @_itunes.current_track.get\n else\n tmp_track = @_itunes.current_track\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current track index
def current_track_index reload @current_track_index end
[ "def current_track\n reload\n @tracks[@current_track_index]\n end", "def nextTrack(current_track)\n if current_track == @tracks.length() - 1\n return 0\n else \n return current_track + 1\n end\n end", "def current_index\n @players[current_player][0]\n end", "def track_numb...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the current track index
def current_track_index=(index) reload @current_track_index = index save end
[ "def current_track_index\n reload\n @current_track_index\n end", "def index=(i) @index=i end", "def index=(value)\n @index = value\n end", "def set_track_num(track_num)\n @number = track_num\n end", "def index=(new_index)\n @index = new_index\n @index = @pages.size-1 if @index...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returs the tracks in this playlist
def tracks reload @tracks end
[ "def play!\n @playlist.shift\n end", "def tracks\n return @tracks\n end", "def index\n @playlists_tracks = PlaylistsTrack.all\n end", "def tracks(params={})\n tracks = { 'items' => [] }\n path = \"/v1/users/#{user_id}/playlists/#{id}/tracks\"\n\n while path\n response = c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the track immediately preceding the current track in this playlist
def previous_track reload (@current_track_index > 0 ? @tracks[@current_track_index - 1] : nil) end
[ "def previous_track()\n @ole.PreviousTrack()\n end", "def previous\n video = playlist.previous\n play(video) if video\n video\n end", "def preceding\n return LessonPart.find_by(lesson: lesson, ordinal: ordinal - 1) unless ordinal == 1\n # if this LessonPart has an ordinal of 1, t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
= main = Traitement principal de la commande 'taches'
def exec_commande_taches # On affiche toujours la liste des tâches clear taches.wait_for_choix_and_execute end
[ "def add_protein_removal_reagent\n show do\n title \"Add Protein Removal Reagent\"\n\n check \"Add 200 #{MICROLITERS} of Protein Removal Reagent to each #{TUBE_MICROFUGE}.\"\n note \"Mix by inverting each tube several times.\"\n note \"Centrifuge at 13,000 g for 5 minutes at room temperature...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wraps the rendered content in a replace statement targeted at your +Apotomo.js_framework+ setting. Use +:selector+ to change the selector. Example: Assuming you set Apotomo.js_framework = :jquery and call replace in a state replace :view => :squeak, :selector => "divmouse" => "$(\"divmouse\").replaceWith(\"squeak!\")"
def replace(options={}) content = render(options) Apotomo.js_generator.replace(options[:selector] || self.name, content) end
[ "def selector_replace(selector, original, replacement); end", "def replace(replace, html)\n function = {:inner =>\"update\",:outer => 'replace'}[replace.to_sym]\n invoke [function, escape_javascript(html)]\n end", "def replace(*args)\n wrap_in_javascript_for(:replace, *args)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the widget named widget_id as long as it is below self or self itself.
def find_widget(widget_id) find {|node| node.name.to_s == widget_id.to_s} end
[ "def get_widget_instance(widget_id)\n get_widget_instances.select{|instance| widget_id == (instance.get_param(\"widget_instance_id\").to_s)}.first\n end", "def widget_id\n controller.name\n end", "def item_for widget\n each do |e|\n if e.is_a? Item\n if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /ingredient_assignments/1 GET /ingredient_assignments/1.json
def show @ingredient_assignment = IngredientAssignment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @ingredient_assignment } end end
[ "def new\n @ingredient_assignment = IngredientAssignment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredient_assignment }\n end\n end", "def create\n @ingredient_assignment = IngredientAssignment.new(params[:ingredient_assignment])\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /ingredient_assignments/new GET /ingredient_assignments/new.json
def new @ingredient_assignment = IngredientAssignment.new respond_to do |format| format.html # new.html.erb format.json { render json: @ingredient_assignment } end end
[ "def create\n @ingredient_assignment = IngredientAssignment.new(params[:ingredient_assignment])\n\n respond_to do |format|\n if @ingredient_assignment.save\n format.html { redirect_to @ingredient_assignment, notice: 'Ingredient assignment was successfully created.' }\n format.json { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ingredient_assignments POST /ingredient_assignments.json
def create @ingredient_assignment = IngredientAssignment.new(params[:ingredient_assignment]) respond_to do |format| if @ingredient_assignment.save format.html { redirect_to @ingredient_assignment, notice: 'Ingredient assignment was successfully created.' } format.json { render json: @ingr...
[ "def new\n @ingredient_assignment = IngredientAssignment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredient_assignment }\n end\n end", "def create\n\n user = UserSession.user_by_authentication_token(params[:id])\n names = params[:ingredie...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /ingredient_assignments/1 PUT /ingredient_assignments/1.json
def update @ingredient_assignment = IngredientAssignment.find(params[:id]) respond_to do |format| if @ingredient_assignment.update_attributes(params[:ingredient_assignment]) format.html { redirect_to @ingredient_assignment, notice: 'Ingredient assignment was successfully updated.' } forma...
[ "def create\n @ingredient_assignment = IngredientAssignment.new(params[:ingredient_assignment])\n\n respond_to do |format|\n if @ingredient_assignment.save\n format.html { redirect_to @ingredient_assignment, notice: 'Ingredient assignment was successfully created.' }\n format.json { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /ingredient_assignments/1 DELETE /ingredient_assignments/1.json
def destroy @ingredient_assignment = IngredientAssignment.find(params[:id]) @ingredient_assignment.destroy respond_to do |format| format.html { redirect_to ingredient_assignments_url } format.json { head :ok } end end
[ "def destroy\n @needed_ingredient = NeededIngredient.find(params[:id])\n @needed_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to home_url }\n format.json { head :ok }\n end\n end", "def destroy\n @recipe = Recipe.find(params[:recipe_id])\n @used_ingredient = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
read the github file and spit out a slightly formatted list of patterns and their owners Empty/invalid/commented lines are still included in order to preserve line numbering
def pattern_owners codeowner_path = search_codeowners_file patterns = [] File.read(codeowner_path).split("\n").each_with_index { |line, i| path_owner = line.split(/\s+@/, 2) if line.match(/^\s*(?:#.*)?$/) patterns.push ['', ''] # Comment/empty line elsif path_owner.le...
[ "def pattern_owners(codeowner_data, opts = {})\n patterns = []\n codeowner_data.split(\"\\n\").each_with_index do |line, i|\n stripped_line = line.strip\n if stripped_line == \"\" || stripped_line.start_with?(\"#\")\n patterns << ['', ''] # Comment / empty line\n\n elsif stri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /frbr_manifestations GET /frbr_manifestations.json
def index screen_name("Admin-Indice-Manifestaciones-FRBR") @frbr_manifestations = FrbrManifestation.all respond_to do |format| format.html # index.html.erb format.json { render json: @frbr_manifestations } end end
[ "def manifests\n api.get('manifests')\n end", "def show\n screen_name(\"Admin-Mostrar-Manifestacion-FRBR\")\n @frbr_manifestation = FrbrManifestation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @frbr_manifestation }\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /frbr_manifestations/1 GET /frbr_manifestations/1.json
def show screen_name("Admin-Mostrar-Manifestacion-FRBR") @frbr_manifestation = FrbrManifestation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @frbr_manifestation } end end
[ "def index\n screen_name(\"Admin-Indice-Manifestaciones-FRBR\")\n @frbr_manifestations = FrbrManifestation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @frbr_manifestations }\n end\n end", "def show\n @manifest = Manifest.find(params[:id])\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /frbr_manifestations/new GET /frbr_manifestations/new.json
def new screen_name("Admin-Nuevo-Manifestacion-FRBR") @frbr_manifestation = FrbrManifestation.new respond_to do |format| format.html # new.html.erb format.json { render json: @frbr_manifestation } end end
[ "def new\n @manifest = Manifest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manifest }\n end\n end", "def new\n @manifestation_type = ManifestationType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /frbr_manifestations POST /frbr_manifestations.json
def create @frbr_manifestation = FrbrManifestation.new(params[:frbr_manifestation]) respond_to do |format| if @frbr_manifestation.save format.html { redirect_to @frbr_manifestation, notice: 'Frbr manifestation was successfully created.' } format.json { render json: @frbr_manifestation, st...
[ "def create\n @manifest = Manifest.new(params[:manifest])\n\n respond_to do |format|\n if @manifest.save\n format.html { redirect_to @manifest, :notice => 'Manifest was successfully created.' }\n format.json { render :json => @manifest, :status => :created, :location => @manifest }\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /frbr_manifestations/1 PUT /frbr_manifestations/1.json
def update @frbr_manifestation = FrbrManifestation.find(params[:id]) respond_to do |format| if @frbr_manifestation.update_attributes(params[:frbr_manifestation]) format.html { redirect_to @frbr_manifestation, notice: 'Frbr manifestation was successfully updated.' } format.json { head :ok ...
[ "def update\n respond_to do |format|\n if @manifest.update(manifest_params)\n format.html { redirect_to @manifest, notice: 'Manifest was successfully updated.' }\n format.json { render :show, status: :ok, location: @manifest }\n else\n format.html { render :edit }\n format.j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /frbr_manifestations/1 DELETE /frbr_manifestations/1.json
def destroy @frbr_manifestation = FrbrManifestation.find(params[:id]) @frbr_manifestation.destroy respond_to do |format| format.html { redirect_to frbr_manifestations_url } format.json { head :ok } end end
[ "def destroy\n @manifest = Manifest.find(params[:id])\n @manifest.destroy\n\n respond_to do |format|\n format.html { redirect_to manifests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @manifest = Manifest.find(params[:id])\n @manifest.destroy\n\n respond_to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /renting_phases GET /renting_phases.json
def index @renting_phases = RentingPhase.all end
[ "def index\n @phases = Phase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @phases }\n end\n end", "def index\n @phases = Phase.all\n end", "def phases\n Phase.where(edition_id: id)\n end", "def index\n @phases = Phase.where(proje...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /renting_phases POST /renting_phases.json
def create @renting_phase = RentingPhase.new(renting_phase_params) respond_to do |format| if @renting_phase.save format.html { redirect_to @renting_phase, notice: 'Renting phase was successfully created.' } format.json { render :show, status: :created, location: @renting_phase } els...
[ "def create\n @phase = Phase.new(phase_params)\n\n respond_to do |format|\n if @phase.save\n format.html { redirect_to @phase, notice: 'Phase was successfully created.' }\n format.json { render :show, status: :created, location: @phase }\n else\n format.html { render :new }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /renting_phases/1 PATCH/PUT /renting_phases/1.json
def update respond_to do |format| if @renting_phase.update(renting_phase_params) format.html { redirect_to @renting_phase, notice: 'Renting phase was successfully updated.' } format.json { render :show, status: :ok, location: @renting_phase } else format.html { render :edit } ...
[ "def update\n respond_to do |format|\n if @phase.update(phase_params)\n format.html\n format.json { render :nothing => true }\n else\n format.html { render :edit }\n format.json { render json: @phase.errors, status: :unprocessable_entity }\n end\n end\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /renting_phases/1 DELETE /renting_phases/1.json
def destroy @renting_phase.destroy respond_to do |format| format.html { redirect_to renting_phases_url, notice: 'Renting phase was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @phase = Phase.find(params[:id])\n @phase.destroy\n\n respond_to do |format|\n format.html { render :layout => false }\n format.json { head :no_content }\n end\n end", "def destroy\n @phase.destroy\n respond_to do |format|\n format.html { redirect_to project_phases...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert row, column indices to the corresponding alphanumumeric coordinate
def rc_to_alphanum(row:, column:) index_to_letter(row) + (column + 1).to_s end
[ "def indices2coords(i,j)\n row = i2row(i)\n col = j2col(j)\n \"#{row}#{col}\"\n end", "def indices_to_address( row_idx, column_idx )\n [ row_idx, column_idx ].all? { |a| a.is_a?( Fixnum ) } or fail ArgumentError, 'Input must be Fixnum'\n col_letter( column_idx ) + row_idx.to_s\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert a letter to the corresponding array index
def letter_to_index(letter) alphabet_array.index(letter.upcase) end
[ "def letter_to_index(letter)\n ALPHA26.index(letter.upcase)\n end", "def index_to_letter(index)\n alphabet_array[index]\n end", "def index_to_letter(index)\n ALPHA26[index]\n end", "def letters_to_index(letters)\n sum = 0\n letters.split(\"\").each_with_index do |letter, i|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert an array index to the corresponding letter of the alphabet
def index_to_letter(index) alphabet_array[index] end
[ "def index_to_letter(index)\n ALPHA26[index]\n end", "def letter_to_index(letter)\n alphabet_array.index(letter.upcase)\n end", "def next_letter(name_array)\n\tvowels = \"aeiou\"\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\tindex = 0\n\tname_array.map { |name|\n\t\tname.map {|letter|\n\t\t\tif vowels.in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Array of all letters of the alphablet in uppercase
def alphabet_array ('A'..'Z').to_a end
[ "def all_letters_capitalized(chars)\n chars.map {|string| string.upcase}\nend", "def letters\n the_letters = []\n letter_regex = /[a-z]/i\n chars.each do |character|\n the_letters << character if character.match(letter_regex)\n end\n the_letters.join\n end", "def alphabetic_chars\n non_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the alpha component of an alphanumumeric coordinate
def alpha_component(alphanum) mtch = alphanum.match(/[[:alpha:]]+/) return mtch[0] if mtch end
[ "def alpha_string\n alpha.round(8).to_s\n end", "def alpha\n return @alpha\n end", "def get_alpha\n\t if alpha?\n\t extract_band bands - 1\n\t else\n\t # make a 255 (opaque) alpha for it\n\t ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the numeric component of an alphanumumeric coordinate
def numeric_component(alphanum) mtch = alphanum.match(/\d+/) return mtch[0].to_i if mtch end
[ "def an_numeric_component\n @record.eds_accession_number.split('.').last\n end", "def split_coord(s)\n letter = \"\"\n number = 0\n i = 0\n while i<s.length and \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\".include?(s[i,1])\n letter += s[i,1]\n i+=1\n end\n while i<s.len...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Associates the provided data to the next `PlateLayoutGenerator` group that does not point to any `Part` that already has a `DataAssociation` for `key` and returns the group
def associate_next_empty_group(key:, data:, column: nil) nxt_grp = next_empty_group(key: key, column: column) associate_group(group: nxt_grp, key: key, data: data) nxt_grp end
[ "def associate_provenance_next_empty_group(key:, data:, column: nil)\n nxt_grp = next_empty_group(key: key, column: column)\n associate_provenance_group(group: nxt_grp, key: key, data: data)\n nxt_grp\n end", "def next_empty_group(key:, column: nil)\n nxt_grp = nil\n loop do\n present = false...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses `PartProvenance` to associate the the provided provenance data to the next `PlateLayoutGenerator` index that does not point to a `Part` that already has a `DataAssociation` for `key` and returns the index
def associate_provenance_next_empty(key:, data:, column: nil) nxt = next_empty(key: key, column: column) associate_provenance(index: nxt, key: key, data: data) nxt end
[ "def associate_provenance(index:, key:, data:)\n to_item = @collection.part(index[0], index[1])\n data.each do |datum|\n # Make sure you aren't modifying a shared data structure\n datum = datum.dup\n from_item = datum.delete(:item)\n next unless from_item\n\n add_one_to_one_provenance...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses `PartProvenance` to associate the the provided provenance data to the next `PlateLayoutGenerator` group that does not point to any `Part` that already has a `DataAssociation` for `key` and returns the group
def associate_provenance_next_empty_group(key:, data:, column: nil) nxt_grp = next_empty_group(key: key, column: column) associate_provenance_group(group: nxt_grp, key: key, data: data) nxt_grp end
[ "def associate_provenance_group(group:, key:, data:)\n group.each { |i| associate_provenance(index: i, key: key, data: data) }\n end", "def next_empty_group(key:, column: nil)\n nxt_grp = nil\n loop do\n present = false\n nxt_grp = @plate_layout_generator.next_group(column: column)\n nxt_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the next `PlateLayoutGenerator` index that does not point to a `Part` that already has a `DataAssociation` for `key`
def next_empty(key:, column: nil) nxt = nil loop do nxt = @plate_layout_generator.next(column: column) prt = @collection.part(nxt[0], nxt[1]) break unless prt.associations[key].present? end nxt end
[ "def next_empty_group(key:, column: nil)\n nxt_grp = nil\n loop do\n present = false\n nxt_grp = @plate_layout_generator.next_group(column: column)\n nxt_grp.each do |nxt|\n prt = @collection.part(nxt[0], nxt[1])\n present = true if prt.associations[key].present?\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the next `PlateLayoutGenerator` group that does not point to any `Part` that already has a `DataAssociation` for `key`
def next_empty_group(key:, column: nil) nxt_grp = nil loop do present = false nxt_grp = @plate_layout_generator.next_group(column: column) nxt_grp.each do |nxt| prt = @collection.part(nxt[0], nxt[1]) present = true if prt.associations[key].present? end break unless ...
[ "def next_empty(key:, column: nil)\n nxt = nil\n loop do\n nxt = @plate_layout_generator.next(column: column)\n prt = @collection.part(nxt[0], nxt[1])\n break unless prt.associations[key].present?\n end\n nxt\n end", "def associate_provenance_next_empty_group(key:, data:, column: nil)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Associates the provided data to indices of the provided group
def associate_group(group:, key:, data:) group.each { |i| associate(index: i, key: key, data: data) } end
[ "def associate_provenance_group(group:, key:, data:)\n group.each { |i| associate_provenance(index: i, key: key, data: data) }\n end", "def indexer(entities, group_key, index_key)\n indexes =\n Hash[entities.group_by { |e| e[group_key] }\n .map { |g, es| [g, es.map { |e| e[index_key]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses `PartProvenance` to associate the provided provenance data to indices of the provided group
def associate_provenance_group(group:, key:, data:) group.each { |i| associate_provenance(index: i, key: key, data: data) } end
[ "def associate_provenance(index:, key:, data:)\n to_item = @collection.part(index[0], index[1])\n data.each do |datum|\n # Make sure you aren't modifying a shared data structure\n datum = datum.dup\n from_item = datum.delete(:item)\n next unless from_item\n\n add_one_to_one_provenance...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses `PartProvenance` to associate the provided provenance data to a part
def associate_provenance(index:, key:, data:) to_item = @collection.part(index[0], index[1]) data.each do |datum| # Make sure you aren't modifying a shared data structure datum = datum.dup from_item = datum.delete(:item) next unless from_item add_one_to_one_provenance( fro...
[ "def add_provenance(microtiter_plate:, pooling_groups:)\n pooling_groups.each do |pooling_group|\n microtiter_plate.associate_provenance_next_empty(\n key: :specimens,\n data: pooling_group.map { |item| hash_data(item) }\n )\n end\n microtiter_plate\n end", "def add_provenance(op...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add provenance data to a sourcedestination pair of items
def add_one_to_one_provenance(from_item:, to_item:, additional_relation_data: nil) from_map = AssociationMap.new(from_item) to_map = AssociationMap.new(to_item) add_provenance( from: from_item, from_map: from_map, to: to_item, to_map: to_map, additional_rel...
[ "def add_provenance(opts = {})\n if opts[:from] == opts[:to] # special case: provenance between two parts on the same collection\n opts[:from_map] = opts[:to_map] # ensure from map and to map are the same object for this case\n end\n\n # creating information hashes to represent `from` and `to` relatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }