query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Determines if the given body matches the signature.
def verify_content(body, signature) hmac = HMAC::SHA1.hexdigest(@secret, body) check = "sha1=" + hmac check == signature end
[ "def matches_signature(signature)\n @signature == signature\n end", "def validate_body(body, request_headers)\n signature = get_header_value(request_headers, HEADER_SIGNATURE)\n key_id = get_header_value(request_headers, HEADER_KEY_ID)\n secret_key = @secret_key_store.get_secret_key(k...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives the content of a challenge response given the challenge body.
def challenge_response(challenge_code) { :body => challenge_code, :status => 200 } end
[ "def challenge\n decode_challenge\n respond\n end", "def challenge\n @challenge = decode_challenge\n respond\n end", "def respond_to_challenge(request, response)\n authenticate_header = response['www-authenticate'].downcase\n authenticate_header.sub!(/^diges...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /article_comments/1 GET /article_comments/1.xml
def show @article_comment = ArticleComment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @article_comment } end end
[ "def show\n @article_comments = Admin::ArticleComments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @article_comments }\n end\n end", "def index\n params[:article_id].present? ? @comments = Article.find(params[:article_id]).co...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /article_comments/new GET /article_comments/new.xml
def new @article_comment = ArticleComment.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @article_comment } end end
[ "def new\n @newcomment = Newcomment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newcomment }\n end\n end", "def new\n @comment = @story.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :x...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /article_comments POST /article_comments.xml
def create @article = Article.find(params[:article_id]) @article_comment = @article.article_comments.build() @article_comment.content = params[:replyContent] respond_to do |format| if @article_comment.save #format.html { redirect_to @article, :anchor => 'comment' } format.html { r...
[ "def create\n @article_comments = Admin::ArticleComments.new(params[:article_comments])\n\n respond_to do |format|\n if @article_comments.save\n flash[:notice] = 'Admin::ArticleComments was successfully created.'\n format.html { redirect_to(@article_comments) }\n format.xml { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /article_comments/1 PUT /article_comments/1.xml
def update @article_comment = ArticleComment.find(params[:id]) respond_to do |format| if @article_comment.update_attributes(params[:article_comment]) format.html { redirect_to(@article_comment, :notice => 'Article comment was successfully updated.') } format.xml { head :ok } else ...
[ "def update\n @article_comments = Admin::ArticleComments.find(params[:id])\n\n respond_to do |format|\n if @article_comments.update_attributes(params[:article_comments])\n flash[:notice] = 'Admin::ArticleComments was successfully updated.'\n format.html { redirect_to(@article_comments) }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /article_comments/1 DELETE /article_comments/1.xml
def destroy @article_comment = ArticleComment.find(params[:id]) @article_comment.destroy respond_to do |format| format.html { redirect_to(article_comments_url) } format.xml { head :ok } end end
[ "def destroy\n Comment.delete_all(\"article_id = #{params[:id]}\")\n Article.find(params[:id]).destroy\n\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article_comments = Admin::ArticleComments.find(params[:id])\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add_student(db, "Bob") methoad to add a subject
def add_subject(database, name) database.execute("INSERT INTO subjects (name) VALUES (?)", [name]) end
[ "def add_student_to_course(student_id, name, email)\n if Student.find_by_email(email)\n student = Student.find_by_email(email)\n else\n student = Student.new\n student.email = email\n student.student_id = student_id\n student.name = name\n student.university = Faculty.find(faculty_id).university...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add_subject(db, "Math") add_subject(db, "English") add_subject(db, "Physics") add_subject(db, "Art") add_subject(db, "Chemistry") method to add a grade
def add_grade(database, student_id, subject_id, grade) database.execute("INSERT INTO grades (grade, student_id, subject_id) VALUES (?, ?, ?)", [grade, student_id, subject_id]) end
[ "def add_grade(subject, score)\n grade = Grade.new(subject, score)\n if @grades[grade.subject]\n raise \"Sorry, you cannot add or change #{grade.subject} because it was already entered.\"\n end\n @grades[grade.subject] = grade.score\n end", "def update_subject_grade(all_grades,cid)\n curr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add_grade(db, 1, 1, 80) method to update a grade
def update_grade(database, student, subject, grade) student_id = get_student_id(database, student) subject_id = get_subject_id(database, subject) database.execute("UPDATE grades SET grade=? WHERE student_id=? AND subject_id=?",[grade, student_id, subject_id]) end
[ "def add_grade(database, student_id, subject_id, grade)\r\n\tdatabase.execute(\"INSERT INTO grades (grade, student_id, subject_id) VALUES (?, ?, ?)\", [grade, student_id, subject_id])\r\nend", "def enter_grade(entry,grade)\n edit_uri=''\n entry.add_namespace('http://www.w3.org/2005/Atom')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
p get_student_id(db, "Bob") method to get subject id
def get_subject_id(database, name) subject = database.execute("SELECT * FROM subjects WHERE name=?",[name]) subject_id = subject[0][0].to_i end
[ "def get_ID\n @studentID\n end", "def student_id\n @net_ldap_entry[:berkeleyedustuid].first\n end", "def student_id\r\n\t\t\treturn 51875531\r\n\t\tend", "def subject_id\n raise ArgumentError, \"#subject_id not implemented for #{self.class}\"\n end", "def student_id\n curren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
display_students(db) method to display all subjects
def display_subjects(database) subjects = database.execute("SELECT * FROM subjects") subjects.each do |subject| puts "ID: #{subject[0]} Subject: #{subject[1]}" end end
[ "def display_students\n Student.all.each do |student|\n puts \"#{student.name.upcase}\".colorize(:blue)\n puts \" location:\".colorize(:light_blue) + \" #{student.location}\"\n puts \" profile quote:\".colorize(:light_blue) + \" #{student.profile_quote}\"\n puts \" bio:\".colorize(:light_b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
make sure the complete key is build using the options such as scope and count
def prepare_key(key, options) complete_key = key # if a scope is passed in options then build the full key complete_key = options[:scope].present? ? "#{options[:scope].to_s}.#{complete_key}" : complete_key # add the correct count suffix if options[:count].present? && options[:count] == 1 co...
[ "def require_master_key=(_arg0); end", "def reserve_key(key); end", "def require_master_key; end", "def build_key(options = {})\n options[:base] = options[:base]||self.class.to_s.downcase\n if (options[:key_pluralize_instances] == true ) || (options[:key_pluralize_instances] != false && self.class.key_p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
You can't proxy nil or false, so remove those possibilities if they're in the type.
def proxy_simplify ts = @types.dup.delete_if do |t| t.is_a? NominalType and (t.klass == NilClass or t.klass == FalseClass) end if ts.length == @types.length then self else if ts.length == 1 then ts.to_a[0] else Uni...
[ "def upcasted?\n false\n end", "def type_available\n type.property_names_to_types.map do |name, type|\n attr_accessor(name) unless method_defined?(name)\n alias_method(:\"#{name}?\", name) if type.excluding_null.is_a?(Type::Boolean)\n end\n end", "def nonregular_type; en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /hookups/1 DELETE /hookups/1.xml
def destroy @hookup = Hookup.find(params[:id]) @hookup.destroy respond_to do |format| format.html { redirect_to(hookups_url) } format.xml { head :ok } end end
[ "def delete_webhook\n send_request('deleteWebhook', {})\n end", "def delete_hook(id)\n delete(\"/hooks/#{id}\")\n end", "def destroy\n @hookup = Hookup.find(params[:id])\n @hookup.destroy\n\n respond_to do |format|\n format.html { redirect_to hookups_url }\n format.json { head...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /product_groups/1 GET /product_groups/1.json
def show @product_group = ProductGroup.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @product_group } end end
[ "def show\n @product_grouping = ProductGrouping.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_grouping }\n end\n end", "def index\n @product_product_groups = ProductProductGroup.all\n end", "def get_product_groups(params,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /product_groups/new GET /product_groups/new.json
def new @product_group = ProductGroup.new respond_to do |format| format.html # new.html.erb format.json { render json: @product_group } end end
[ "def new\n @product_grouping = ProductGrouping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_grouping }\n end\n end", "def new\n @group = scoped_groups.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /product_groups POST /product_groups.json
def create @product_group = ProductGroup.new(params[:product_group]) respond_to do |format| if @product_group.save format.html { redirect_to @product_group, notice: 'Product group was successfully created.' } format.json { render json: @product_group, status: :created, location: @product_...
[ "def create\n @product_group = ProductGroup.new(product_group_params)\n\n respond_to do |format|\n if @product_group.save\n format.html { redirect_to @product_group, notice: \"Product group was successfully created.\" }\n format.json { render :show, status: :created, location: @product_grou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /product_groups/1 PUT /product_groups/1.json
def update @product_group = ProductGroup.find(params[:id]) respond_to do |format| if @product_group.update_attributes(params[:product_group]) format.html { redirect_to @product_group, notice: 'Product group was successfully updated.' } format.json { head :no_content } else f...
[ "def update\n respond_to do |format|\n if @product_group.update(product_group_params)\n format.html { redirect_to @product_group, notice: \"Product group was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product_group }\n else\n format.html { rende...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /product_groups/1 DELETE /product_groups/1.json
def destroy @product_group = ProductGroup.find(params[:id]) @product_group.destroy respond_to do |format| format.html { redirect_to product_groups_url } format.json { head :no_content } end end
[ "def destroy\n @product_grouping = ProductGrouping.find(params[:id])\n @product_grouping.destroy\n\n respond_to do |format|\n format.html { redirect_to product_groupings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_product.destroy\n respond_to do |forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
pass in a user_id and period in params and it will find the next or previous fab
def cycle_fab_by_period(direction, params) user = User.find(params[:user_id]) current_fab = find_or_create_base_fab(user, params) @fab = (direction == :forward) ? current_fab.exactly_next_fab : current_fab.exactly_previous_fab end
[ "def determinate_next_page_by_period\n if vehicle_details('weekly_possible')\n select_period_dates_path(id: transaction_id)\n else\n daily_charge_dates_path(id: transaction_id)\n end\n end", "def upcoming_fab\n fabs.find_or_build_this_periods_fab\n end", "def one_user\n @user = User.f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
scores for each letter
def letter_scores { "A"=>1, "B"=>3, "C"=>3, "D"=>2, "E"=>1, "F"=>4, "G"=>2, "H"=>4, "I"=>1, "J"=>8, "K"=>5, "L"=>1, "M"=>3, "N"=>1, "O"=>1, "P"=>3, "Q"=>10, "R"=>1, "S"=>1, "T"=>1, "U"=>1, "V"=>4, "W"=>4, "X"=>8, "Y"=>4, "Z"=>10 } end
[ "def individual_letter_scores\n @scores ||= begin\n # every letter starts with a default score\n scores = Array.new text.length, DEFAULT_LETTER_SCORE\n\n # first letter of each \"word\" gets a bonus:\n\n # start of string\n scores[0] += START_OF_WORD_BONUS\n\n # words start after a ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a Scalyr log endpoint Create a Scalyr for a particular service and version.
def create_log_scalyr_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: LoggingScalyrApi.create_log_scalyr ...' end # unbox the parameters from the hash service_id = opts[:'service_id'] version_id = opts[:'version_id'] # v...
[ "def create_log_https_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LoggingHttpsApi.create_log_https ...'\n end\n # unbox the parameters from the hash\n service_id = opts[:'service_id']\n version_id = opts[:'version_id']\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update the Scalyr log endpoint Update the Scalyr for a particular service and version.
def update_log_scalyr(opts = {}) data, _status_code, _headers = update_log_scalyr_with_http_info(opts) data end
[ "def update_log_scalyr_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LoggingScalyrApi.update_log_scalyr ...'\n end\n # unbox the parameters from the hash\n service_id = opts[:'service_id']\n version_id = opts[:'version_id'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update the Scalyr log endpoint Update the Scalyr for a particular service and version.
def update_log_scalyr_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: LoggingScalyrApi.update_log_scalyr ...' end # unbox the parameters from the hash service_id = opts[:'service_id'] version_id = opts[:'version_id'] log...
[ "def update_log_scalyr(opts = {})\n data, _status_code, _headers = update_log_scalyr_with_http_info(opts)\n data\n end", "def update_log_https_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LoggingHttpsApi.update_log_https ...'\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a box given as a string of four numbers separated by commas.
def parse_box(key, box) if box.kind_of?(String) begin raw_box = box.split(",").map(&:to_f) box = [[raw_box[0], raw_box[1]], [raw_box[2], raw_box[3]]] rescue raise_error(type: "box.format", key: "key", value: box) end end return bo...
[ "def parse_mp4_box(cursor, box_names, hierarchy = [], max_cursor = nil, &proc)\n #log_debug \"=== @#{cursor} - Parsing #{@data[cursor..cursor+31].inspect} ...\"\n nbr_boxes = 0\n nbr_direct_subboxes = 0\n container_box_max_cursor = ((max_cursor == nil) ? @end_offset : max_cursor)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /folha/fonte_recursos/1 GET /folha/fonte_recursos/1.xml
def show @folha_fonte_recurso = Folha::FonteRecurso.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @folha_fonte_recurso } end end
[ "def new\n @folha_fonte_recurso = Folha::FonteRecurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @folha_fonte_recurso }\n end\n end", "def index\n @fontes_de_recurso = FonteDeRecurso.all\n end", "def index\n @ficha_tematicas = FichaTemat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /folha/fonte_recursos/new GET /folha/fonte_recursos/new.xml
def new @folha_fonte_recurso = Folha::FonteRecurso.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @folha_fonte_recurso } end end
[ "def new\n @receta = Receta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receta }\n end\n end", "def create\n @folha_fonte_recurso = Folha::FonteRecurso.new(params[:folha_fonte_recurso])\n\n respond_to do |format|\n if @folha_fonte_recu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /folha/fonte_recursos POST /folha/fonte_recursos.xml
def create @folha_fonte_recurso = Folha::FonteRecurso.new(params[:folha_fonte_recurso]) respond_to do |format| if @folha_fonte_recurso.save format.html { redirect_to(@folha_fonte_recurso, :notice => 'Fonte recurso cadastrado com sucesso.') } format.xml { render :xml => @folha_fonte_recur...
[ "def create\n @fonte_de_recurso = FonteDeRecurso.new(fonte_de_recurso_params)\n\n respond_to do |format|\n if @fonte_de_recurso.save\n addlog(\"Fonte e recurso criada\")\n format.html { redirect_to @fonte_de_recurso, notice: 'Fonte de recurso criado com sucesso.' }\n format.json { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /folha/fonte_recursos/1 PUT /folha/fonte_recursos/1.xml
def update @folha_fonte_recurso = Folha::FonteRecurso.find(params[:id]) respond_to do |format| if @folha_fonte_recurso.update_attributes(params[:folha_fonte_recurso]) format.html { redirect_to(@folha_fonte_recurso, :notice => 'Fonte recurso atualizado com sucesso.') } format.xml { head :...
[ "def update\n respond_to do |format|\n if @fonte_de_recurso.update(fonte_de_recurso_params)\n addlog(\"Fonte de recurso atualizada\")\n format.html { redirect_to @fonte_de_recurso, notice: 'Fonte de recurso atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /folha/fonte_recursos/1 DELETE /folha/fonte_recursos/1.xml
def destroy @folha_fonte_recurso = Folha::FonteRecurso.find(params[:id]) @folha_fonte_recurso.destroy respond_to do |format| format.html { redirect_to(folha_fonte_recursos_url) } format.xml { head :ok } end end
[ "def destroy\n @orc_ficha = OrcFicha.find(params[:id])\n @orc_ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_fichas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @fichaselemento = Fichaselemento.find(params[:id])\n @fichaselemento.destroy\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /spaceships/1 GET /spaceships/1.json
def show @spaceship = Spaceship.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @spaceship } end end
[ "def destroy\n @spaceship = Spaceship.find(params[:id])\n @spaceship.destroy\n\n respond_to do |format|\n format.html { redirect_to spaceships_url }\n format.json { head :no_content }\n end\n end", "def show\n @space = Space.find(params[:id])\n\n respond_to do |format|\n format.h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /spaceships/new GET /spaceships/new.json
def new @spaceship = Spaceship.new respond_to do |format| format.html # new.html.erb format.json { render json: @spaceship } end end
[ "def create\n @spaceship = Spaceship.new(params[:spaceship])\n\n respond_to do |format|\n if @spaceship.save\n format.html { redirect_to @spaceship, notice: 'Spaceship was successfully created.' }\n format.json { render json: @spaceship, status: :created, location: @spaceship }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /spaceships POST /spaceships.json
def create @spaceship = Spaceship.new(params[:spaceship]) respond_to do |format| if @spaceship.save format.html { redirect_to @spaceship, notice: 'Spaceship was successfully created.' } format.json { render json: @spaceship, status: :created, location: @spaceship } else form...
[ "def create\n @space = Space.new(space_params)\n @space.user = current_user\n if @space.save\n render json: @space\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def create\n @space = Space.new(params[:space])\n\n respond_to do |format|\n if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /spaceships/1 PUT /spaceships/1.json
def update @spaceship = Spaceship.find(params[:id]) respond_to do |format| if @spaceship.update_attributes(params[:spaceship]) format.html { redirect_to @spaceship, notice: 'Spaceship was successfully updated.' } format.json { head :no_content } else format.html { render act...
[ "def update\n if @space.update(space_params)\n render json: @space, status: :ok\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @spaceship = Spaceship.find(params[:id])\n @spaceship.destroy\n\n respond_to do |format|\n format.html {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /spaceships/1 DELETE /spaceships/1.json
def destroy @spaceship = Spaceship.find(params[:id]) @spaceship.destroy respond_to do |format| format.html { redirect_to spaceships_url } format.json { head :no_content } end end
[ "def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end", "def destroy\n @hostship = Hostship.find(params[:id])\n @hostship.destroy\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Make sure the message has valid message ids for the message, and fetch them
def fetch_message_ids field self[field] ? self[field].message_ids || [self[field].message_id] : [] end
[ "def has_message_id?; end", "def test_get_existing_message_id\n id = Message.all.first&.id\n return if id.nil?\n\n get \"/messages/#{id}\"\n assert last_response.ok?\n assert_equal 'application/vnd.api+json', last_response.headers['Content-Type']\n\n response_body = JSON.parse last_response.body...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
unnests all the mime stuff and returns a list of [type, filename, content] tuples. for multipart/alternative parts, will only return the subpart that matches preferred_type. if none of them, will only return the first subpart.
def decode_mime_parts part, preferred_type, level=0 if part.multipart? if mime_type_for(part) =~ /multipart\/alternative/ target = part.body.parts.find { |p| mime_type_for(p).index(preferred_type) } || part.body.parts.first if target # this can be nil decode_mime_parts target, prefer...
[ "def decode_mime_parts part, preferred_type, level=0\n if part.multipart?\n if mime_type_for(part) =~ /multipart\\/alternative/\n target = part.body.find { |p| mime_type_for(p).index(preferred_type) } || part.body.first\n if target # this can be nil\n decode_mime_parts target, preferr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the content of a mime part itself. if the contenttype is text/, it will be converted to utf8. otherwise, it will be left in the original encoding
def mime_content_for mime_part, preferred_type return "" unless mime_part.body # sometimes this happens. not sure why. content_type = mime_part.fetch_header(:content_type) || "text/plain" source_charset = mime_part.charset || "US-ASCII" content = mime_part.decoded converted_content, converted_char...
[ "def mime_content_for mime_part, preferred_type\n return \"\" unless mime_part.body # sometimes this happens. not sure why.\n\n mt = mime_type_for(mime_part) || \"text/plain\" # i guess\n content_type = if mt =~ /^(.+);/ then $1.downcase else mt end\n source_charset = if mt =~ /charset=\"?(.*?)\"?(;|$)/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the shortest path from source to destination using BFS algorithm
def shortest_path initial_position_obj = { position: start_position, source: {} } knights_path = [initial_position_obj] while knights_path.present? current_position = knights_path.shift position = current_position[:position] if position == end_position return path_to_destinatio...
[ "def shortest_path\n dist, previous = Hash.new(Infinity), {}\n dist[@source] = 0.0\n queue = @graph.vertex_set.dup\n\n until queue.empty?\n u = queue.min { |a,b| dist[a.name] <=> dist[b.name] }\n break if dist[u.name].infinite?\n queue.delete(u)\n\n u.each_edge do |e, v|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Saves the given knight's position and returns the board id
def save if self.class.valid_position?(knight_position) unique_board_id = board_id redis_conn.set(unique_board_id, knight_position) { status: :success, board_id: unique_board_id } else { status: :failed, message: "Invalid knight's position" } end end
[ "def save_board( last_move )\n recent = boards[boards.keys.max]\n @boards[ @boards.keys.max + 1 ] = recent.dup.play_move!( last_move )\n end", "def store_board(board)\n game_board = board.get_board\n new_state = \"\"\n game_board.each do |cords, stack|\n if stack != nil\n stack.each do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds all possible destinations with respect to the knight's position
def add_possible_destination(position, knights_action, knights_path) possible_destinations = possible_destinations(position) possible_destinations.each do |possible_destination| add_path(possible_destination, knights_action, knights_path) end end
[ "def add_possible_destination_movements(position, knight_movement, knight_movements)\n possible_destinations = possible_destinations(position)\n\n possible_destinations.each do |possible_destination|\n add_movement(possible_destination, knight_movement, knight_movements)\n end\n end", "def add_move...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add destination to visited destinations Adds destination with respect to the action taken by knight and adds the path taken to destination to source to track.
def add_path(destination, knights_action, knights_path) visited_destinations << destination knights_path << { position: destination, source: knights_action } end
[ "def add_possible_destination(position, knights_action, knights_path)\n\n possible_destinations = possible_destinations(position)\n\n possible_destinations.each do |possible_destination|\n add_path(possible_destination, knights_action, knights_path)\n end\n end", "def add_movement(destination, knig...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a new unifiedRoleManagementPolicyExpirationRule and sets the default values.
def initialize() super @odata_type = "#microsoft.graph.unifiedRoleManagementPolicyExpirationRule" end
[ "def initialize()\n super\n @odata_type = \"#microsoft.graph.unifiedRoleManagementPolicyNotificationRule\"\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.unifiedRoleManagementPolicyApprovalRule\"\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the isExpirationRequired property value. Indicates whether expiration is required or if it's a permanently active assignment or eligibility.
def is_expiration_required return @is_expiration_required end
[ "def is_expiration_required=(value)\n @is_expiration_required = value\n end", "def expiration_required?\n @expiration_required\n end", "def expiration_behavior\n return @expiration_behavior\n end", "def can_expire?\n return !!@expiry\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the isExpirationRequired property value. Indicates whether expiration is required or if it's a permanently active assignment or eligibility.
def is_expiration_required=(value) @is_expiration_required = value end
[ "def is_expiration_required\n return @is_expiration_required\n end", "def require_expiration\n @expiration_required = true\n end", "def expiration_required?\n @expiration_required\n end", "def expiration_behavior=(value)\n @expiration_behavior = value\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the maximumDuration property value. The maximum duration allowed for eligibility or assignment which is not permanent. Required when isExpirationRequired is true.
def maximum_duration return @maximum_duration end
[ "def maximum_duration=(value)\n @maximum_duration = value\n end", "def maximum_lifetime_in_minutes\n return @maximum_lifetime_in_minutes\n end", "def max_duration=(max_duration)\n max_duration = nil unless max_duration.present?\n settings.max_duration = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the maximumDuration property value. The maximum duration allowed for eligibility or assignment which is not permanent. Required when isExpirationRequired is true.
def maximum_duration=(value) @maximum_duration = value end
[ "def max_duration=(max_duration)\n max_duration = nil unless max_duration.present?\n settings.max_duration = max_duration\n end", "def max_lifetime=(value)\n @max_lifetime = value\n end", "def maximum_lifetime_in_minutes=(value)\n @maximum_lifetime_in_minutes = va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates child work with: All the appropriate metadata copied from parent title/creator copied from file_set file_set set as member of new child_work DOES save the new child work. DOES NOT actually add it to parent_work yet. That's expensive and needs to be done in a lock. DOES NOT transfer collection membership, that's...
def create_intermediary_child_work(parent, file_set) new_child_work = GenericWork.new(title: file_set.title, creator: [current_user.user_key]) new_child_work.apply_depositor_metadata(current_user.user_key) # make original fileset a member of our new child work self.class.add_to_parent(new_child_work, fi...
[ "def spawn attributes={}\n child = self.dup\n self.work_groups.each do |wg|\n new_wg = WorkGroup.new(:institution=>wg.institution,:project=>child)\n child.work_groups << new_wg\n wg.group_memberships.each do |gm|\n new_gm = GroupMembership.new(:person=>gm.person, :work_group=>wg)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the list of node configs hashes in the given scenario.
def node_configs(scenario_id) parse_node_config_files(parse_scenario_file(scenario_id)) end
[ "def parse_node_config_files(scenario)\n scenario[\"nodes\"].map do |node|\n config_path = File.join(configuration_root, \"nodes\", node[\"node_config\"])\n JSON.parse(File.read(config_path))\n end\nend", "def node_configs(scenario_file)\n parse_node_config_files(parse_scenario_file(scenario_file))\nend"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the environment from the node config hash, or 'production' if it is nil or empty.
def node_environment(node_config) env = node_config['environment'] (env.nil? || env.empty?) ? 'production' : env end
[ "def node_environment(node_config)\n env = node_config[\"environment\"]\n env.nil? || env.empty? ? \"production\" : env\nend", "def environment\n if exists?(:stage)\n stage\n elsif exists?(:rails_env)\n rails_env\n elsif(ENV['RAILS_ENV'])\n ENV['RAILS_ENV']\n else\n \"production\"\n end\nend", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Group the list of node configs into a hash keyed by their environments. A nil or empty environment will be interpreted as 'production'.
def group_by_environment(node_configs) node_configs.group_by do |config| node_environment(config) end end
[ "def modules_per_environment(node_configs)\n node_configs = group_by_environment(node_configs)\n modules = node_configs.map do |env, configs|\n [env, configs.map { |c| c[\"modules\"] }.flatten.uniq]\n end\n Hash[modules]\nend", "def modules_per_environment(node_configs)\n node_configs = group_by_environme...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hash from environments to modules; removes duplicate modules.
def modules_per_environment(node_configs) node_configs = group_by_environment(node_configs) modules = node_configs.map do |env, configs| [env, configs.map { |c| c['modules'] }.flatten.uniq] end Hash[modules] end
[ "def modules_per_environment(node_configs)\n node_configs = group_by_environment(node_configs)\n modules = node_configs.map do |env, configs|\n [env, configs.map { |c| c[\"modules\"] }.flatten.uniq]\n end\n Hash[modules]\nend", "def modules_hash\n @modules\n end", "def modules_hash\n @modules\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the path to the local hiera.yaml file for the specified hiera.
def hiera_configpath(hiera) File.join('config', 'hieras', hiera, 'hiera.yaml') end
[ "def hiera_config_path_on(sut)\n File.join(puppet_environment_path_on(sut), 'hiera.yaml')\n end", "def hiera_datadir\n # This output lets us know where Hiera is configured to look on the system\n puppet_lookup_info = run_shell('puppet lookup --explain test__simp__test').stdout.strip.lines\n puppet_config_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a list of pairs of datadir filepaths for the given hiera. The pairs contain the local and target filepaths, respectively.
def hiera_datadirs(hiera) configpath = hiera_configpath(hiera) config = YAML.load_file(configpath) backends = [config[:backends]].flatten datadirs = backends.map { |be| config[be.to_sym][:datadir] }.uniq datadirs.map do |datadir| localpath = File.join('config', 'hieras', hiera, File.basename(datadir)) ...
[ "def child_paths(prefix, l, r)\n children = (dir_children(l) + dir_children(r)).uniq.sort\n if prefix\n children.map {|x| File.join(prefix, x) }\n else\n children\n end\nend", "def paths(arrs)\n arrs.inject([[]]) do |paths, arr|\n arr.map {|e| paths.map {|path| path + [e]}}.flatten(1)\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /lists/new GET /lists/new.xml
def new @list = List.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @list } end end
[ "def new\n @title = \"New Listing\"\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list }\n end\n end", "def new\n @list = List.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
optional parameters: name: _method, type: String, optional values: GET|POST name: _region, type: String name: _scheme, type: String, optional values: http|https name: address, type: String name: client_token, type: String name: is_public_address, type: String name: load_balancer_mode, type: String name: load_balancer_n...
def create_load_balancer(optional={}) args = self.class.new_params args[:query]['Action'] = 'CreateLoadBalancer' args[:region] = optional[:_region] if (optional.key? :_region) if optional.key? :_method raise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method] ...
[ "def create_load_balancer(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancer'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find out what new roles need filling in, and (at the same time) which ones need saving. We need filling in if 'dont_know' is set or if an email address is given which isn't in the system. It needs saving if it needs filling in or if is has a valid email address
def needs_filling_in? any_need_filling = false @roles.select{|r| r.new_entry }.each do |role| role.needs_saving = role.needs_filling_in = false if role.dont_know role.needs_filling_in = true role.needs_saving = true elsif !role.email.empty? role.needs_saving = true ...
[ "def set_possible_roles\n\tif User.has_role Role.ADMINISTRATOR,session[:roles]\n\t @roles=Role.all\n\t return\n\tend\n\n\t@logged_in_user_role_id = UserRoleMap.getRoleidByUserid(session[:session_user])\n\t#@roles = Role.where(:id => RoleReportTo.select(\"user_role_id\").where(:manager_role_id => @logged_in_user_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build notification channel with recipient's id for uniqueness
def build_notification_id(id) "Notification-#{id}" end
[ "def create_notification(chatroom)\n last_message = chatroom.messages.last\n user = last_message.user\n other_user = chatroom.other_user user.id\n n = other_user.notification || Notification.create(user_id: other_user.id)\n n.count += 1\n n.save\n last_message.notification_id = n.id\n last_m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /v1_users/new GET /v1_users/new.xml
def new @user = V1::User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user } end end
[ "def new\n logger.debug(\"Create a new user\")\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.xml { render xml: @user}\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /v1_users/1 PUT /v1_users/1.xml
def update @user = V1::User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'V1::User was successfully updated.' format.html { redirect_to(@user) } format.xml { head :ok } else format.html { render :action => "edit...
[ "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def update\n if @api_v1_user.update(api_v1_user_param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /v1_users/1 DELETE /v1_users/1.xml
def destroy @user = V1::User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to(v1_users_url) } format.xml { head :ok } end end
[ "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @users = User.find(params[:id])\n @users.destroy\n\n respond_to do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hash of cards SheetName => CardName => Card Modifies defaultFile
def read_worksheet(ws, defaultFile) cards = {} keys = [] (1..ws.getNumRows()).each do |row| if (row == 1) cards[ws.getTitle()] = {} end card = {} (1..ws.getNumCols()).each do |col| cell = ws.getCell(row, col) if cell.empty? then next end # first row should be keys ...
[ "def sheets_info\n if @info[:default_sheet]\n @info[:default_sheet] = verify_sheet_name(@info[:default_sheet])\n @info[:sheets].merge!(sheet_info(@info[:default_sheet]))\n else\n @info[:sheets_name].each { |name| @info[:sheets].merge!(sheet_info(name)) }\n @workbook.default_she...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Export the entire class definition as an OWL ontology. ==== Example Person.to_owl returns string representation of the OWL ontology in Turtle. Person.to_owl(:json) returns string representation of the OWL ontology in RDFJSON.
def to_owl(*args) g = Graph.new owl = Namespace.new('http://www.w3.org/2002/07/owl', 'owl', true) foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf") rdf = Namespace.new("http://www.w3.org/1999/02/22-rdf-syntax-ns", "rdf", true) rdfs = Namespace.new("http://www.w...
[ "def ontology\n load_ontology if @ontology.nil?\n @ontology\n end", "def owl_equivalent_class\n end", "def ontology_objects\n LinkedData::SampleData::Ontology.ontology_objects\n end", "def rdfs_from_owl\n # Get all OWL classes\n qry = Query.new.distinct.select(:s)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create the basic OWL triples for the class, without the properties. ==== Example Person.triple_for_class_definition returns a graph of the triples representing the bare class in OWL. ==== Rules for creating the ontology The class itself will be represented by a bnode. ==== Returns
def triples_for_class_definition declare_namespaces g = Graph.new b = BNode.new(self.name) g << Triple.new(b, URIRef.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), URIRef.new('http://www.w3.org/2002/07/owl#Class')) return g end
[ "def create_triples(clsauthor, bibo)\n myuri = RDF::URI(@liiScholarID)\n myssrnuri = RDF::URI(LII_SSRN_AUTHOR_URI_PREFIX + @ssrnAuthorID)\n RDF::Writer.for(:ntriples).new($stdout) do |writer|\n writer << RDF::Graph.new do |graph|\n graph << [myuri, RDF.type, clsauthor.CLSAuthor]\n graph ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create the OWL triples for a DataMapper property. ==== Example Person.triples_for_property(Person.properties[:id]) returns a graph of the triples representing the id property on Person in OWL. ==== Returns
def triples_for_property(property) g = Graph.new b = BNode.new(property.field) t = Triple.new(b, URIRef.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), URIRef.new('http://www.w3.org/2002/07/owl#DatatypeProperty')) g << t return g end
[ "def get_triples_for_this_resource\n triples_graph = RDF::Graph.new\n @repository.query([RDF::URI.new(self.uri), :predicate, :object]) do |stmt|\n triples_graph << stmt\n end\n triples_graph\n end", "def property_ids\n result = Array.new\n self.properties.each do |p|\n result << p.id\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Utility method to declare a bunch of useful namespaces. ==== Example Person.declare_namespaces instantiates some useful namespaces.
def declare_namespaces foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf") rdf = Namespace.new("http://www.w3.org/1999/02/22-rdf-syntax-ns", "rdf", true) rdfs = Namespace.new("http://www.w3.org/2000/01/rdf-schema", 'rdfs', true) xsd = Namespace.new('http://www.w3.org/2001/...
[ "def register_namespaces(namespaces); end", "def namespaces(*namespaces)\n namespaces.each do |ns|\n namespace ns\n end\n @namespaces\n end", "def namespaces\n @namespaces ||= self.class.name.split('::').slice(0...-1).map(&:underscore).map(&:to_sym)\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /asignaciones GET /asignaciones.json
def index @asignaciones = Asignacione.all end
[ "def index\n @asignaturas = Asignatura.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asignaturas }\n end\n end", "def index\n @asignacions = Asignacion.all\n end", "def index\n @asignaturas = Asignatura.all\n end", "def show\n @motiv...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns coordinates that will be reached after applying the +move+, starting from the +from+ coordinates
def relative_coords(from, move) [from[0] + move[0], from[1] + move[1]] end
[ "def valid_moves(from)\n\tpossible_moves(from).select { |move| valid_position?(move) }\nend", "def valid_moves(from)\r\n\tpossible_moves(from).select { |move| valid_position?(move) }\r\nend", "def relative_direction(from, to)\n # first, look for the case where the maze wraps, and from and to\n # are on op...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /despatches GET /despatches.json
def index @despatches = Despatch.all end
[ "def destroy\n @despatch.destroy\n respond_to do |format|\n format.html { redirect_to despatches_url, notice: 'Despatch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @production_dpts = ProductionDpt.all\n\n render json: @production_dpts\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /despatches POST /despatches.json
def create @despatch = Despatch.new(despatch_params) respond_to do |format| if @despatch.save format.html { redirect_to @despatch, notice: 'Despatch was successfully created.' } format.json { render :show, status: :created, location: @despatch } else format.html { render :ne...
[ "def index\n @despatches = Despatch.all\n end", "def destroy\n @despatch.destroy\n respond_to do |format|\n format.html { redirect_to despatches_url, notice: 'Despatch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /despatches/1 PATCH/PUT /despatches/1.json
def update respond_to do |format| if @despatch.update(despatch_params) format.html { redirect_to @despatch, notice: 'Despatch was successfully updated.' } format.json { render :show, status: :ok, location: @despatch } else format.html { render :edit } format.json { render...
[ "def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n\n redirect_to :action ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /despatches/1 DELETE /despatches/1.json
def destroy @despatch.destroy respond_to do |format| format.html { redirect_to despatches_url, notice: 'Despatch was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @gratch.destroy\n respond_to do |format|\n format.html { redirect_to gratches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @scratch = Scratch.find(params[:id])\n @scratch.destroy\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
remove both the local download file and remote eb config
def clean(mute=false) return if @options[:dirty] UI.say "Cleaning up eb remote config and local files" unless mute eb.delete_configuration_template( application_name: @updater.app_name, template_name: current_name ) unless @options[:noop] FileUtils.rm_f(@curre...
[ "def remove!\n response = connection.exec!(\"rm #{ File.join(remote_path, remote_file) }\")\n if response =~ /No such file or directory/\n Logger.warn \"Could not remove file \\\"#{ File.join(remote_path, remote_file) }\\\".\"\n end\n end", "def remove\n print \"[\\e[90m%s\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the create_device_registry REST call
def create_device_registry request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_create_device_registry_request request_pb query_string_params = if query_string_params.a...
[ "def create_registry!(params)\n svc = ::Registries::CreateService.new(nil, params)\n svc.execute\n return unless svc.valid?\n\n Rails.logger.tagged(\"registry\") do\n msg = JSON.pretty_generate(params)\n Rails.logger.info \"Registry created with the following parameters:\\n#{msg}\"\n end\nend", "def cr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the get_device_registry REST call
def get_device_registry request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_get_device_registry_request request_pb query_string_params = if query_string_params.any? ...
[ "def registry\n @registry ||= client.registries.get_from_uri(info[:registry]) unless info[:registry].nil?\n end", "def create_device_registry request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the update_device_registry REST call
def update_device_registry request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_update_device_registry_request request_pb query_string_params = if query_string_params.a...
[ "def update\n attrs = update_params.merge(id: params[:id])\n svc = ::Registries::UpdateService.new(current_user, attrs)\n @registry = svc.execute\n\n if svc.valid?\n # NOTE: if we decide to use rails-observers at some point,\n # we can remove this from here and use it in observers\n Rails...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the delete_device_registry REST call
def delete_device_registry request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_delete_device_registry_request request_pb query_string_params = if query_string_params.a...
[ "def destroy\n \n @registry = Registry.find(params[:id])\n @registry.destroy\n logger.info \"*-*-*-*-* #{@registry.name} deleted by #{@user.username}.\"\n\n respond_to do |format|\n format.html { redirect_to( user_gifts_url(@user)) }\n format.xml { head :ok }\n end\n end", "def destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_device_registries REST call
def list_device_registries request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_list_device_registries_request request_pb query_string_params = if query_string_params.a...
[ "def index\n @device_registrations = DeviceRegistration.all\n end", "def calc_reg_list(device = :all)\n registrars.find_all { |dev, reg| device.to_sym == :all || device.to_s == dev }.map { |vp| vp[1] }\n end", "def registrations\n software_registrations + hardware_registrations\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the modify_cloud_to_device_config REST call
def modify_cloud_to_device_config request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_modify_cloud_to_device_config_request request_pb query_string_params = if query_s...
[ "def update\n if !current_user.manager?\n head :forbidden\n else\n if @device_configuration.update(device_configuration_params)\n render json: @device_configuration.to_json, status: :ok\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_device_config_versions REST call
def list_device_config_versions request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_list_device_config_versions_request request_pb query_string_params = if query_strin...
[ "def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n end", "def versions\n vars = api.get_config_vars(app).body\n _, versions_data = vars.detect {|k,v| k == 'HEROKU_CONFIG_VERSIONS'}\n\n if versions_data\n v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_device_states REST call
def list_device_states request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_list_device_states_request request_pb query_string_params = if query_string_params.any? ...
[ "def device_states_list\n get \"deviceStates\"\n end", "def device_states_get(device_name)\n get \"deviceStates/#{device_name}\"\n end", "def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end", "def device_states=(value)\n @device_states = value\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the send_command_to_device REST call
def send_command_to_device request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_send_command_to_device_request request_pb query_string_params = if query_string_params.a...
[ "def send_cmd(cmd)\n payload = [PAYLOAD_START, cmd, 0, 0, 0, 0, 0, 0]\n @handle.usb_control_msg(REQUEST_TYPE, REQUEST, 0, 0, payload.pack('CCCCCCCC'), 0)\n end", "def rcon_send(command); end", "def send_command(cmd, params = {})\n # Send the command\n return @server.command cmd , params\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the bind_device_to_gateway REST call
def bind_device_to_gateway request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_bind_device_to_gateway_request request_pb query_string_params = if query_string_params.a...
[ "def bind(&block)\n\t\t\t@endpoint.bind(&block)\n\t\tend", "def device_passthrough\n @device_passthrough\n end", "def method_missing(method_name, *arguments, &block)\n device.send(method_name, *arguments, &block)\n end", "def unbind_device_from_gateway request_pb, options = nil\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the unbind_device_from_gateway REST call
def unbind_device_from_gateway request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_unbind_device_from_gateway_request request_pb query_string_params = if query_string_...
[ "def unbridge bridge_id\n post \"bridges/#{bridge_id}\", {callIds: []}\n\n nil\n end", "def unregister\n puts \"APN::Device.unregister\"\n http_delete(\"/api/device_tokens/#{self.token}\")\n end", "def unbind(port:)\n {\n method: \"Tethering.unbind\",\n params:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If `type` is an interface, and `self` has a type membership for `type`, then make sure it's visible.
def visible_interface_implementation?(type, context, warden) if type.respond_to?(:kind) && type.kind.interface? implements_this_interface = false implementation_is_visible = false warden.interface_type_memberships(self, context).each do |tm| if tm.abstract_typ...
[ "def check_type(type) self.class.instance_eval { check_type(type) }; end", "def check_type(instance, &recursively_check_type)\n raise NotImplementedError\n end", "def interface_type?(type)\n interface_typelist.include?(resolve_type(type))\n rescue ModelKit::Types::NotFound\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /finger_prints GET /finger_prints.json
def index @finger_prints = FingerPrint.all respond_to do |format| format.html # index.html.erb format.json { render json: @finger_prints } format.csv { send_data FingerPrint.scoped.to_csv, filename: "fingerprints-#{Date.today}.csv"} end end
[ "def show\n #debugger\n @finger_print = FingerPrint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @finger_print }\n end\n end", "def index\n # @setup = CloudPrint.setup(hash)\n # @printers = CloudPrint::Printer.all\n\n respo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /finger_prints/1 GET /finger_prints/1.jsonl
def show #debugger @finger_print = FingerPrint.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @finger_print } end end
[ "def index\n @finger_prints = FingerPrint.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @finger_prints }\n format.csv { send_data FingerPrint.scoped.to_csv, filename: \"fingerprints-#{Date.today}.csv\"}\n end\n end", "def show\n @magnetic_fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /finger_prints/new GET /finger_prints/new.json
def new @finger_print = FingerPrint.new respond_to do |format| format.html # new.html.erb format.json { render json: @finger_print } end end
[ "def new\n @printer = Printer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @printer }\n end\n end", "def new\n @sprint = Sprint.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sprint }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /finger_prints POST /finger_prints.json
def create @finger_print = FingerPrint.check_exist(params[:finger_print]) respond_to do |format| format.html { redirect_to @finger_print, notice: 'FingerPrint was successfully created.' } format.json { render json: @finger_print, status: :created, location: @finger_print } end end
[ "def create\n @magnetic_finger_print = MagneticFingerPrint.new(params[:magnetic_finger_print])\n\n respond_to do |format|\n if @magnetic_finger_print.save\n format.html { redirect_to @magnetic_finger_print, notice: 'Magnetic finger print was successfully created.' }\n format.json { render j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /finger_prints/1 PUT /finger_prints/1.json
def update @finger_print = FingerPrint.find(params[:id]) respond_to do |format| if @finger_print.update_attributes(params[:finger_print]) format.html { redirect_to @finger_print, notice: 'Finger print was successfully updated.' } format.json { head :no_content } else format....
[ "def update\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n if @magnetic_finger_print.update_attributes(params[:magnetic_finger_print])\n format.html { redirect_to @magnetic_finger_print, notice: 'Magnetic finger print was successfully updated.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /finger_prints/1 DELETE /finger_prints/1.json
def destroy @finger_print = FingerPrint.find(params[:id]) @finger_print.destroy respond_to do |format| format.html { redirect_to finger_prints_url } format.json { head :no_content } end end
[ "def destroy\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n @magnetic_finger_print.destroy\n\n respond_to do |format|\n format.html { redirect_to magnetic_finger_prints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @print.destroy\n respond_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
responsible for handling the loc_page view
def loc_view end
[ "def landing_page\n end", "def selected_page\n end", "def visited_page(url); end", "def visit_path\n end", "def page_view page\n self.views.find(:first, :conditions => [\"resource_type = 'Page' and resource_id = ?\", page.id ])\n end", "def visit(page)\n end", "def set_page_view\n @page_v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Passes an array of fingerprint readings to the model to localize
def localization #debugger searched = params[:finger_print] @coordinates = FingerPrint.KNN(searched) puts @coordinates respond_to do |format| format.html format.json {render json: @coordinates} end end
[ "def localization\n\t\t\tloc = []\n\t\t\t# we have to sort the hash in this case.\n#\t\t\titems.sort.each_index do |index|\n#\t\t\t\tloc << items[index+1].aln_from.to_s + \"..\" + items[index+1].aln_to.to_s\n#\t\t\tend\n#\t\t\tloc.join(\",\")\n\t\t\teach_domain do |domain|\n\t\t\t\tdomain.each_domainhit do |dh|\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Magnetic variation in degrees
def magnetic_variation_degrees self.class.nsew_signed_float(@fields[10], @fields[11]) end
[ "def magnetic_variation_degrees\n self.class.nsew_signed_float(@fields[4], @fields[5])\n end", "def magnetic_deviation_degrees\n self.class.nsew_signed_float(@fields[5], @fields[6])\n end", "def true_to_magnetic(heading)\r\n value = heading - @variance\r\n value += 360....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Disable SQL logging. You can use this method to turn off logging SQL when the migration is munging data that may vary between environments.
def disable_sql_logging(&block) sql_logging(enabled: false, &block) end
[ "def disable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 1\nend", "def enable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 0\nend", "def turn_off_qa_db_logging()\r\n @@logToQADatabase =0\r\n end", "def disable_verbose_log()\n PureHailDB.ib_cfg_set(\"print_verbos...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enable SQL logging. You can call this method within a block where SQL logging was disabled to renable it.
def enable_sql_logging(&block) sql_logging(enabled: true, &block) end
[ "def log_sql\n @opts[:log_sql]\n end", "def disable_sql_logging(&block)\n sql_logging(enabled: false, &block)\n end", "def enable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 0\nend", "def enable_logging\n initialize_logger\n end", "def set_logging_statement(opts)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use a different database connection for the block. You can use this if your application has multiple databases to swap connections for the migration. You can pass in either a database connection or an ActiveRecord::Base class to use the connection used by that class. The label argument will be added to the logged SQL a...
def using_connection(connection_or_class, label: nil, &block) if connection_or_class.is_a?(Class) && connection_or_class < ActiveRecord::Base label ||= connection_or_class.name connection_or_class.connection_pool.with_connection do |connection| switch_connection_in_block(connection, labe...
[ "def repository_db &block\n Sequel.connect \"sqlite://#{ path }\", logger: LOGGER, &block\n end", "def use(name)\n with(database: name)\n end", "def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extract the connection string for the rabbitmq service from the service information provided by Cloud Foundry in an environment variable.
def amqp_url if not ENV['VCAP_SERVICES'] return { :host => "172.16.32.11", :port => 5672, :username => "guest", :password => "guest", :vhost => "/", } end services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true) url = services.values.map do |srvs| ...
[ "def amqp_url\n if not ENV['VCAP_SERVICES']\n return {\n :host => \"localhost\",\n :port => 5672,\n :username => \"guest\",\n :password => \"guest\",\n :vhost => \"/\",\n }\n end\n\n services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true)\n url = services.values.map ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Register a card that has been duplicated so it can be remapped
def register_duplicated_card(original_card_id:, to_card_id:) Cache.hash_set("#{@batch_id}_duplicated_cards", original_card_id, to_card_id) remapper = CardDuplicatorMapper::RemapLinkedCards.new( batch_id: @batch_id, ) # remap the card that was just duplicated remapper.remap_cards(o...
[ "def addCard(givenCard)\n \tcards_users.create(card_id: givenCard.id, is_shared: false)\n end", "def add_card(card)\n add_card_to_hand(card)\n end", "def checkDuplicateCard source, customer, user\n \t#Retrieve the card fingerprint using the stripe_card_token \n newcard = Stripe::Token.retrieve(source...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }