query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
DELETE /high_schools/1 DELETE /high_schools/1.json
def destroy @high_school.destroy respond_to do |format| format.html { redirect_to high_schools_url, notice: 'High school was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @highschool = Highschool.find(params[:id])\n @highschool.destroy\n\n respond_to do |format|\n format.html { redirect_to highschools_url }\n format.json { head :ok }\n end\n end", "def destroy\n @school = School.find(params[:id])\n @school.destroy\n\n respond_to do |f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /pickup_point_time_details GET /pickup_point_time_details.json
def index @pickup_point_time_details = PickupPointTimeDetail.includes(:route, :location, :pickup_route_start_time) end
[ "def show\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_point }\n end\n end", "def create\n @pickup_point_time_detail = PickupPointTimeDetail.new(pickup_point_time_detail_params)\n\n respond_to do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /pickup_point_time_details POST /pickup_point_time_details.json
def create @pickup_point_time_detail = PickupPointTimeDetail.new(pickup_point_time_detail_params) respond_to do |format| if @pickup_point_time_detail.save format.html { redirect_to pickup_point_time_details_path, notice: 'Pickup point time detail was successfully created.' } format.json {...
[ "def create\n @drop_point_time_detail = DropPointTimeDetail.new(drop_point_time_detail_params)\n\n respond_to do |format|\n if @drop_point_time_detail.save\n format.html { redirect_to drop_point_time_details_path, notice: 'Drop point time detail was successfully created.' }\n format.json { ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /pickup_point_time_details/1 PATCH/PUT /pickup_point_time_details/1.json
def update respond_to do |format| if @pickup_point_time_detail.update(pickup_point_time_detail_params) format.html { redirect_to pickup_point_time_details_path, notice: 'Pickup point time detail was successfully updated.' } format.json { render :show, status: :ok, location: @pickup_point_time_...
[ "def update\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n if @time_point.update_attributes(params[:time_point])\n format.html { redirect_to @time_point, notice: 'Time point was successfully updated.' }\n format.json { head :no_content }\n else\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /pickup_point_time_details/1 DELETE /pickup_point_time_details/1.json
def destroy @pickup_point_time_detail.destroy respond_to do |format| format.html { redirect_to pickup_point_time_details_url, notice: 'Pickup point time detail was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @drop_point_time_detail.destroy\n respond_to do |format|\n format.html { redirect_to drop_point_time_details_url, notice: 'Drop point time detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_point = TimePoint.find(params...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin def start_date start_date end def rental_days rental_days end =end
def last_day start_date + rental_days.days end
[ "def rental_days\n 1 + (@end_date - @start_date).to_i\n end", "def rental_days\n\t\trental_days = 1 + (Date.parse(@end_date) - Date.parse(@start_date)).to_i\n\tend", "def days_booked\n end_date - start_date\n end", "def number_of_days(rental)\n\tnumber_of_days = (rental.end_date - rental.start_date)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wait section ==================================================== This function wait for Freelancer page to be visible
def wait_for_freelancer_page_visible sleep 15 end
[ "def wait_for_page_to_load\n @wait_on.each { |element| wait_for_element(element) }\n end", "def wait_to_load\n activity_div.wait_until(&:exists?)\n @page = @bank_page.load_page\n end", "def wait_page_load\n browser.wait_for_load\n end", "def wait_page_load\n @browser.wait_for_load\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function wait for Freelancer Skills to Be displayed
def wait_for_freelancer_skills_displayed wait_for_element_present@driver.find_elements(:xpath, FREELANCER_SKILLS) end
[ "def wait_for_freelancer_page_visible\n sleep 15\n end", "def wait_for_company_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS)\n end", "def is_freelancer_skills_displayed\n @driver.find_element(:xpath, FREELANCER_SKILLS).displayed?\n end", "def flash_card_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function wait for Company Skills to bo visible
def wait_for_company_skills_displayed wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS) end
[ "def wait_for_freelancer_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, FREELANCER_SKILLS)\n end", "def is_company_skills_displayed\n @driver.find_element(:xpath, COMPANY_SKILLS).displayed?\n end", "def wait_for_elements\n @wait_on << :loan_button\n @wait_on << :item_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is Displayed Section ============================================ This function verifying is Freelancer title visible
def is_freelancer_title_displayed @driver.find_element(:xpath, FREELANCER_TITLE).displayed? end
[ "def display_header?\n !@request.hide_title?\n end", "def section_visible?\n root_element.visible?\n end", "def is_freelancer_description_displayed\n @driver.find_element(:xpath, FREELANCER_DESCRIPTION).displayed?\n end", "def preview_content?\n !!definition[\"as_element_title\"]\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function verifying is Company title visible
def is_company_title_displayed @driver.find_element(:xpath, COMPANY_TITLE).displayed? end
[ "def is_freelancer_title_displayed\n @driver.find_element(:xpath, FREELANCER_TITLE).displayed?\n end", "def title_good?\n @page.css('title').size == 1 && @page.css('title').text.size < 70 if @page\n end", "def page_title\n\n # expect=\"User Management\"\n # actual=self.title_element.text...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function verifying is Freelancer description displayed
def is_freelancer_description_displayed @driver.find_element(:xpath, FREELANCER_DESCRIPTION).displayed? end
[ "def has_description?\r\n (@description.to_s != '')\r\n end", "def description_shown?(passed, spec)\n specdoc_shown?(passed) || console_for_spec?(spec) || errors_for_spec?(spec)\n end", "def has_description?\n @desc and @desc.is_a? String and @desc.length > 0\n end", "def has_d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function verifying is Freelancer Skills displayed
def is_freelancer_skills_displayed @driver.find_element(:xpath, FREELANCER_SKILLS).displayed? end
[ "def is_company_skills_displayed\n @driver.find_element(:xpath, COMPANY_SKILLS).displayed?\n end", "def verify_admission_preview(options={})\n texts = get_text(\"css=#content\")\n texts.include?(options[:acct_class])== true\n #texts.include?(options[:patient]) == true\n #texts.include?(options[:pi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function verifying is Company Skills displayed
def is_company_skills_displayed @driver.find_element(:xpath, COMPANY_SKILLS).displayed? end
[ "def wait_for_company_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS)\n end", "def is_freelancer_skills_displayed\n @driver.find_element(:xpath, FREELANCER_SKILLS).displayed?\n end", "def partner_info_verify(partner)\n h3_section.text.eql?(partner.company_in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /promotions/new GET /promotions/new.json
def new @title = t('admin.promotions.new.title') @promotion = Promotion.new respond_to do |format| format.html # new.html.erb format.json { render json: @promotion } end end
[ "def new\n @promoter = Promoter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @promoter }\n end\n end", "def new\n @promocion = Promocion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prom...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the current loggedin author (if any)
def current_author Author.find(current_user.id) unless current_user.nil? end
[ "def get_author\n @current_author ||= session[:current_user_id] && Author.find(session[:current_user_id])\n end", "def get_author_username\n return User.find_by(id: self.author_id).username\n end", "def author_name\n user_data.name || login\n end", "def author\n return...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the Move method that takes a array, position and value.
def move(array,position,value = "X") array[position.to_i - 1] = value end
[ "def move=(value)\n @move = value\n end", "def change(move)\n value = self.dup\n value[0] += move[0]\n value[1] += move[1]\n Position.new(value)\n end", "def move(board, position, token=\"X\")\n board[position.to_i - 1] = token \nend", "def move(board, index, c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get all users in the graph
def get_users(neo) cypher_query = ' START me = node:nodes_index(type = "user")' cypher_query << ' RETURN ID(me), me.name' cypher_query << ' ORDER BY ID(me)' neo.execute_query(cypher_query)['data'] end
[ "def users\n User.where(network_id: context[:current_network]&.id)\n end", "def list_users\n response = Flareshow::Service.query({:flows=>{:id => self.id, :limit => 1, :include=>['users']}})\n (Flareshow::CacheManager.assimilate_resources(response[\"resources\"]) || {})[\"users\"]\n end", "def fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get all repo's with a follow_count > 2
def get_repos(neo) # return repo's that have more than 1 connection # TODO: try this; n<-r[follows*2..]-m cypher_query = ' START n = node:nodes_index(type = "repo")' cypher_query << ' MATCH n<-[r:follows]-m' cypher_query << ' WITH n, count(m) AS follow_count' cypher_query << ' WHERE follow_count > 2' cypher_qu...
[ "def repositories\n Repository.where(user_id: group_ids).or(membered_repositories).order(\"updated_at desc\")\n end", "def find_users_with_shared_repos\n\n (friends - [self]).sort_by do |f|\n f.repos.select { |r| repos.collect { |s| s.id }.include?(r.id) }.size\n end.reverse\n\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get the users for a repo
def get_users_for_repo(neo, repo) neo.traverse(repo, 'nodes', { :order => 'breadth first', :uniqueness => 'node global', :relationships => { :type => 'follows', :direction => 'in' }, }) end
[ "def get_repo_users\n repo_users = Array.new\n github = Github.new :oauth_token => github_token\n\n github.repos.list.body.each do |repo|\n repo_users << repo[\"owner\"][\"login\"]\n end\n\n repo_users\n end", "def get_user_repos(username)\n get_organized_repos(@octokit.repositories(user...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get the relationships for a repo, with user id and user name
def get_relationships_for_repo(neo, repo) cypher_query = ' START user = node:nodes_index(type = "user"), repo = node:nodes_index(type = "repo")' cypher_query << ' MATCH user-[r:follows]->repo' cypher_query << ' WHERE ID(repo) = {repo_id}' cypher_query << ' RETURN ID(user), user.name' neo.execute_query(cypher_qu...
[ "def relationships\n model.relationships(repository.name)\n end", "def find_repos(user)\n user.repos\n end", "def get_users_for_repo(neo, repo)\n\n\tneo.traverse(repo, 'nodes', {\n\t\t:order => 'breadth first',\n\t\t:uniqueness => 'node global',\n\t\t:relationships => {\n\t\t\t:type ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
build json for longest paths
def get_longest_path(clear_cache = false) File.delete(longest_cache_file) if clear_cache && File.exist?(longest_cache_file) if File.exist?(longest_cache_file) content_type :json unless is_rake send_file longest_cache_file else neo = Neography::Rest.new(ENV['NEO4J_URL'] || 'http://localhost:7474') out =...
[ "def generate_json(path); end", "def paths_to_json\n JSON.unparse(paths_to_array) \n end", "def longest_path_1(edges)\nend", "def pieces_to_json_path(pieces)\n json_path = ''\n pieces.each do |piece|\n if piece.is_a?(Integer)\n json_path += \"[#{piece}]\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Show the details of one place
def show @place = Place.find_by(:id=> params["id"]) end
[ "def show\n @place_information = PlaceInformation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @place_information }\n end\n end", "def show_place_detail(params, options = {})\n query_str = params[:text]\n query_str = quer...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a place from the database
def delete @place = Place.find_by(:id => params["id"]) # Find out what link has been clicked @place.delete # Delete the item which has been clicked redirect_to root_url # Show home page to verify that the place has been deleted end
[ "def destroy\n @place = Place.find(params[:id])\n @place.destroy\n redirect_to places_path\n end", "def delete\n CONNECTION.execute(\"DELETE FROM locations WHERE id = #{self.id};\")\n end", "def destroy\n place = Place.with_permissions_to(:read).find(params[:id])\n if place.destroy\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert all fonts to ems
def convert_fonts out = "" sass.each_line do |line| line.gsub!(/(\s*)(word-spacing|letter-spacing|font-size|line-height|margin-[^\s]+|margin|padding-[\s]+|padding)\s*:(.*)/) do |m| # indent rule: value m = "#{$1}#{$2}: #{CSS.val_to_em($3)}" end o...
[ "def convert_em(el, opts)\n # TODO: add mechanism to verify that we have processed all classes\n before = ''\n after = ''\n inner_text = nil\n case\n when [nil, ''].include?(el.attr['class'])\n # em without class => convert to \\emph{}\n before << '\\\\emp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replace body css rule and add it to the above rule using the sass '&'
def rename_body puts "renaming sass body element" self.sass.gsub!(/^(\s*)body\n/, "\n#{$1}&\n") end
[ "def write_unmergable_css_rules(doc, unmergable_rules) # :nodoc:\n styles = unmergable_rules.to_s\n\n unless styles.empty?\n style_tag = \"<style type=\\\"text/css\\\">\\n#{styles}</style>\"\n if body = doc.search('body')\n if doc.at_css('body').children && !doc.at_css('bo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
CSS directives must be top levl We namespace the css so these will bork So loop through identifying directives and remove them an anything indented inside
def move_css_directives puts "moving css directives to top of file" css_directives = "" new_sass = "" directive_indent = 0 # Go through the lines rewriting paths as appropriate sass.each_line do |line| sass_line = SassLine.new(@epub, self, line.to_s, directive_...
[ "def strip_directive_whitespace( tree )\n\t\t# Make a flat list of all nodes\n\t\tnodes = tree.collect {|node| node.to_a}.flatten\n\n\t\t# Elide non-rendering directive lines. Match node lists like:\n\t\t# <TextNode> =~ /\\n\\s*$/\n\t\t# <NonRenderingNode>*\n\t\t# <TextNode> =~ /^\\n/\n\t\t# removing one \"\\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays a progress indicator for a given message. This progress report is only displayed on TTY displays, otherwise the message is passed to the +nontty_log+ level.
def progress(msg, nontty_log = :debug) send(nontty_log, msg) if nontty_log return unless show_progress icon = "" if defined?(::Encoding) icon = PROGRESS_INDICATORS[@progress_indicator] + " " end @mutex.synchronize do print("\e[2K\e[?25l\e[1m#{icon}#{msg}\e[0m\r") ...
[ "def progress(msg, nontty_log = T.unsafe(nil)); end", "def log(message)\n\t\tif !@progress_dialog.nil?\n\t\t\t@progress_dialog.logMessage(message)\n\t\telse\n\t\t\tputs message\n\t\tend\n\tend", "def report_progress(progress, total, show_parts=true)\n if total && total > 0\n percent = (progress....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clears the progress indicator in the TTY display.
def clear_progress return unless show_progress print_no_newline("\e[?25h\e[2K") @progress_msg = nil end
[ "def clear_progress\n self.status nil\n end", "def clear_progress; end", "def complete_progress\n # Just clear the line back out\n print \"#{cl_reset}\"\n end", "def clear\n SimCtl.status_bar_clear(device)\n end", "def clear\n @mutex.synchronize do \n write(LCD_C...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints the backtrace +exc+ to the logger as error data.
def backtrace(exc, level_meth = :error) return unless show_backtraces send(level_meth, "#{exc.class.class_name}: #{exc.message}") send(level_meth, "Stack trace:" + exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n") end
[ "def error exception, backtrace = nil\n backtrace ||= exception.backtrace\n unless backtrace.is_a? Array\n backtrace = [ backtrace ]\n end\n\n Railroader.debug exception\n Railroader.debug backtrace\n\n @errors << { :error => exception.to_s.gsub(\"\\n\", \" \"), :backtrace => backtrace }\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Warns that the Ruby environment does not support continuations. Applies to JRuby, Rubinius and MacRuby. This warning will only display once per Ruby process.
def warn_no_continuations end
[ "def warn_no_continuations; end", "def silence_fork_callback_warning\n @options[:silence_fork_callback_warning] = true\n end", "def continuable?\n\t\ttrue\n\tend", "def silence_single_worker_warning; end", "def jruby_skip(message = '')\n skip message if defined?(JRUBY_VERSION)\nend", "def jruby_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes and returns an Iterator
def iter @iter ||= Iterator.new(self) end
[ "def iter\n @iter ||= IteratorBase.new(self)\n end", "def iter\n @iter ||= Iterator.new(self)\n end", "def begin_iterator\n ListIterator.new @head, self\n end", "def create_stream_iterator; self end", "def iterator()\n return SBAComplexObjectIterator.new(self)\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Comparing elevator to previous best
def checkBestElevator(scoreToCheck, newElevator, bestElevatorInfo, floor) #If elevators situation is more favourable if scoreToCheck < bestElevatorInfo[1] bestElevatorInfo[1] = scoreToCheck bestElevatorInfo[0] = newElevator bestElevatorInfo[2] = (n...
[ "def elevator(left, right, call)\n (call - left).abs < (call - right).abs ? \"left\" : \"right\"\nend", "def elevator\n elevators.sort_by { |e| e.stop_count }.first\n end", "def find_close_elv_and_setlevel(lev)\nclosest_elevator = find_closest_elv(lev) #compute closest elevator. should i pass close...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End getters Method to create floor request buttons
def makeFloorRequestButton floorRequestButtonFloor = 1 for i in 1..@amountOfFloors floorRequestButton = FloorRequestButton.new(i, 'off', floorRequestButtonFloor) @floorRequestButtonsList.push(floorRequestButton) floorRequestButtonFloor += 1 ...
[ "def create_floor_buttons\n for floor in 1..Elevator.num_floors do\n button = FloorButton.new(floor, self)\n @floor_buttons.append(button)\n end\n end", "def create_call_buttons\n \n for floor in 1..Elevator.num_floors do\n \n up_btn = Cal...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
User requesting floor inside elevator
def requestFloor(floor) puts "The elevator is requested to move to floor #{floor}." @floorRequestList.push(floor) sortFloorList() puts "Elevator is moving." moveElevator() puts "Elevator is #{@status}." doorController() if @...
[ "def floor_request(floor)\n elevator = elevators.find { |e| e.current_floor == floor } # this is wrong\n elevator.floor_request(floor) if elevator\n end", "def request_floor(elevator_object, requested_floor)\n sleep(0.5)\n puts(\">>> User wants to go to floor #{requested_floor} <<<\")\n sleep(0.5)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sorting floor request list
def sortFloorList if @direction == 'up' @floorRequestList.sort! elsif @direction == 'down' @floorRequestList.sort!.reverse end end
[ "def sortFloorList()\n if @direction == \"up\"\n @floorRequestList.sort!()\n else\n @floorRequestList.sort!()\n @floorRequestList.reverse!()\n end\n end", "def sort_entries; end", "def sort_requests_queue\n request = @re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /mission_memberships GET /mission_memberships.json
def index @mission_memberships = MissionMembership.all end
[ "def GetMemberships params = {}\n\n params = params.merge(path: 'group_memberships.json')\n APICall(params)\n\n end", "def fetch_memberships(token, params)\n params.to_options!\n \n # Setup params.\n setup_params_logic = lambda do |last_request, params|\n # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /mission_memberships POST /mission_memberships.json
def create @mission_membership = MissionMembership.new(mission_membership_params) respond_to do |format| if @mission_membership.save format.html { redirect_to @mission_membership, notice: 'Mission membership was successfully created.' } format.json { render :show, status: :created, locati...
[ "def create\n logger.info \"Post parameters memberships: #{params}\"\n @membership = @group.memberships.create(user: @user, admin: params[:membership][:admin] )\n if @membership.save\n render json: @membership, status: :created, location: [@group, @membership]\n else\n render json: @membership...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /mission_memberships/1 PATCH/PUT /mission_memberships/1.json
def update respond_to do |format| if @mission_membership.update(mission_membership_params) format.html { redirect_to @mission_membership, notice: 'Mission membership was successfully updated.' } format.json { render :show, status: :ok, location: @mission_membership } else format....
[ "def update\n if @membership.update(membership_params)\n render json: @membership, status: :ok\n else\n render json: @membership.errors, status: :unprocessable_entity\n end\n end", "def update\n @membership = @group.memberships.find(params[:id])\n if @membership.update_attributes(params[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /mission_memberships/1 DELETE /mission_memberships/1.json
def destroy @mission_membership.destroy respond_to do |format| format.html { redirect_to mission_memberships_url, notice: 'Mission membership was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @membership.destroy\n\n head :no_content\n end", "def destroy\n @membership.destroy\n head :no_content\n end", "def destroy\n @oa_membership = OA_Membership.find(params[:id])\n @oa_membership.destroy\n\n respond_to do |format|\n format.html { redirect_to oa_memberships...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dispatch remaining units in owned territories. Used when the user didn't do it himself during deployment.
def dispatch_remaining_units! Participation.transaction do shuffled_ownerships = ownerships.shuffle 1.upto(units_count) do ownerships.sample.deploy_units!(1) end end end
[ "def manipulation_units\n raise \"Not implemented yet!\"\n end", "def compute_free_places\n max_participants - compute_occupied_places\n end", "def unit_menu\n units = current_user.units\n render :partial => \"shared/unit_menu\", :locals => {:units => units, :current_unit => current_unit}\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method that adds git repo (if it does not exist)
def add_repo_git(dir) if not Dir.exist?("#{dir}/.git") system_commands("git init #{dir}") end end
[ "def add(path, param=File.split(path).last)\n unless self.has_repo?(param)\n begin\n list << Repo.new(path)\n rescue Rugged::RepositoryError\n logger.warn \"SKIPPING '#{path}' - not a git repository\"\n end\n end\n list\n end", "def git(path)\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method that checks and adds or not the remote github url
def add_remoteurl(dir) vConfig(CONFIG['configWebsite']) read_json(CONFIG['configWebsite']) remoteURL = @parse_json_config['deploy']['github']['config']['remoteURL'] remoteVerify = `sed -n '/url/p' #{dir}/.git/config | cut -d'=' -f2 | cut -d' ' -f2` if remoteVerify.nil? || remoteVerify.empty? s...
[ "def has_github?\n !github_url.blank?\n end", "def github?\n !!(remote.to_s =~ /github.com/)\n end", "def github_remote?(remote = @remote)\n remote_url(remote).host == 'github.com'\n end", "def github?\n @repo.include?('github.com')\n end", "def github_url\n [homepage, s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The color of this user's messages.
def name_color # HACK(pwnall): come up with better colors user.key == @room.user1.key ? 'red' : 'blue' end
[ "def message_color; end", "def colour(msg)\n puts msg.colorize(:red)\n end", "def get_user_text_color(user)\n user_color = get_user_color(user).gsub(\"#\", \"\")\n\n # Get the hex color as red, green, blue\n r = user_color[0..1].hex\n g = user_color[2..3].hex\n b = user_color[4..5].hex\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
CREATE TALLY METHOD TO KEEP TRACK TO TOTALS a hand would currently look like this: [["3", "Diamonds"], ["5", "Clubs"], ["3", "Hearts"], ["J", "Spades"], ["2", "Hearts"]]
def tally(hand) arr = hand.map{|e| e[0]} #gets the second element of the nested array (cos arrays are zero indexed) running_total = 0 #initialise this at the beginning & then iterate through each value to get the total from our new hand_total array arr.each do |value| if value == 'A' running_total +...
[ "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A B B C D update of tags is tricky in that it can produce three groups of changes: 1. tags being removed (exist on record, but not in params) 2. tags unchanged (exist both on record and in params) 3. tags being added (do not exiust on record but are passed in params)
def update_tags! return unless @params.key?(:tags) tags_to_remove.each do |tag_title| TaskTag.where(task: task).joins(:tag).merge(Tag.where(title: tag_title)).destroy_all end tags_to_add.each do |tag_title| TaskTag.where(task: task, tag: tag_from_title(tag_title)).first_or_crea...
[ "def tag_update\n # let's check for a dup and merge if necessary\n @tags = Tag.find(:all)\n @temp = Tag.new(params[:tag])\n @temp.name = clean_tag(@temp.name) if @temp.name # strip spaces and quotes\n dup = false\n for tag in @tags\n if @temp.name == tag.name and tag.name != params[:old_name]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The model's fullyqualified and quoted primary key.
def primary_key "#{quoted_table_name}.#{model_class.send :primary_key}" end
[ "def primary_key\n @primary_key ||= @model_class.primary_key.to_sym\n end", "def quoted_primary_key\n @quoted_primary_key ||= connection.quote_column_name(primary_key)\n end", "def primary_key\n send( self.class.primary_key )\n end", "def primary_key\n case primary_key_prefix_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The old and new values for the friendly_id column.
def friendly_id_changes changes[friendly_id_config.column.to_s] end
[ "def friendly_id; end", "def history_id_attr\n @history_id_attr ||= Admin::MigrationGenerator.history_table_id_attr_for(table_name)\n end", "def original_id; end", "def friendly_id\n slug.name\n end", "def old_value_name\n return @old_value_name\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set the choosen number into the board
def set(num) player_id = @players[@turn % 2].id @board[num - 1] = @player_char[player_id] @turn += 1 end
[ "def set_player(input, player_num)\n board[input.to_i] = player_num\n end", "def setchosenbox(num)\n\t\t\t@chosenbox = num\n\t\tend", "def seed(idx,val)\n\t\t@board[idx].set_value = val\n\tend", "def set(index, player)\n\t\t@board[index] = player\n\tend", "def fill_board\n @num = 1\n (0..2).each d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
reset the raw parameters for each filter received by the form
def reset_filter_params params[:search] = nil params[:status] = nil params[:unassigned] = nil params[:assigned_to_me] = nil params[:needs_attention] = nil params[:year] = nil end
[ "def reset_filter_params\n session[:filter]=nil\n end", "def reset_params!\n @params = nil\n end", "def reset\n @params = {}\n @query_filters = []\n @uri = ''\n self\n end", "def reset\n all_filters.each(&:reset)\n validate\n end", "def reset\n @params ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create date object with the given integer loop 365 times if date is a friday, and date is the 13th of the month add 1 to unlucky_days variable
def friday_13th(year) date = Date.new(year) unlucky_days = 0 365.times do date = date + 1 if date.friday? == true && date.mday == 13 unlucky_days += 1 end end unlucky_days end
[ "def unlucky_days(year)\n count = 0\n for i in 1..12\n if Time.new(year, i, 13).friday?\n count += 1\n end\n ++i\n end\n return count\nend", "def createDays\n for i in 0..6\n createDay(firstDay + i.days)\n end\n end", "def your_birthday_is_on_a_friday_in_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Context Tools Used to call pdb functions which change or retrieve information about context features within gimp Flushes displays so that the images displayed in windows are up to date
def context_update_displays!() $gimp_iface.gimp_displays_flush() end
[ "def context_update_displays()\n $gimp_iface.gimp_displays_flush()\nend", "def features\n features = {}\n sexp_newtype_block.each do |s|\n if s[0] == :command and\n s[1][0..1] == [:@ident, \"feature\"] and\n s[2][0] == :args_add_block\n\n name = s[2][1][0][1][1][1]\n desc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_get_bgcolor: retrieves the current background color. This returns an integer, not an object
def context_get_bgcolor() return $gimp_iface.gimp_context_get_background()[0] end
[ "def bg_color\n BG_COLOR_CODES.index(read_attribute(:bg_color))\n end", "def background_color\n return @background_color\n end", "def bgcolor\n @bgcolor || $def_bg_color\n end", "def bgcolor\n @bgcolor || @parent.bgcolor || $def_bg_color\n end", "def get_backgro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_get_fgcolor: retrieves the current foreground color. This returns an integer, not an object
def context_get_fgcolor() return $gimp_iface.gimp_context_get_foreground()[0] end
[ "def foreground\n get_or_inherit_color(:foreground, Cura::Color.white)\n end", "def foreground\n @foreground ||= if colour && present?(colour.foreground)\n colour.foreground\n\n elsif named_colour?\n named_colour.foreg...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_set_bgcolor: sets the background color to rgb. This does not change the color of existing images, but new images will be initialized with a layer filled with the background color
def _context_set_bgcolor!(rgb) $gimp_iface.gimp_context_set_background(rgb) end
[ "def set_background_color(color)\n end", "def background_color(color); end", "def background_color=(value)\n @background_color = value\n end", "def make_transparent(bgcolor)\n manipulate! do |img|\n img.format(\"png\") do |c|\n c.transparent bgcolor\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_set_fgcolor: sets the foreground color to rgb. This is the color that is used to fill selections and draw with gimp tools
def _context_set_fgcolor!(rgb) $gimp_iface.gimp_context_set_foreground(rgb) end
[ "def set_fg_color(color = 0x40)\n @fg_color = get_color(color)\n end", "def _context_set_bgcolor!(rgb)\n $gimp_iface.gimp_context_set_background(rgb)\nend", "def context_get_fgcolor()\n return $gimp_iface.gimp_context_get_foreground()[0]\nend", "def fg=(color)\n color = Color.new(color)\n @cte...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_get_brush: Returns the current brush as a string
def context_get_brush() return $gimp_iface.gimp_context_get_brush()[0] end
[ "def _context_set_brush!(brush_name)\n $gimp_iface.gimp_context_set_brush(brush_name)\nend", "def print_brush_prefs\n if !self.brushes.empty?\n puts\"\\n\"\n puts 'BRUSH PREFERENCES'\n self.brushes.each do |key, value|\n puts \"#{key}: #{value}\"\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context_set_brush: Takes a brush name and sets the brush accordingly
def _context_set_brush!(brush_name) $gimp_iface.gimp_context_set_brush(brush_name) end
[ "def setMarkerBrush _obj, _args\n \"_obj setMarkerBrush _args;\" \n end", "def setMarkerBrushLocal _obj, _args\n \"_obj setMarkerBrushLocal _args;\" \n end", "def setBrushSize(size)\n puts(\"Brush size updated\") \n @brushSize = size\n end", "def markerBrush _args\n \"m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
contextlistcolors: returns an array of color names. If given a string, the array only contains the names that contain that string.
def context_list_colors(pattern = nil) if pattern == nil return $gimp_iface.ggimp_rgb_list()[1] elsif pattern.is_a? String names = $gimp_iface.ggimp_rgb_list()[1] names.select!{|element| element.include?(pattern)} return names else raise ArgumentError, "context_list_color_names only accepts a ...
[ "def colorNames\n colors = [\"red\", \"orange\", \"yellow\", \"green\", \"mint\", \"navy\", \"light blue\", \"lavender\", \"plum\", \"pink\"]; \n return colors;\n end", "def list_colors\n color_string = \"\\nThe available colors are \"\n COLORS.each_with_index do |color, index|\n if index%2 == 0...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
contextlistbrushes: returns an array of brush names. If given a string, the array only contains the names that contain that string.
def context_list_brushes(pattern = nil) if pattern == nil return $gimp_iface.gimp_brushes_get_list("")[1] elsif pattern.is_a? String return $gimp_iface.gimp_brushes_get_list(pattern)[1] else raise ArgumentError, "context_list_brushes only accepts a string as an argument" end end
[ "def context_list_colors(pattern = nil)\n if pattern == nil\n return $gimp_iface.ggimp_rgb_list()[1]\n elsif pattern.is_a? String\n names = $gimp_iface.ggimp_rgb_list()[1]\n names.select!{|element| element.include?(pattern)}\n return names\n else\n raise ArgumentError, \"context_list_color_names o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Underline a string (make it a title). string The String to underline. Examples StringHelper.underline('1234') => "" Returns the String underline.
def underline(string) '-' * string.size end
[ "def underline(str)\n str += \"\\n\" + \"-\"*str.length\n end", "def underline string, char = '-'\n\t\tputs string\n\t\tlinebr string.length, char\n\tend", "def text_underline(text); underline(text);end", "def underline_message(message)\n Format(:underline, message)\n end", "def unde...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns HTML ready to be used in the email body, HTML is generated by parsing the email.html template and applying realease_notes.md content
def parsed_body(opts) file = File.open(File.dirname(__FILE__) + "/email.html", "r") content = file.read markdown = Yolo::Tools::Ios::ReleaseNotes.html content = content.gsub("YOLO.TITLE",opts[:title]) content = content.gsub("YOLO.CONTENT",markdown) if opts[:o...
[ "def content_for_preview( layout_options )\r\n content = self.body.dup\r\n content.gsub!( /<%=\\s?(@[^%]+)\\s?%>/, '<code>\\1</code>' )\r\n mail = Mail.new( :token => \"\" )\r\n mail.content = Render::Base.new( content ).mail_content\r\n template = IO.read(\"#{RAILS_ROOT}/app/views/mail_tas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /syndromes GET /syndromes.json
def index @syndromes = Syndrome.all end
[ "def index\n @synonymous = Synonymou.all\n end", "def get_synonyms\n keywords = params[:keywords]\n overrides = params[:overrides]\n\n if keywords.blank?\n head :bad_request\n return\n end\n\n country = request.location.country\n\n if overrides.present?\n country = overrides[:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /syndromes POST /syndromes.json
def create @syndrome = Syndrome.new(syndrome_params) respond_to do |format| if @syndrome.save format.html { redirect_to @syndrome, notice: 'Syndrome was successfully created.' } format.json { render :show, status: :created, location: @syndrome } else format.html { render :ne...
[ "def update\n respond_to do |format|\n if @syndrome.update(syndrome_params)\n format.html { redirect_to @syndrome, notice: 'Syndrome was successfully updated.' }\n format.json { render :show, status: :ok, location: @syndrome }\n else\n format.html { render :edit }\n format.j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /syndromes/1 PATCH/PUT /syndromes/1.json
def update respond_to do |format| if @syndrome.update(syndrome_params) format.html { redirect_to @syndrome, notice: 'Syndrome was successfully updated.' } format.json { render :show, status: :ok, location: @syndrome } else format.html { render :edit } format.json { render...
[ "def update\n respond_to do |format|\n if @syndicate.update(syndicate_params)\n format.html { redirect_to @syndicate, notice: 'Syndicate was successfully updated.' }\n format.json { render :show, status: :ok, location: @syndicate }\n else\n format.html { render :edit }\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /syndromes/1 DELETE /syndromes/1.json
def destroy @syndrome.destroy respond_to do |format| format.html { redirect_to syndromes_url, notice: 'Syndrome was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n s = @node.synonyms.find(params[:id])\n s.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n end", "def destroy\n @syndicate = Syndicate.find(params[:id])\n @syndicate.destroy\n\n respond_to do |format|\n format.html { redirect_to syndicates_url }\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes a Twitch client. client_id [String] The client ID. Used as the ClientID header in a request. access_token [String] An access token. Used as the Authorization header in a request. Any "Bearer " prefix will be stripped. with_raw [Boolean] Whether to include raw HTTP response Intended for testing/checking API ...
def initialize(client_id: nil, access_token: nil, with_raw: false) if client_id.nil? && access_token.nil? raise "An identifier token (client ID or bearer token) is required" elsif !!client_id && !!access_token warn(%{WARNING: It is recommended that only one identifier token is specified. Unp...
[ "def initialize(client_id: nil, access_token: nil)\n if client_id.nil? && access_token.nil?\n raise \"An identifier token (client ID or bearer token) is required\"\n elsif !!client_id && !!access_token\n warn(%{WARNING:\nIt is recommended that only one identifier token is specified.\nUnpredi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
hack to generate yajl_version.h without using cmake
def generate_yajl_version build_path = File.expand_path("../ext/libyajl2", __FILE__) vendor_path = File.expand_path("../ext/libyajl2/vendor/yajl", __FILE__) yajl_major = yajl_minor = yajl_micro = nil File.open("#{vendor_path}/CMakeLists.txt").each do |line| if (m = line.match(/YAJL_MAJOR (\d+)/)) yaj...
[ "def ffi_yajl_gem\n Resources::Gem.new name: 'ffi-yajl', version: '2.2.3'\n end", "def uses_yajl?\n tracker.config.has_gem? :yajl\n end", "def target_version=(_arg0); end", "def binary_format_minor_version; end", "def version_string(include_buildnum = T.unsafe(nil)); end", "def get_ver...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def revision(scm, target, ref)
def revision(host, scm, target, ref) args = [] case scm when 'hg' args.push('update', 'clean', '-r', ref) when 'git' args.push('reset', '--hard', ref) else fail "Unfortunately #{scm} is not supported yet" end on host, "cd #{target} && #{scm} #{args.flatten.join ' '}" end
[ "def fetch_revision\n end", "def target_revision\n @target_revision ||= git(\"rev-parse #{version}\").stdout.strip\n rescue CommandFailed => e\n if e.message.include?('ambiguous argument')\n @target_revision = git(\"rev-parse origin/#{version}\").stdout.strip\n @target_revision\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the intervals precision. Mixed precisions are currently not supported; in that case, the start date's precision takes precedence.
def precision min.precision || max.precision end
[ "def precision\n @precision || DEFAULT_PRECISION\n end", "def precision\n self['precision']\n end", "def precision\n @precision = self.class::MAX_PRECISION unless @precision\n return @precision\n end", "def precision\n __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO how to handle +/ Infinity for Dates? TODO we can't delegate to Ruby range for mixed precision intervals Returns the Interval as a Range.
def to_range case when open?, unknown? nil else Range.new(unknown_start? ? Date.new : @from, max) end end
[ "def unbounded\n ::Unbounded::Range.new(self.min, self.max, exclude_end?)\n end", "def to_range\n return @range if @range\n raise(Error, \"cannot create ruby range for an empty PostgreSQL range\") if empty?\n raise(Error, \"cannot create ruby range when PostgreSQL range excludes begin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /availability_products GET /availability_products.json
def index @availability_products = AvailabilityProduct.all end
[ "def available\n @products = Product.where.not(inventory_count: 0)\n json_response(@products)\n end", "def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /availability_products POST /availability_products.json
def create @availability_product = AvailabilityProduct.new(availability_product_params) respond_to do |format| if @availability_product.save format.html { redirect_to @availability_product, notice: 'Availability product was successfully created.' } format.json { render :show, status: :cre...
[ "def check_products_availability\n if self.available && !self.product.available\n self.product.available = true\n self.product.save\n elsif !self.available && self.product.details.available.empty?\n self.product.available = false\n self.product.save\n end\n end", "def index\n @ava...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /availability_products/1 PATCH/PUT /availability_products/1.json
def update respond_to do |format| if @availability_product.update(availability_product_params) format.html { redirect_to @availability_product, notice: 'Availability product was successfully updated.' } format.json { render :show, status: :ok, location: @availability_product } else ...
[ "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n @v1_product = V1::Product.find(params[:id])\n\n if @v1_product.update(v1_product_params)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /availability_products/1 DELETE /availability_products/1.json
def destroy @availability_product.destroy respond_to do |format| format.html { redirect_to availability_products_url, notice: 'Availability product was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @availability = Availability.find(params[:id])\n @availability.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n \n if @product.destroy\n render json: @product, :status => :ok\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine which gem will be used for the projects CSS framework
def template_engine_gem_str(css_framework = '') case css_framework.to_s when 'semantic' 'semantic_ui' else 'bootstrap' end end
[ "def vendor_css\n dist(/^vendor.*css$/)\n end", "def gems_for_testing_framework(testing_framework)\n testing_framework == :rspec ? '' : %Q{gem \"#{testing_framework}\", :group => :test} \n end", "def gem_type(place_or_version)\n if place_or_version =~ /^git:/\n :git\n elsif place_or_ve...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Make a directory in the applications directory path
def mk_appdir(dir) path = Rails.root.join(dir) FileUtils.mkdir(path) unless File.directory?(path) end
[ "def make_app_directories\n @shell.call \"mkdir -p #{self.directories.join(\" \")}\"\n end", "def create_dir(dir)\n Dir::mkdir 'app/' + dir if !File.directory? 'app/' + dir\nend", "def make_dir up_to_path = nil\n up_to_path ||= path\n `if [ ! -d \"#{up_to_path}\" ];then mkdir -p \"#{up_to_path}\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Used to add additional assets to be considered when compiling your assets
def add_to_assets(asset_str) append_to_file('config/initializers/assets.rb', "Rails.application.config.assets.precompile += %w( #{asset_str} )\n") unless asset_str.blank? end
[ "def precompile_assets=(_arg0); end", "def add_assets(paths)\n copy_assets(paths)\n characterize_assets\n create_or_update_assets\n end", "def extra_asset_links\n lines = []\n if item.attributes.has_key?(:css)\n for stylesheet in item.attributes[:css]\n lines.push(\"<link href='/asse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a specific line to the config/routes.rb file
def add_to_routes(route_str = '') inject_into_file('config/routes.rb', optimize_indentation("#{route_str.strip}\n", 2), after: "\s# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html\n") end
[ "def append_route name\n if (::File.exist? \"config/routes.rb\")\n append_to_file \"config/routes.rb\" do\n \"Rails.application.routes.draw do\n get 'info' => '#{name}#info'\n get 'event' => '#{name}#event'\n get 'config' => '#{name}#config_ui'\n post...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an instance of ConfigurationInstance
def get_instance(payload) ConfigurationInstance.new(@version, payload) end
[ "def build\n @config.validate! if @config.respond_to?(:validate!)\n @config\n end", "def instantiate_builder\n klass = TinyCI::Builders.const_get(@config[:builder][:class])\n konfig = @config[:builder][:config].merge(\n target: target_path,\n export: export_path,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Splices to the pipe from the given source. If maxlen is negative, splices repeatedly using absolute value of maxlen until EOF is encountered.
def splice_from(src, maxlen) Polyphony.backend_splice(src, self, maxlen) end
[ "def splice(src, dest, maxlen)\n Polyphony.backend_splice(src, dest, maxlen)\n end", "def readpartial(maxlen)\n shell.input.readpartial(maxlen)\n end", "def readpartial(maxlen, buf=nil)\n if maxlen == 0\n if buf\n buf.clear\n return buf\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
8. Perfect numbers between 1 to 100
def sample for num in 1..100 sum = 0 for j in 1..num-1 if( num % j == 0 ) sum = sum + j end end if( sum == num ) puts "perfect number : #{num}" end end end
[ "def problem_100\n 2.sqrt_frac do |top,bot|\n if top.odd? && bot.odd?\n x,n = top/2+1,bot/2+1\n puts \"#{x} / #{n}\"\n return n if x > 1_000_000_000_000\n end\n end\nend", "def multiple_of_100?(int)\n return int % 100 == 0 ? true : false\nend", "def divisible_by_5_and_3\n numbers = (1...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Initialize a CSS generation / distribution. name A String name that will be used to name a font and stylesheet file. file A String name that will be used to link to the font files. has A zero or more Symbol font types that a stylesheet will use. Valid symbols are: :eot, :svg, :woff, :ttf. Returns the String CSS...
def initialize(name, file, *has) [name, file, has] @has = has @name = name @filename = File.basename(file, '.*') # :nocov: @url = (self.class.relative_from.nil? ? (self.class.link_to ? (self.class.link_to + '/' + File.basename(file)) : file) : (self.class.link_to ?...
[ "def initialize(css_file, html_dir)\n @css_file = css_file\n @html_dir = html_dir\n @font_name = File.basename(@css_file, \".*\")\n\n make_html\n write\n end", "def new_css_for(name=nil)\n return \"USAGE : new_css_for [name_of_css]\" if name.nil?\n css_path = \"public/stylesheets...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: (Re)Create a CSS file and write code there. dir The String directory path to write CSS file to. Returns the css file just written.
def write(dir) @dir = FileUtils.mkdir_p dir @css_file = File.join(@dir, @filename + '.css') File.delete(@css_file) if File.exist?(@css_file) @output = File.open(@css_file, 'w') { |file| file.write(@result) } @css_file end
[ "def new_css_for(name=nil)\n return \"USAGE : new_css_for [name_of_css]\" if name.nil?\n css_path = \"public/stylesheets/#{name}.css\"\n File.open(css_path,\"w+\")\n # TM only function sorry win guys! ... maybe you can use e\n system(\"mate #{css_path}\")\n return \"CSS File : #{name}.css has been...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Use template to fill placeholders with relevant values. Returns the String containing a CSS stylesheet code.
def make_css template = ERB.new TEMPLATE result = template.result binding (0..3).each { result.gsub!(/\n;\n/m, ";\n") } @result = result.gsub /^$\n/, '' end
[ "def assemble_css\n renderer = Liquid::Template.parse(@stylesheet.data)\n renderer.render(global_template_data, :filters => liquid_filters)\n end", "def compile(template) #:nodoc:\n template.gsub(/:[a-z0-9_]+/) do |match|\n position = TEMPLATE_ARGUMENT_ORDER.index(match)\n if position\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /opinion_reports GET /opinion_reports.json
def index @opinion_reports = OpinionReport.all end
[ "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @annual_reports }\n end\n end", "def index\n @outage_reports = OutageReport.all\n\n respond_to do |format|\n format.html\n format.json\n format.geojson\n end\n end", "def ind...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /opinion_reports POST /opinion_reports.json
def create if OpinionReport.where(opinion_report_params).count > 0 render json: { status: "Error", message: "Ya se ha enviado un reporte sobre esta opinión" }.to_json else @opinion_report = OpinionReport.new(opinion_report_params) if @opinion_report.save render js...
[ "def index\n @opinion_reports = OpinionReport.all\n end", "def report_data_request(options)\n request.headers['Content-Type'] = 'application/json'\n post :report_data, :params => report_data_request_data(options)\n end", "def create\n @outage_report = OutageReport.new(outage_report_par...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /opinion_reports/1 PATCH/PUT /opinion_reports/1.json
def update respond_to do |format| if @opinion_report.update(opinion_report_params) format.html { redirect_to @opinion_report, notice: 'Opinion report was successfully updated.' } format.json { render :show, status: :ok, location: @opinion_report } else format.html { render :edit ...
[ "def update\n authorize @expense_report\n\n\n @expense_report.actual_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @expense_report.trip.destination\n req.expense_type = 'actual'\n end\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /opinion_reports/1 DELETE /opinion_reports/1.json
def destroy @opinion_report.destroy respond_to do |format| format.html { redirect_to opinion_reports_url, notice: 'Opinion report was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @report.destroy!\n render json: {status: :ok}\n end", "def destroy\n @expense_report = ExpenseReport.find(params[:id])\n @expense_report.destroy\n\n respond_to do |format|\n format.html { redirect_to expense_reports_url }\n format.json { head :no_content }\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /vlan_details/1 GET /vlan_details/1.xml
def show @vlan_detail = VlanDetail.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @vlan_detail } end end
[ "def new\n @vlan_detail = VlanDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vlan_detail }\n end\n end", "def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @vlan }\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /vlan_details/new GET /vlan_details/new.xml
def new @vlan_detail = VlanDetail.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @vlan_detail } end end
[ "def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @vlan }\n end\n end", "def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vlan }\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /vlan_details POST /vlan_details.xml
def create @vlan_detail = VlanDetail.new(params[:vlan_detail]) respond_to do |format| if @vlan_detail.save flash[:notice] = 'VlanDetail was successfully created.' format.html { redirect_to(@vlan_detail) } format.xml { render :xml => @vlan_detail, :status => :created, :location =>...
[ "def new\n @vlan_detail = VlanDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vlan_detail }\n end\n end", "def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @vlan }\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /vlan_details/1 PUT /vlan_details/1.xml
def update @vlan_detail = VlanDetail.find(params[:id]) respond_to do |format| if @vlan_detail.update_attributes(params[:vlan_detail]) flash[:notice] = 'VlanDetail was successfully updated.' format.html { redirect_to(@vlan_detail) } format.xml { head :ok } else forma...
[ "def update\n @vlan = Vlan.find(params[:id])\n\n respond_to do |format|\n if @vlan.update(vlan_params)\n flash[:notice] = 'VLAN was successfully updated.'\n format.html { redirect_to(admin_vlans_path) }\n format.xml { head :ok }\n else\n format.html { render action: 'edi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /vlan_details/1 DELETE /vlan_details/1.xml
def destroy @vlan_detail = VlanDetail.find(params[:id]) @vlan_detail.destroy respond_to do |format| format.html { redirect_to(vlan_details_url) } format.xml { head :ok } end end
[ "def destroy\n @hq_vlan = HqVlan.find(params[:id])\n @hq_vlan.destroy\n \n respond_to do |format|\n format.html { redirect_to(hq_vlans_url) }\n format.xml { head :ok }\n end\n end", "def delete_vlan_dev\n nil\n end", "def delete_vlan_dev\n OpenNebula.log_error('de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /enqueues GET /enqueues.json
def index @enqueues = Enqueue.all end
[ "def create\n @enqueue = Enqueue.new(enqueue_params)\n\n respond_to do |format|\n if @enqueue.save\n format.html { redirect_to @enqueue, notice: 'Enqueue was successfully created.' }\n format.json { render :show, status: :created, location: @enqueue }\n else\n format.html { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /enqueues POST /enqueues.json
def create @enqueue = Enqueue.new(enqueue_params) respond_to do |format| if @enqueue.save format.html { redirect_to @enqueue, notice: 'Enqueue was successfully created.' } format.json { render :show, status: :created, location: @enqueue } else format.html { render :new } ...
[ "def index\n @enqueues = Enqueue.all\n end", "def enqueue(job_attrs={})\n send_request('enqueue', {job: job_attrs})\n end", "def before_enqueue; end", "def create\n arg = params[:email]\n counter = Job.enqueue(arg)\n render :status => :accepted, :json => { jobId: counter }\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /enqueues/1 PATCH/PUT /enqueues/1.json
def update respond_to do |format| if @enqueue.update(enqueue_params) format.html { redirect_to @enqueue, notice: 'Enqueue was successfully updated.' } format.json { render :show, status: :ok, location: @enqueue } else format.html { render :edit } format.json { render json...
[ "def update\n respond_to do |format|\n if @dequeue.update(dequeue_params)\n format.html { redirect_to @dequeue, notice: 'Dequeue was successfully updated.' }\n format.json { render :show, status: :ok, location: @dequeue }\n else\n format.html { render :edit }\n format.json {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /enqueues/1 DELETE /enqueues/1.json
def destroy @enqueue.destroy respond_to do |format| format.html { redirect_to enqueues_url, notice: 'Enqueue was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end", "def deleteQueue( queue_id)\n params = Hash.new\n params['queue_id'] = queue_id\n return doCurl(\"de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the itinerary edit page is THE MAIN INTERFACE for attendee registration so... this page has mission creeped and is a bit messy it functions like a 'new' page for line_items and transactions NOTE: the itinerary isn't responsible for creating, updating, or destroying either of those resources though it also acts like an ...
def edit @itinerary = Itinerary.find(params[:id]) authorize! :update, @itinerary end
[ "def edit\n\t\titinerary = Itinerary.find(params[:id])\n\tend", "def edit\n\t\tputs \"Editing Workout : #{params[:id]}\"\n\n\t\t@workout = Workout.find(params[:id])\n\n\t\t# Makesure that the user can access that workout if they dont redirect them to the\n\t\t# login page\n\t\tallowed = confirm_user_auth(@workout...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
FORCE to implement content_for in controller
def view_context super.tap do |view| (@_content_for || {}).each do |name,content| view.content_for name, content end end end
[ "def content_for\n @content_for\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def content_controller\n self\n end", "def global_content_for(name, content = nil, &block...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }