query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Create multiple rooms for the hotel.
def create_rooms(rooms_params) rooms_params[:extra_info] ||= "" rooms_params[:range].each do |number| rooms << Room.create( number: number.to_i, capacity: rooms_params[:capacity].to_i, extra_info: rooms_params[:extra_info], name: rooms_params[:name] ) end end
[ "def create_rooms\n @rooms = []\n (1..20).each do |room_num|\n room = Hotel::Room.new(room_num: 1)\n room.room_num = room_num\n @rooms << room\n end\n return @rooms\n end", "def create_rooms\n $room1 = Room.new(\"Room 1\", \"This is room 1\", {}, {fork: $fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the capcity of the hotel based on the sum of the capacity of its rooms
def capacity capacity = 0 rooms.all.each do |room| capacity += room.capacity end capacity end
[ "def house_capacity\n has_reserved_seating? ? seatmap.seat_count : attributes['house_capacity']\n end", "def get_rooms_by_capacity(range_filter, room, rooms_capacity)\n range = split_string(range_filter)\n if room.capacity >= range[0].to_i && room.capacity < range[1].to_i\n rooms_capacity << room\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array with all users inside the rooms of the hotel
def users users = [] rooms.each do |room| room.users.each do |user| users << user end end users end
[ "def list_all_rooms_in_hotel\n\n return @rooms.map { |room| room }\n end", "def get_users_of_room(room_id:, offline_users: 'false')\n { msg: 'method',\n method: 'getUsersOfRoom',\n params: [room_id, offline_users] }\n end", "def users\n response = @campfire.http.get(\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the number of people inside the hotel
def number_of_people users.length end
[ "def number_of_guests()\n return @guests_in_room.count()\n end", "def total_visitors\n room.group_by{|v| v.visitor}.count.to_i\n end", "def count_occupants()\n return @occupants.length\n end", "def total_people\n legislatures.map(&:person_count).inject(:+)\n end", "def passenger_coun...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin logic for sending Emails. if current_user.id matches the resource_requests/user_id then he is the project manager and the email should go to admin. else it will go to project managers from current_user.id parameters need to be passed current_user object and resource_request object. =end
def ResourceRequestsAndReply(current_user, resource_request, comments) @current_user = current_user @resource_request = resource_request @comments = comments if ['submitted'].include?(@resource_request.status) # @admin = true @message = "Hi, <br/> #{@current_user.full_name()} has requested r...
[ "def match_to_request_or_send_email\n if joinable.membership_request_for?(user)\n accept(user)\n else\n UserMailer.invited_to_project_email(self).deliver\n end\n end", "def grant_manager(user)\n @user = user\n mail(to: @user.email, subject: 'Your have been promoted as Project Manager')\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /intervals/1 GET /intervals/1.json
def show @interval = Interval.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @interval } end end
[ "def index\n @intervals = Interval.all\n\n render json: @intervals\n end", "def show\n @interval = current_user.intervals.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interval }\n end\n end", "def get_intervals\n return ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /intervals/new GET /intervals/new.json
def new @interval = Interval.new respond_to do |format| format.html # new.html.erb format.json { render json: @interval } end end
[ "def new\n @interval = Interval.new\n\n\t@date = Date.today\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interval }\n end\n end", "def create\n @interval = Interval.new(interval_params)\n\n if @interval.save\n render json: @interval, status: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /intervals POST /intervals.json
def create @interval = Interval.new(params[:interval]) respond_to do |format| if @interval.save format.html { redirect_to @interval, notice: 'Interval was successfully created.' } format.json { render json: @interval, status: :created, location: @interval } else format.html ...
[ "def create\n @interval = Interval.new(interval_params)\n\n if @interval.save\n render json: @interval, status: :created, location: @interval\n else\n render json: @interval.errors, status: :unprocessable_entity\n end\n end", "def create\n @interval = Interval.new(interval_params)\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /intervals/1 PUT /intervals/1.json
def update @interval = Interval.find(params[:id]) respond_to do |format| if @interval.update_attributes(params[:interval]) format.html { redirect_to @interval, notice: 'Interval was successfully updated.' } format.json { head :no_content } else format.html { render action: "...
[ "def update\n @interval = Interval.find(params[:id])\n\n if @interval.update(interval_params)\n head :no_content\n else\n render json: @interval.errors, status: :unprocessable_entity\n end\n end", "def update\n @interval = Interval.find(params[:id])\n\n respond_to do |format|\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /intervals/1 DELETE /intervals/1.json
def destroy @interval = Interval.find(params[:id]) @interval.destroy respond_to do |format| format.html { redirect_to intervals_url } format.json { head :no_content } end end
[ "def destroy\n @interval = Interval.find(params[:id])\n @interval.destroy\n\n respond_to do |format|\n format.html { redirect_to(intervals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @interval = Interval.find(params[:id])\n @interval.destroy\n redirect_to(interva...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Construct a BrowseEverything::FileEntry object
def entry_for(name, size, date, dir) BrowseEverything::FileEntry.new(name, [key, name].join(':'), File.basename(name), size, date, dir) end
[ "def build_entry(hash)\n FileOrDirectory.new(hash[\"name\"], hash[\"id\"], hash[\"content_type\"])\n end", "def make_entry()\n ## already have access to a the instance var @filehandler, no need to pass it in\n # def make_entry(f)\n # remove the trailing newline\n header = @filehand...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a listing and a S3 listing and path, populate the entries
def add_files(listing, path) listing.contents.each do |entry| key = from_base(entry.key) new_entry = entry_for(key, entry.size, entry.last_modified, false) @entries << new_entry unless strip(key) == strip(path) || new_entry.nil? end end
[ "def addBatchAndURLInformation()\n AWS::S3.new.buckets['curateanalytics'].objects.each do |obj|\n if(obj.key =~ /swipe batches/) && (obj.key =~ /jpg/)\n folder = obj.key.split(\"/\")[1]\n batch = obj.key.split(\"/\")[obj.key.split(\"/\").length-2]\n url = \"https://s3.amazonaws.com/curateanalytic...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read the failing log from our test stack
def read_failing_log() failed_files = [] # Read in the file file = File.readlines(@failing_log) # Get lines which begin with rspec file.each do |line| if line =~ /rspec \.\// # Get the file name only failed_files << get_error_info(line) end end ...
[ "def extract_chef_stacktrace(payload)\n uuid = payload[:message_id]\n path = File.join(workspace(uuid, :log), \"#{uuid}.log\")\n error_msg = 'Failed to extract error information!'\n if(File.exists?(path))\n debug \"Found chef log file for error extraction (#{path})\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /session_events POST /session_events.json
def create @session_event = SessionEvent.new(session_event_params) respond_to do |format| if @session_event.save format.html { redirect_to @session_event, notice: 'Session event was successfully created.' } format.json { render :show, status: :created, location: @session_event } els...
[ "def create\n @session_event = SessionEvent.new\n @session_event.behavior_square_id = params[:behavior_id]\n @session_event.square_press_time = params[:start_time].to_s\n @session_event.duration_end_time = params[:end_time].to_s\n @session_event.session_id = params[:session_id]\n\n # calculate and...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /session_events/1 DELETE /session_events/1.json
def destroy @session_event.destroy respond_to do |format| format.html { redirect_to session_events_url, notice: 'Session event was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @event_session.destroy\n respond_to do |format|\n format.html { redirect_to event_sessions_url, notice: 'Event session was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: select_exam explanation: this method associate select_exam view with this controller parameters: none return: select_exam
def select_exam end
[ "def select_exam\n\n end", "def set_exam\n\t\t@exam = Exam.find(params[:id])\n\tend", "def answer_exam\n if params[:year_exam] \n questions ||= Question.where(year: params[:year_exam])\n assert(questions.kind_of?(Question))\n else\n questions ||= Question.all\n assert(questions.kind_o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: exams_statistics explanation: this method associate exams_statistics view with this controller parameters: none return: exams_statistics
def exams_statistics end
[ "def exams_statistics\n\n end", "def view_stats_all\n data = {\n :name => \"Student Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at >...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: answer_exam explanation: this method parameters: none return: questions of enemamigo
def answer_exam if params[:year_exam] questions ||= Question.where(year: params[:year_exam]) assert(questions.kind_of?(Question)) else questions ||= Question.all assert(questions.kind_of?(Question)) end if !questions.empty? auxiliar_exam ||= push_questions_auxiliar(questi...
[ "def answer_exam\n\n questions = params[:year_exam] ? Question.where(year: params[:year_exam]) : Question.all\n\n if !questions.empty?\n auxiliar_exam = push_questions_auxiliar(questions)\n @exam = push_questions(auxiliar_exam)\n else\n return redirect_to_back(select_exam_path)\n if par...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: exam_result explanation: this method list result of the exam of enemamigo parameters: none
def exam_result if params[:exam_id] @exam = Exam.find(params[:exam_id]) assert(exam.kind_of?(Exam)) @exam = fill_user_answers(@exam) current_user.exams_total_questions += @exam.questions.count current_user.update_attribute(:exam_performance, current_user.exam_performance + [@exam.acce...
[ "def exam_data(subject)\n Exam.result(subject.id, id)\n end", "def check\n @exam = @course.exams.find(params[:id])\n @record = Record.new\n @record.exam, @record.student = @exam, @student\n @record.started_at = session[:test_started_at] || Time.now\n session[:test_started_at] = nil\n @record...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
name: cancel_exam explanation: this method cancel of exam of enemamigo parameters: none return:redirect_to root_path
def cancel_exam exam = Exam.find(params[:exam_id]) assert(exam.kind_of?(Exam)) exam.destroy return redirect_to root_path end
[ "def cancel_exam\n\n exam = Exam.find(params[:exam_id])\n exam.destroy\n return redirect_to root_path\n\n end", "def cancel_remark_request\n @submission = record\n @assignment = record.grouping.assignment\n @course = record.course\n record.remark_result.destroy\n record.get_original_resul...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Float() style conversion, or false if conversion impossible.
def to_Float begin fl = Float stripn return fl rescue ArgumentError return false end end
[ "def float?(str)\n true if Float(str) rescue false\n end", "def float?(object)\n return true if Float(object)\n rescue \n return false\nend", "def float?\n @kind == :float_lit || @kind == :float_exp_lit\n end", "def check_float(string)\n\t\treturn true if Float(string) rescue false \n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Like strip, but also strips newlines.
def stripn encode( universal_newline: true ) .gsub("\n", "") .strip end
[ "def rstrip() end", "def rstrip!() end", "def strip(string)\n string.split(\"\\n\").map(&:strip).join(\"\\n\")\n end", "def lstrip() end", "def safe_strip!() self.strip!; self end", "def strip_newlines(input)\n input.to_s.gsub(/\\n/, '')\n end", "def lstrip!() end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Applies standardize to the receiver and converts the result to a symbol.
def to_standardized_sym standardize .to_sym end
[ "def to_standardized_sym\n to_s.to_standardized_sym\n end", "def to_sym() end", "def to_sym\n @symbol\n end", "def turn_to_symbol(string)\n string.gsub(/\\s+/, \"\").to_sym\nend", "def turn_symbol_into_string(symbol)\n symbol.to_s\nend", "def to_symbol(text)\n text.gsub(/\\:/i, '').to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Workhorse utility method for logging funnel events (This is probably how MOST funnel events will be triggered) checks if we are an admin visitor first sends the funnel event msg to the current user, if we're logged in sets the url, referer, ua data automatically using the request otherwise, sends it to the current visi...
def log_funnel_event(event, data={}) return if ignore_funnel_tracking? register_funnel_visitor if current_visitor.nil? unless current_visitor.nil? data.reverse_merge!({ :url=>request.request_uri, :referer=>request.referer, :user_agent=>...
[ "def log_funnel_page_visit\n log_funnel_event(:view_page)\n end", "def log_funnel_event(event, data={})\n unless self.valid_events.include?(event.to_sym)\n Rails.logger.info \"#{self.class.to_s} couldn't log FunnelCake event: #{event} This event is not valid for state: #{self.current_state...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Utility method for logging a page visit
def log_funnel_page_visit log_funnel_event(:view_page) end
[ "def dc_log_visit()\r\n if request.env[\"HTTP_USER_AGENT\"] and request.env[\"HTTP_USER_AGENT\"].match(/\\(.*https?:\\/\\/.*\\)/)\r\n logger.info \"ROBOT: #{Time.now.strftime('%Y.%m.%d %H:%M:%S')} id=#{@page.id} ip=#{request.remote_ip}.\"\r\n session[:is_robot] = true\r\n else\r\n DcVisit.create(site_id:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Utility method for syncing the current visitor to the current user (This should be called when a user logs in!) Bails out if not logged in otherwise, sets the .user of the current_visitor
def sync_funnel_visitor return unless FunnelCake.enabled? if not logged_in? logger.info "Couldn't sync Analytics::Visitor to nil User" return end if current_visitor.nil? logger.info "Couldn't sync nil Analytics::Visitor to current User: #{curr...
[ "def set_current_user\n Member.current = current_user unless current_user.nil?\n end", "def assign_logged_in_user\n LOGGED_IN_USER[:user] = current_user\n end", "def set_current_user\n # To be accessible in the model when not granted\n # rubocop:disable Style/GlobalVars\n $request =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the current visitor registered? We check the cookie state to find out
def visitor_registered? cookies[self.class.read_inheritable_attribute(:cookie_name)].nil? == false end
[ "def visited?(cookie_hash)\n (cookie_hash.empty? || cookie_hash[slug] == \"1\" ? true : false)\n end", "def logged_in?\n !current_reg.nil?\n end", "def ever_logged_in?\n @data[:has_ever_logged_in]\n end", "def registered?\n @registered ||= false\n end", "def exists_in_cookie(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Register the current visitor (without checking anything first, just do it) We create a new Analytics::Visitor here, using a new random hex key Set the cookie value for this visitor
def register_funnel_visitor @current_visitor = FunnelCake.engine.visitor_class.create( :ip=>request.remote_ip.to_s ) @current_visitor.user_id = current_user.id if logged_in? @current_visitor.save cookies[self.class.read_...
[ "def record_visit\n unless (visit_key = cookies[:id])\n visit_key = SecureRandom.urlsafe_base64(16)\n cookies.permanent[:id] = visit_key\n end\n VisitCounter.record(visit_key)\n end", "def register_visit\r\n if @debug\r\n puts \"REQUEST IN REGISTER VISIT: #{request}\"\r\n pu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the current Analytics::Visitor object, using the visitor's cookie
def current_visitor return @current_visitor unless @current_visitor.nil? # Check if we're logged in first, set the current_visitor from the current_user if logged_in? @current_visitor = current_user.visitor end # If we are not logged in, or if the current_...
[ "def current_site_visitor\n @current_site_visitor ||= begin\n code = ensure_code_cookie\n GreenFlag::SiteVisitor.for_visitor_code!(code)\n end\n end", "def get_cookie\n self.headers[\"Cookie\"]\n end", "def cookie\n @cookie ||= Coca::AuthCookie.new(cookies, scope)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Accessor for target_path The target_path is the path where the finalizers will put the release
def target_path Pathname.new(config[:target_path]) end
[ "def target_path\n Pathname.new(self.config[:target_path])\n end", "def target_path(target_name)\r\n File.join(package_dir, target_name)\r\n end", "def targets_path\n self.root.join(TARGETS_DIRECTORY)\n end", "def release_path\n context.release_path\n end", "def release_path\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a banner if a block is given, or returns the currently set banner. It automatically takes care of adding comment marks around the banner. The default banner looks like this: ======================= = Version : v1.0.0 = = Date : 20120620 = =======================
def banner(options = {}, &_block) options = { comment: :js }.update(options) if block_given? @_banner = yield.to_s elsif !@_banner @_banner = default_banner.join("\n") end if options[:comment] comment(@_banner, style: options[:comment]) else ...
[ "def banner(options = {}, &block)\n options = {\n :comment => :js\n }.update(options)\n \n if block_given?\n @_banner = yield.to_s\n elsif !@_banner\n banner = []\n banner << \"Version : #{self.scm.version}\"\n banner << \"Date : #{self.scm.date.strftime(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
============== = The runway = ============== Checks if build path exists (and cleans it up) Checks if target path exists (if not, creates it)
def validate_paths! ensure_clean_build_path! ensure_existing_target_path! end
[ "def validate_paths!\n if self.build_path.exist?\n log self, \"Cleaning up previous build \\\"#{self.build_path}\\\"\"\n rm_rf(self.build_path)\n end\n \n if !self.target_path.exist?\n log self, \"Creating target path \\\"#{self.target_path}\\\"\"\n mkdir self.targe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find a processor in the stack
def find_in_stack(klass) @stack.find { |(processor, _options)| processor.class == klass } end
[ "def find(processor_name)\n @processors.find do |processor|\n processor.processor_name == processor_name\n end\n end", "def fetch(processor_name)\n idx = processors.index {|processor| processor.name.equal?(processor_name)}\n idx or raise(UnknownProcessor.new(processor_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Let's make our own `each` method on AnimalSet. Now, we can have a set of animals and get one at a time. Because the animals is ultimately just an array (look at the initialize method), we're going to cheat a little bit and just take a block to AnimalSet's each method and then
def each(&block) @animals.each(&block) end
[ "def each\n return enum_for(:each) unless block_given?\n\n @sets.each { |_, set| yield(set) }\n end", "def each(&blk); each_value(&blk) ; end", "def each\n self.to_a.each { |i| yield i }\n end", "def collect!\n block_given? or return enum_for(__method__)\n set = self.class.new\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a list of specified user's splatts GET /users/splatts/1 GET /users/splatts/1.json
def splatts @user = User.find(params[:id]) render json: @user.splatts end
[ "def splatts\n\t@user = User.find(params[:id])\n\t\n\trender json: @user.splatts\n end", "def splatts\n @user = User.find(params[:id])\n\n render json: @user.splatts\n end", "def splatts\n \t@user = User.find(params[:id])\n \t\n \trender json: @user.splatts\n end", "def index\n @splatts = Splat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /admin_panels POST /admin_panels.json
def create @admin_panel = AdminPanel.new(admin_panel_params) respond_to do |format| if @admin_panel.save format.html { redirect_to @admin_panel, notice: 'Admin panel was successfully created.' } format.json { render action: 'show', status: :created, location: @admin_panel } else ...
[ "def create\n @admin_panel = Admin::Panel.new(admin_panel_params)\n\n respond_to do |format|\n if @admin_panel.save\n format.html { redirect_to @admin_panel, notice: 'Panel was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_panel }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /admin_panels/1 PATCH/PUT /admin_panels/1.json
def update respond_to do |format| if @admin_panel.update(admin_panel_params) format.html { redirect_to @admin_panel, notice: 'Admin panel was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @a...
[ "def update\n @admin_panel = Panel.find(params[:id])\n\n if @admin_panel.update_attributes(params[:admin_panel])\n params.keys.each do |k|\n set_params(k)\n end \n else \n flash[:notice] = t(\"admin.panels.update.notice_failure\")\n respond_with(@admin_panel)\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /admin_panels/1 DELETE /admin_panels/1.json
def destroy @admin_panel.destroy respond_to do |format| format.html { redirect_to admin_panels_url } format.json { head :no_content } end end
[ "def destroy\n @panel = Panel.find(params[:id])\n @panel.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_panels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @gui_panel = Gui::Panel.find(params[:id])\n @gui_panel.destroy\n\n respond_to do |form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /containers GET /containers.json
def index @containers = Container.all end
[ "def running_containers\n request do\n get(path: '/containers/json')\n end\n end", "def show\n @container.json = Docker::Container.get(@container.cid)\n end", "def containers(limit = nil, marker = nil)\n path = OpenStack.get_query_params({:limit=>limit, :marker=>marker, :format=>'js...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /containers/1 PATCH/PUT /containers/1.json
def update respond_to do |format| if @container.update(container_params) format.html { redirect_to @container, notice: 'Container was successfully updated.' } format.json { render :show, status: :ok, location: @container } else format.html { render :edit } format.json { r...
[ "def update\n @container = Container.find(params[:id])\n\n # Destroy everything in the container but not the container itself \n @container.routers.each do |router|\n router.destroy()\n end\n @container.networks.each do |network|\n network.destroy()\n end\n @container.vms.each do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /participant_quotes GET /participant_quotes.json
def index @participant_quotes = ParticipantQuote.all respond_to do |format| format.html # index.html.erb format.json { render json: @participant_quotes } end end
[ "def show\n @participant_quote = ParticipantQuote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant_quote }\n end\n end", "def destroy\n @participant_quote = ParticipantQuote.find(params[:id])\n @participant_quote.destroy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /participant_quotes/1 GET /participant_quotes/1.json
def show @participant_quote = ParticipantQuote.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @participant_quote } end end
[ "def index\n @participant_quotes = ParticipantQuote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participant_quotes }\n end\n end", "def destroy\n @participant_quote = ParticipantQuote.find(params[:id])\n @participant_quote.destroy\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /participant_quotes/new GET /participant_quotes/new.json
def new @participant_quote = ParticipantQuote.new respond_to do |format| format.html # new.html.erb format.json { render json: @participant_quote } end end
[ "def new\n @quote = Quote.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end", "def new\n @quote = Quote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /participant_quotes POST /participant_quotes.json
def create @participant_quote = ParticipantQuote.new(params[:participant_quote]) @participant_quote.user_id = current_user.id respond_to do |format| if @participant_quote.save format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully created.' } format....
[ "def create\n @quote = Quote.new(params[:quote])\n render json: @quote\n end", "def create\n @quote = Customer.find(params[:customer_id]).quotes.new(quote_params)\n \n respond_to do |format|\n if @quote.save\n format.json { render :json => { :code => \"201\", :description => \"Created ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /participant_quotes/1 PUT /participant_quotes/1.json
def update @participant_quote = ParticipantQuote.find(params[:id]) respond_to do |format| if @participant_quote.update_attributes(params[:participant_quote]) format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully updated.' } format.json { head :no_conten...
[ "def create\n @participant_quote = ParticipantQuote.new(params[:participant_quote])\n @participant_quote.user_id = current_user.id\n\n respond_to do |format|\n if @participant_quote.save\n format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully created.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /participant_quotes/1 DELETE /participant_quotes/1.json
def destroy @participant_quote = ParticipantQuote.find(params[:id]) @participant_quote.destroy respond_to do |format| format.html { redirect_to participant_quotes_url } format.json { head :no_content } end end
[ "def destroy\n @quotes.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @awesome_quote.destroy\n respond_to do |format|\n format.html { redirect_to awesome_quotes_url }\n format.json { head...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines if a shell command exists by searching for it in ENV['PATH'].
def command_exists?(command) ENV['PATH'].split(File::PATH_SEPARATOR).any? {|d| File.exists? File.join(d, command) } end
[ "def command_in_path?(command)\n found = ENV['PATH'].split(File::PATH_SEPARATOR).map do |p|\n File.exist?(File.join(p, command))\n end\n found.include?(true)\n end", "def command_in_path?(command)\n found = ENV['PATH'].split(File::PATH_SEPARATOR).map do |p|\n File.exist?(File.join(p, co...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Marks a key readonly. Returns self.
def read_only! key set_data! key, :read_only, true self end
[ "def read_only! key\n @read_only[key] = true\n self\n end", "def readonly!\n @readonly = true\n add_class(:readonly)\n end", "def readonly! #:nodoc:\n @readonly = true\n end", "def key!\n @_key = true\n end", "def set_readonly\n readonly! if persisted? && !pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the value for key is marked 'inherited'. If so, any attempt to call []= will be ignored and the value returned from [] will the ENV[key] value at initialization.
def inherit? key ! ! (data(key, INHERIT) && data(key, DEFAULT)) end
[ "def env?(key)\n blank?(ENV[key])\n end", "def env_truthy?(k)\n self.class.env_value_truthy?(env[k.to_s])\n end", "def inherited?\n is_inherited\n end", "def has_key?(key)\n key_as_str = key.to_s\n ENV.has_key?(key_as_str)\n end", "def key_inheritable_in_parent?(*key...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the value for key is marked 'locked' If so, any attempt to call []= will be ignored.
def locked? key ! ! data(key, LOCKED) end
[ "def locked?(key)\n attributes[key].locked?\n end", "def locked?\n @locked\n end", "def locked?\n (@restriction != nil && @restriction == \"locked\") ? true : false\n end", "def is_locked=(value)\n @is_locked = value\n end", "def lockable?\n @lockable\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Executes block while setting dst with each element of env. dst is restored after completion of the block. nil values are equivalent to deleting the dst element dst defaults to the global ENV NOT THREADSAFE if dst == ENV
def with dst = nil dst ||= ENV with_env(@h, dst) do yield end end
[ "def save_env\n # ENV isn't a Hash, but a weird Hash-like object. Calling #to_hash on it\n # will copy its items into a newly created Hash instance, which then can\n # be fed into #replace. This approach ensures that any modifications of\n # ENV in the passed block won't affect the stored value....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Guarantee to read n bytes
def read_bytes(sd, n) out = [] while (n > out.size) data = sd.read_bytes(n - out.size) break unless data out = out + data end return out end
[ "def read(n)\n slice!(0,n)\n end", "def read(n)\n Buffer.new(@buffer.slice!(0, n))\n end", "def recvExactNBytes(n)\n buffer = \"\" ;\n while(buffer.size < n)\n IO::select([@socket]) ;\n buf = @socket.recv(n-buffer.size) ;\n if(buf == \"\") # in the case o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /portal_grades GET /portal_grades.xml
def index # PUNDIT_REVIEW_AUTHORIZE # PUNDIT_CHECK_AUTHORIZE # authorize Portal::Grade # PUNDIT_REVIEW_SCOPE # PUNDIT_CHECK_SCOPE (did not find instance) # @grades = policy_scope(Portal::Grade) @portal_grades = Portal::Grade.all respond_to do |format| format.html # index.html.erb ...
[ "def index\n @item_grades = @current_user.items_with_grades(@course)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @grades }\n end\n end", "def index\n @service_grades = ServiceGrade.all\n\n respond_to do |format|\n format.html # index.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /portal_grades/new GET /portal_grades/new.xml
def new # PUNDIT_REVIEW_AUTHORIZE # PUNDIT_CHECK_AUTHORIZE # authorize Portal::Grade @portal_grade = Portal::Grade.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @portal_grade } end end
[ "def new\n @staffgrade = Staffgrade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @staffgrade }\n end\n end", "def new\n @service_grade = ServiceGrade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /portal_grades POST /portal_grades.xml
def create # PUNDIT_REVIEW_AUTHORIZE # PUNDIT_CHECK_AUTHORIZE # authorize Portal::Grade @portal_grade = Portal::Grade.new(params[:portal_grade]) respond_to do |format| if @portal_grade.save flash[:notice] = 'Grade was successfully created.' format.html { redirect_to(@portal_gr...
[ "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::GradeLevel\n @portal_grade_level = Portal::GradeLevel.new(params[:portal_grade_level])\n\n respond_to do |format|\n if @portal_grade_level.save\n flash[:notice] = 'Portal::GradeLevel was successfully ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /portal_grades/1 PUT /portal_grades/1.xml
def update # PUNDIT_REVIEW_AUTHORIZE # PUNDIT_CHECK_AUTHORIZE (did not find instance) # authorize @grade @portal_grade = Portal::Grade.find(params[:id]) respond_to do |format| if @portal_grade.update_attributes(params[:portal_grade]) flash[:notice] = 'Grade was successfully updated.' ...
[ "def update\n @grade = Grade.find(params[:id])\n respond_to do |format|\n if @grade.update_attributes(params[:grade])\n format.html { redirect_to(@grade, :notice => 'Grade was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /portal_grades/1 DELETE /portal_grades/1.xml
def destroy # PUNDIT_REVIEW_AUTHORIZE # PUNDIT_CHECK_AUTHORIZE (did not find instance) # authorize @grade @portal_grade = Portal::Grade.find(params[:id]) @portal_grade.destroy respond_to do |format| format.html { redirect_to(portal_grades_url) } format.xml { head :ok } end en...
[ "def destroy\n @analysis_grade = AnalysisGrade.find(params[:id])\n @analysis_grade.destroy\n\n respond_to do |format|\n format.html { redirect_to(analysis_grades_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @grade = Grade.find(params[:id])\n @grade.destroy\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assigns the cookie string.
def cookie= cookie_str @headers['Cookie'] = cookie_str if @use_cookies end
[ "def set_cookie(name, value)\n @cookies[\"flexi_#{@id}_#{name}\"] = value\n return value\n end", "def cookie=(c)\n @cookie = c\n @dataobj.cookie = c\n end", "def set_cookie(key, value)\n\t\t\tresponse.set_cookie(key, value)\n\t\tend", "def set_cookie(cookie=nil)\n self.headers[\"Cooki...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assigns the http method.
def http_method= new_verb @http_method = new_verb.to_s.upcase end
[ "def set_method(method)\n\n # capitalize and convert to a symbol if not already a symbol\n method.upcase! if !method.kind_of? Symbol\n\n # check if the http method is valid\n valid_methods = [:GET, :PUT, :POST, :PATCH, :DELETE]\n if !valid_methods.include?(method.to_sym)\n raise Argu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decide whether to use cookies or not.
def use_cookies= bool if bool && (!@headers['Cookie'] || @headers['Cookie'].empty?) cookie = Kronk.cookie_jar.get_cookie_header @uri.to_s @headers['Cookie'] = cookie unless cookie.empty? else @headers.delete 'Cookie' end @use_cookies = bool end
[ "def accept_cookies?\n @opts[:accept_cookies]\n end", "def use_cookies= bool\n if bool && (!@headers['Cookie'] || @headers['Cookie'].empty?)\n cookie = Kronk.cookie_jar.get_cookie_header @uri.to_s\n @headers['Cookie'] = cookie unless cookie.empty?\n\n elsif !bool\n @headers....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assign whether to use ssl or not.
def ssl= bool @uri.scheme = bool ? "https" : "http" end
[ "def use_ssl?\n @use_ssl\n end", "def set_UseSSL(value)\n set_input(\"UseSSL\", value)\n end", "def ssl?\n true\n end", "def use_ssl?\n use_ssl\n end", "def enableSSL(use_ssl = true)\n\t\t\t@use_ssl = use_ssl\n\t\tend", "def ssl?\n @ssl\n end", "def set_ss...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the raw HTTP request String.
def to_s out = "#{@http_method} #{@uri.request_uri} HTTP/1.1\r\n" out << "host: #{@uri.host}:#{@uri.port}\r\n" self.http_request.each do |name, value| out << "#{name}: #{value}\r\n" unless name =~ /host/i end out << "\r\n" out << @body.to_s end
[ "def request_str\n return request().nil? ? \"\" : ::String.from_java_bytes(request())\n end", "def to_s\n out = \"#{@http_method} #{@uri.request_uri} HTTP/1.1\\r\\n\"\n out << \"Host: #{@uri.host}:#{@uri.port}\\r\\n\"\n\n http_request.each do |name, value|\n out << \"#{name}: #{value...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is for brand users to see their requests that are related to this startup
def requests @requests = @startup.requests.startup_related_requests(current_user.brand_id) .order(created_at: :desc) end
[ "def initial_requests(_requester)\n # Intentionally left blank\n end", "def init_request( request )\n url = URI.parse(@hip_base_url)\n uri_query_merge(url, \"menu\" => \"request\",\n \"bibkey\" => request.bib_id,\n \"itemkey\" => request.item_id,\n \"time\" =>Time.now.to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Analyse l'option de ligne de commande
def treat_as_option doption option = nil valeur = nil if doption.start_with? '--' doption.gsub(/^--([^=]+)=?(.*)?$/){ option = $1 valeur = $2 } else option_courte = doption[1..1] option = OPTION_LIST[option_courte] fatal_error(:unknown_...
[ "def line_options(given_opts); end", "def analyse_command_line arguments_v = nil\n arguments_v ||= ARGV\n init\n # On mémorise la dernière commande, c'est-à-dire la ligne complète fournie\n # à cette méthode.\n self.last_command = (arguments_v||[]).join(' ')\n # On ajoute cette comma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Recursivly call the transformer_worker with all the the compound data we have collected in the first pass
def transform_and_load_compounds! compound_records.each_slice(batch_size) do |compound_records_batch| transformer_worker_klass.perform_async( compound_records_batch, solr_config, cdm_endpoint, oai_endpoint, field_mappings, batch_size ) ...
[ "def each_needed_transformation(&block)\n if !block_given?\n return enum_for(:each_needed_transformation)\n end\n\n needed_transformations.each(&block)\n supercall(nil, :each_needed_transformation, &block)\n end", "def run_transforms\n # insta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
topic_reply_count is a count of posts in other users' topics
def update_topic_reply_count self.topic_reply_count = Topic .joins("INNER JOIN posts ON topics.id = posts.topic_id AND topics.user_id <> posts.user_id") .where("posts.deleted_at IS NULL AND posts.user_id = ?", self.user_id) .distinct .count end
[ "def reply_count\n replies.size\n end", "def number_of_replies\n self.forum_posts.count - 1\n end", "def topic_count\n return @topic_count\n end", "def topics_count\n object.topics.count\n end", "def topics_count\n if self.class.topics_count_column?\n self[:top...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queue jobs for OauthTokenRefreshWorker. Accounts whose OAuth tokens will expire in the next 25 minutes will have their tokens refreshed.
def perform Account.tokens_expiring_soon(Time.zone.now).each do |account| OauthTokenRefreshWorker.perform_async(account.id) end end
[ "def perform(_last_occurrence, current_occurrence)\n lower_bound = Time.zone.at(current_occurrence.floor)\n upper_bound = Time.zone.at(current_occurrence.ceil + 1) + 25.minutes\n\n Account.\n joins(:user).\n where(oauth_expires: lower_bound..upper_bound).\n pluck(:id).\n each do |id|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns under supervision clinics and examining clinics
def related_clinics _clinics = [] under_supervision_clinics.each do |c| unless _clinics.include?(c) _clinics.append(c) end end clinics.each do |c| unless _clinics.include?(c) _clinics.append(c) end end return _clinics end
[ "def has_related_clinics?\n if under_supervision_clinics.count > 0 || clinics.count > 0\n return true\n end\n return false\n end", "def collect_crime_information\n ### Crime information\n mark_data_crime_information = Array.new\n crime_information = @case_details[:case][:system][:crime]\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all patient in under supervision clinics or patient which has registered by user.
def related_patients _patients=[] under_supervision_clinics.each do |clinic| clinic.registrations.each do |reg| unless _patients.include?(reg.patient) _patients.append(reg.patient) end end end registrations.each do |reg| unless _patients.include?(reg.patient)...
[ "def patients \n # patients = []\n # Appointment.all.each do | appointment |\n # if appointment.doctor == self \n # patients << appointment.patient\n # end\n # end\n # patients\n all_app = Appointment.all.select do | appointment |\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all under supervision Studies plus related Studies.
def related_studies _studies = [] under_supervision_studies.each do |study| unless _studies.include?(study) _studies.append(study) end end studies.each do |study| unless _studies.include?(study) _studies.append(study) end end return _studies end
[ "def studies\n connection.get('studies.json').body['studies']\n end", "def case_studies\n case_studies = []\n stacks.case_studies.all.each do |stack|\n case_studies << stack.stackable\n end\n case_studies\n end", "def diagnostic_studies\n get_data_elements('diagnostic_study')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if User has at least one related Patient
def has_related_patient? if registrations.count > 0 return true end under_supervision_clinics.each do |clinic| clinic.registrations.each do |reg| return true end end return false end
[ "def patient_exists\n if self.patient?\n return true\n else\n patient = User.find_by(phone_number: self.patient_phone_number)\n if patient.nil?\n return false\n else\n return true\n end\n end\n end", "def patient_implicit?\n @authorized_user.patients.size == 1 ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if User has at least one related Clinic
def has_related_clinics? if under_supervision_clinics.count > 0 || clinics.count > 0 return true end return false end
[ "def check_clinics(clinic_ids, user)\n\t\tunless clinic_ids && !clinic_ids.empty?\n\t\t\treturn false\n\t\tend\n\t\tclinic_ids.each do |clinic_id|\n\t\t\tclinic = Clinic.find(clinic_id)\n\t\t\tunless user.related_clinics.include?(clinic)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend", "def cab...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if User is a supervisor of at least one Clinic
def is_supervisor? not under_supervision_clinics.empty? end
[ "def valid_supervisor_for?(user)\n if user == self\n false\n elsif nested_supervisors.include? user\n false\n else\n true\n end\n end", "def is_staff?(user)\n Role.has_entry? user, :staff, self\n end", "def can_contact? user\n if is_admin?\n return true\n else\n s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if User has access to Study
def can_edit_study(study_id) study = Study.find(study_id) if study if study.admin == self return true end study.users.each do | user | if user == self return true end end end return false end
[ "def may_view\n @study and @study.can_be_viewed_by current_user\n end", "def current_user_has_student_privileges?\n current_user_has_privileges_of?('Student')\n end", "def student_access_allowed?\n return true if scopes.include_any?(Scopes::READ_ALL)\n if username && scopes.include_any?(Scopes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if user is approved or is admin (devise overrides)
def active_for_authentication? super && (approved? || self.admin) end
[ "def approved_user?\n \t(self.user && self.user.approved) || (self.user && self.user.admin?)\n \tend", "def is_auto_approve_admin?\n @is_auto_approve && (@admin_id == Admin::AUTO_APPROVE_ADMIN_ID)\n end", "def approved?\n (status == ConfigCenter::User::APPROVED)\n end", "def user_is_ad...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
execute a block scoped to the current tenant unsets the current tenant after execution
def with_tenant(tenant, &block) Multitenant.current_tenant = tenant Multitenant.in_block = true save_and_change_default_scope_for_all yield ensure restore_default_scope Multitenant.in_block = false Multitenant.current_tenant = nil end
[ "def without_tenant\n old_current = self.current\n self.current = nil\n yield if block_given?\n ensure\n self.current = old_current\n end", "def with_tenant(tenant, &block)\n self.current_tenant = tenant\n yield\n ensure\n self.current_tenant = nil\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extract long flag name
def long_name long.to_s.sub(/^(--.+?)(\s+|\=|\[).*$/, "\\1") end
[ "def long_flag_syntax\n @long_flag_syntax ||= flag_syntax.find_all { |ss| ss.flag_style == :long }\n end", "def extract_long_flag(objects, config); end", "def long_name\n n = name\n n += \" (\" if version.present? || language.present?\n n += \"rev#{ version }\" if version.present?\n n += \"-...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /rental_cars POST /rental_cars.json
def create @rental_car = RentalCar.new(rental_car_params) respond_to do |format| if @rental_car.save format.html { redirect_to rental_cars_path, notice: 'Rental car was successfully created.' } format.json { render :index, status: :created, location: @rental_car } else forma...
[ "def create\n @car = Car.new(car_params)\n\n if @car.save\n render json: @car, status: :created, location: @car\n else\n render json: @car.errors, status: :unprocessable_entity\n end\n end", "def create\n @car = Car.new(car_params)\n\n if @car.save\n render json: @car, status: :c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /rental_cars/1 PATCH/PUT /rental_cars/1.json
def update respond_to do |format| if @rental_car.update(rental_car_params) format.html { redirect_to rental_cars_path, notice: 'Rental car was successfully updated.' } format.json { render :index, status: :ok, location: @rental_car } else format.html { render :edit } form...
[ "def update\n @car = Car.find(params[:id])\n \n if @car.update(car_params)\n render json: @car, status: :ok \n else\n render json: @car.errors, status: :unprocessable_entity\n end\n end", "def update\n @car = Car.find(params[:id])\n\n if @car.update(car_params)\n head :no_cont...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /rental_cars/1 DELETE /rental_cars/1.json
def destroy @rental_car.destroy respond_to do |format| format.html { redirect_to rental_cars_url, notice: 'Rental car was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @car = Car.find(params[:id])\n \n if @car.destroy\n render json: @car, status: :ok \n else\n render json: @car.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @car = Car.find(params[:id])\n @car.destroy\n\n respond_to do |format|\n format.h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Indicates whether the renderer handles animations or not. false indicates that slides should not be repeated.
def handles_animation? false end
[ "def animated?\n @animated\n end", "def animated?\n !@animation.nil?\n end", "def animation?\n return @animation != nil\n end", "def animated?\n max_order > 0\n end", "def animate_scenes_reversed?\n default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:animate_scenes_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Model.human_name is deprecated. Use Model.model_name.human instead.
def human_name(*args) ActiveSupport::Deprecation.warn("human_name has been deprecated, please use model_name.human instead", caller[0,1]) model_name.human(*args) end
[ "def human_model name=nil, pluralize=false\n s = model(name).human_name\n s = s.pluralize if pluralize && pluralize != 1\n s\n end", "def good_human_name\n name\n end", "def human_name\n self.model_class ? self.model_class.human_attribute_name(@name) : human_name_without_localization\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
resource wrappers (wrapped around Localeze elements) element 2935 get categories
def get_categories body = build_request(2935, 1501, "ACTIVEHEADINGS") response = send_to_localeze(body) xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text) end
[ "def categories\n @categories ||= (@doc/\"Category\").collect { |it| Element.new(it) }\n end", "def categories\n @categories ||= @entry_element.select_all(\"./atom:category\").map do |category_element|\n Category.new(category_element.attr(\"term\"), category_element.attr(\"scheme\"))\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the decimalPlaces property value. How many decimal places to display. See below for information about the possible values.
def decimal_places return @decimal_places end
[ "def decimal_places=(value)\n @decimal_places = value\n end", "def number_format(decimal_places = 2)\n return \"%.#{decimal_places}f\" % self\n end", "def to_decimals decimals = 2\n \"%.#{decimals}f\" % self\n end", "def places(value = nil, options = {})\n if value.nil?\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the decimalPlaces property value. How many decimal places to display. See below for information about the possible values.
def decimal_places=(value) @decimal_places = value end
[ "def decimal_places\n return @decimal_places\n end", "def number_format(decimal_places = 2)\n return \"%.#{decimal_places}f\" % self\n end", "def precision=(val)\n self['precision'] = val\n end", "def round_to(decimal_places)\n to_f.round(decimal_places)\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the displayAs property value. How the value should be presented in the UX. Must be one of number or percentage. If unspecified, treated as number.
def display_as return @display_as end
[ "def display_as=(value)\n @display_as = value\n end", "def show_percentage\n return @show_percentage\n end", "def show_as=(value)\n @show_as = value\n end", "def display_format\n value = self.format_str ||\n I18n.t(self....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the displayAs property value. How the value should be presented in the UX. Must be one of number or percentage. If unspecified, treated as number.
def display_as=(value) @display_as = value end
[ "def show_as=(value)\n @show_as = value\n end", "def display=(value)\n @display = value\n end", "def display_as\n return @display_as\n end", "def setDisplayFormat(displayFormat)\r\n\t\t\t\t\t@displayFormat = displayFormat\r\n\t\t\t\tend", "def disp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the minimum property value. The minimum permitted value.
def minimum return @minimum end
[ "def min\n read_attribute(:min) or ( input and input.min )\n end", "def min\n raise AnyError, \"No min value for type #{self}\"\n end", "def minimum=(value)\n @minimum = value\n end", "def minimum\n 0\n end", "def min_m\n @min_m\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the minimum property value. The minimum permitted value.
def minimum=(value) @minimum = value end
[ "def set_Minimum(value)\n set_input(\"Minimum\", value)\n end", "def min=(value)\n MSPhysics::Newton::Piston.set_min(@address, value)\n end", "def set_min( min )\n if IntegerOption.bounds_ok?( min, @max )\n @min = min\n else\n @min = nil\n raise \"invalid lower bound...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin i: array with 'faces'strings o: number of smiling faces r: face has : or ; face may have or ~ face has ) or D nothing else! f: loop throug faces if 2 long: index 0 in valid eyes index 1 in valid mouth if 3 long: index 0 in valid eyes index 1 in valid nose index 2 in valid mouth if valid face up counter output co...
def countSmileys(faces) valid_eyes = [':', ';'] valid_nose = ['-', '~'] valid_mouth = [')', 'D'] counter = 0 faces.each do |face| case face.size when 2 if valid_eyes.include?(face[0]) && valid_mouth.include?(face[1]) counter += 1 end when 3 if valid_eyes.incl...
[ "def count_smileys(arr)\n count = 0\n arr.each do |face|\n case\n when face == \":)\"\n count += 1\n when face == \":-)\"\n count += 1\n when face == \":~)\"\n count += 1\n when face == \":D\"\n count += 1\n when face == \":-D\"\n count += 1\n wh...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a movie and redirect to the movies page.
def destroy @movie = Movie.find params[:id] @movie.destroy flash[:notice] = "Deleted '#{@movie.title}'." redirect_to movies_path end
[ "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if SSH connection is closed +connection+:: SSH connection to check
def closed?(connection) return true if connection.closed? begin # Hack to check connection isn't dead connection.exec!('true') unless connection.busy? rescue Net::SSH::Exception, SystemCallError => e return true end return false end
[ "def closed?\n @connection_state == :closed\n end", "def ssh_alive? address\n socket = TCPSocket.open address, 22\nrescue SystemCallError\nensure\n socket.close if socket\nend", "def close_ssh\n puts \"Close connection\"\n @ssh.close unless @ssh.closed?\n end", "def closed?()\n @connec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if SSH connection is busy +connection+:: SSH connection to check
def busy?(connection) connection.busy? end
[ "def closed?(connection)\n return true if connection.closed?\n begin \n # Hack to check connection isn't dead\n connection.exec!('true') unless connection.busy?\n rescue Net::SSH::Exception, SystemCallError => e\n return true\n end\n return false\n end", "def busy?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get new SSH connection
def get_new logger.debug "Establishing connection for #{creep.user}@#{creep.host} passwd:#{creep.password}" ssh = Net::SSH.start(creep.host, creep.user, {:password => creep.password, :verbose => (ENV['SSH_DEBUG'] && ENV['SSH_DEBUG'].to_sym) || :fatal }) ssh.send_global_request("keepalive@openssh.com"...
[ "def ssh\n @connection ||= @ssh.connect\n return @ssh\n end", "def ssh_connection\n @ssh_connection ||= Net::SSH.start(@host, config[:user], config[:ssh_options] || {})\n end", "def ssh\n @ssh ||= @remote.connect\n @remote\n end", "def getSSHConnectionHelper()\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Kill SSH connection +connection+:: SSH connection
def kill_connection(connection) connection.shutdown! end
[ "def disconnect_ssh_tunnel\n @logger.debug('closing SSH tunnel..')\n\n @ssh.shutdown! unless @ssh.nil?\n @ssh = nil\n end", "def disconnect_ssh_tunnel\n @log.debug('closing SSH tunnel..')\n\n @ssh.shutdown! unless @ssh.nil?\n @ssh = nil\n end", "def close_ssh\n puts \"Close connection\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return name of the key in the response body hash where fetched resources are, like bookings or rentals
def resources_key decoded_body.keys.delete_if { |key| SPECIAL_JSONAPI_FIELDS.include?(key) }.pop end
[ "def resource_names\n JSON.parse(@body).fetch('Resources', {}).keys\n end", "def resource_key\n resource\n end", "def label_name(bucket,key)\n JsonTemplate.nested_hash_value(JSON.parse(self.content), key, bucket)[\"name\"] rescue nil\n end", "def name\n json[\"name\"] || recipe_name\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return an array of Resources from the response body
def resources @resources ||= process_data(decoded_body[resources_key]) end
[ "def resources\n @resources ||= @response[@resource_field].to_a\n end", "def resource_names\n JSON.parse(@body).fetch('Resources', {}).keys\n end", "def resources\n @resources ||= []\n end", "def resource_objects\n @body['provision']['resource']\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Hash of meta information taken from the response body
def meta @meta ||= decoded_body[:meta] end
[ "def meta\n fail ResponseError, 'Cannot fetch meta for non JSON response' unless json?\n\n json_body.fetch('meta', {})\n end", "def meta\n json_body.fetch('meta', {})\n end", "def unpack_meta(response)\n response.body['meta'] if response.body.has_key?('meta')\n end", "def meta_inf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PROBLEM: Given a string, write a method change_me which returns the same string but with all the words in it that are palindromes uppercased. input: string output: string (not the same object) rules: Explicit requirements: every palindrome in the string must be converted to uppercase. (Reminder: a palindrome is a word ...
def change_me(string) result = [] words = string.split iterator = 0 loop do break if iterator == words.size word = words[iterator] if word.reverse == word result << word.upcase else result << word end iterator += 1 end result.join(' ') end
[ "def change_me(str)\n str_array = str.split\n str_array.each { |word| word.upcase! if word.reverse == word }\n return str_array.join(' ')\nend", "def reverse_each_word(setence1)\n\n old_array = string.split(\" \")\n return_array = []\n old_array.each do|sentence1|\n return_array << sentence1.reverse\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /telefons/1 PUT /telefons/1.xml
def update @telefon = Telefon.find(params[:id]) @telefon.update_attributes(params[:telefon]) respond_with(@telefon) end
[ "def update\n @tipo_telefone = TipoTelefone.find(params[:id])\n\n respond_to do |format|\n if @tipo_telefone.update_attributes(params[:tipo_telefone])\n flash[:notice] = 'TipoTelefone was successfully updated.'\n format.html { redirect_to(@tipo_telefone) }\n format.xml { head :ok }\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }