query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
full filename expected; requires and returns the task class | def task_from_filename(filename)
require filename
File.basename(filename).gsub(".rb", "").camelcase # RAILS_ROOT/rooster/lib/tasks/newsfeed_task.rb => NewsfeedTask
end | [
"def task(source_adapter, task_file)\n case source_adapter\n when \"sftp\"\n Sftp::Task.new(self, task_file)\n when \"postgres\"\n Database::Task.new(self, task_file)\n when \"mssql\"\n Database::Task.new(self, task_file)\n when \"alma\"\n Alma::Task.new(self, ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Spyke override Keep a cache of loaded portals. Spyke's default behavior is to reload the association each time. | def association(name)
@loaded_portals ||= {}
if @loaded_portals.has_key?(name.to_sym)
return @loaded_portals[name.to_sym]
end
super.tap do |assoc|
next unless assoc.kind_of?(FmRest::Spyke::Portal)
@loaded_portals[name.to_sym] = assoc
... | [
"def cached_association; end",
"def reload!\n cache.clear\n @collection = load_collection\n\n self\n end",
"def reload_uncached_association\n \n end",
"def reload!\n associations.clear\n\n remote = self.class.fetch(id, _prefix)\n return self if remote.nil?\n\n remote.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Signals that this record has been embedded in a portal so we can make sure to include it in the next update request | def embedded_in_portal
@embedded_in_portal = true
end | [
"def will_record_after_update?\n on = @record.paper_trail_options[:on]\n on.nil? || on.include?(:update)\n end",
"def track_record_update\n # Don't do this if we have the configuration set to avoid tracking, or\n # if the record was not created or updated\n return if no_track || !(@was_updat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes care of updating the new portal record's recordIds and modIds. Called when saving a record with freshly added portal records, this method is not meant to be called manually. | def __new_portal_record_info=(data)
data.each do |d|
table_name = d[:tableName]
portal_new_records =
portals.detect { |p| p.portal_key == table_name }.select { |r| !r.persisted? }
# The DAPI provides only one recordId for the entire portal in the
... | [
"def store_updated_records(records)\n @updated_records.concat(records_identities(records))\n end",
"def update_record!(record, hash, inventory_object)\n record.assign_attributes(hash.except(:id))\n if !inventory_collection.check_changed? || record.changed?\n record.save\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /javaques GET /javaques.json | def index
@javaques = Javaque.all
end | [
"def question\n ques_type = params[:within].try([:ques_type])\n ques_id = params[:within].try([:ques_id])\n question = get_custom_ques current_user.id,ques_type,ques_id\n render json: question\n end",
"def index\n @ques = Que.all\n end",
"def show\n @quesito = Quesito.find(params[:id])\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /javaques POST /javaques.json | def create
@javaque = Javaque.new(javaque_params)
respond_to do |format|
if @javaque.save
format.html { redirect_to @javaque, notice: 'Javaque was successfully created.' }
format.json { render :show, status: :created, location: @javaque }
else
format.html { render :new }
... | [
"def create\n @quesito = Quesito.new(params[:quesito])\n\n respond_to do |format|\n if @quesito.save\n format.html { redirect_to @quesito, :notice => 'Quesito was successfully created.' }\n format.json { render :json => @quesito, :status => :created, :location => @quesito }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /javaques/1 DELETE /javaques/1.json | def destroy
@javaque.destroy
respond_to do |format|
format.html { redirect_to javaques_url, notice: 'Javaque was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @quesito = Quesito.find(params[:id])\n @quesito.destroy\n\n respond_to do |format|\n format.html { redirect_to quesitos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cheque.destroy\n respond_to do |format|\n format.html { redirect_to cheque... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Method: dest Args: mnemonic (string) Returns: 3 bits Function: Returns the binary code of the dest mnemonic =end | def write_dest(output, dest_mnemonic)
case dest_mnemonic
when ""
File.open(output, "a") { |f| f.write "000"}
when "M"
File.open(output, "a") { |f| f.write "001"}
when "D"
File.open(output, "a") { |f| f.write "010"}
when "MD"
File.open(output, "a") { |f| f.write "011"}
whe... | [
"def mnemonic(instruction)\n\t\tif @ida.ua_mnem(instruction.offset) != nil:\n\t\t\tmnem = @ida.cmd.get_canon_mnem\n\n\t\t\tbyte = instruction.byte\n\t\t\t\n\t\t\tif byte == 0xF3\n\t\t\t\tif mnem == \"scas\"\n\t\t\t\t\treturn \"repe \" + mnem\n\t\t\t\telse\n\t\t\t\t\treturn \"rep \" + mnem\n\t\t\t\tend\n\t\t\telsif ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Method: comp Args: mnemonic (string) Returns: 7 bits Function: Returns the binary code of the comp mnemonic =end | def write_comp(output, comp_mnemonic)
case comp_mnemonic
when "0"
File.open(output, "a") { |f| f.write "0101010"}
when "1"
File.open(output, "a") { |f| f.write "0111111"}
when "-1"
File.open(output, "a") { |f| f.write "0111010"}
when "D"
File.open(output, "a") { |f| f.write "... | [
"def comp(command)\n\t\tunless command.empty?\n\t\t\tcomp_bits = (command.include? \"M\") ? \"1\" : \"0\" # determines a prefix for c command\n\t\t\tif command.include? \"M\"\n\t\t\t\tcomp_bits << @comp_table_a1[command]\n\t\t\t\tcomp_bits = comp_bits\n\t\t\telse\n\t\t\t\tcomp_bits << @comp_table_a0[command]\n\t\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deskew an image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_deskewed_image(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def showImage3\n\t@image_data = Applicant.find(params[:id])\n\t@image = @image_data.admission\n\tsend_data @image, :type => \"image/jpg\", :disposition => 'inline'\n end",
"def put_scratch_image(user)\n b64_image = \"R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=\"\n post \"/media_gallery/image_scratche... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Grayscales an image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_grayscaled_image(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def process_image_grey_scale\n file_name = \"#{Rails.root}/tmp/temp-#{self.id}.jpg\"\n\n open(file_name, 'wb') do |file|\n file << open(self.image_uncompressed.url).read\n end\n\n image = OpenCV::Cv::Mat.new\n image = OpenCV::Cv::imread file_name\n\n OpenCV::Cv::cvtColor(image, image, OpenCV... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get separate frame from existing image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_image_frame(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def create_image_frame_from_request_body\n puts('Get separate frame from existing image from request body')\n\n frame_id = 1 # Index of the frame\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get frames range from existing image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_image_frame_range(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def get_image_frame_range(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def create_image_frame_range_from_request_body\n puts('Get separate frame range from existing image from request body')\n\n start_frame_id = 1 # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update parameters of SVG image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_modified_svg(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def update\n respond_to do |format|\n if @svg_image.update(svg_image_params)\n format.html { redirect_to @svg_image, notice: 'Svg image was successfully updated.' }\n format.json { render :show, status: :ok, location: @svg_image }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rotate and/or flip an image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def create_rotate_flipped_image(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'File')
end | [
"def flip\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.flip!\n img.write('public' + @photo.attachment_url)\n end",
"def rotate(img)\n exif = img.get_exif_by_entry(:Orientation)\n return img if !(exif && exif[0] && exif... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes image features from search context. | def delete_image_features(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :DELETE, nil)
nil
end | [
"def delete_search_context\n folder = nil # File will be saved at the root of the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::DeleteImageSearchRequest.new(search_context_id, folder, storage)\n imaging_api.delete_image_search(request)\n\n pu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract features from image without adding to search context. Image data may be passed as zeroindexed multipart/formdata content or as raw body stream. | def extract_image_features(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'ImageFeatures')
end | [
"def get_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'ImageFeatures')\n end",
"def test_extract_and_add_image_features_from_website_test\n image_source_url = URI.encode('https://www.f1news.ru/interview/hamilton/140909.shtml... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get separate frame properties of existing image. Image data is passed as zeroindexed multipart/formdata content or as raw body stream. | def extract_image_frame_properties(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'ImagingResponse')
end | [
"def extract_image_frame_properties_from_request_body\n puts('Get separate frame properties of existing image from request body')\n\n frame_id = 1 # Number of a frame\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeIm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find images by tags. Tags JSON string is passed as zeroindexed multipart/formdata content or as raw body stream. | def find_images_by_tags(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :POST, 'SearchResultsSet')
end | [
"def find_images_by_tag\n puts('Finds the images by tag:')\n\n file_name = image_to_find_by_tag\n tag_name = 'ImageTag'\n similarity_threshold = 60.0\n max_count = 5\n folder = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(Ima... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find similar images. Image data may be passed as zeroindexed multipart/formdata content or as raw body stream. | def find_similar_images(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'SearchResultsSet')
end | [
"def find_similar_images\n puts('Finds the similar images:')\n\n find_image_id = File.join(ImagingAiBase::CLOUD_PATH, images_path, image_to_find)\n similarity_threshold = 60.0\n max_count = 3\n folder = nil\n storage = nil # We are using default Cloud Storage\n\n request = AsposeI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets image features from search context. | def get_image_features(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'ImageFeatures')
end | [
"def extract_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'ImageFeatures')\n end",
"def prepare_search_context\n create_search_context\n\n # Upload images to Cloud Storage\n %w[1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get separate frame properties of existing image. | def get_image_frame_properties(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'ImagingResponse')
end | [
"def extract_image_frame_properties(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'ImagingResponse')\n end",
"def extract_image_frame_properties_from_request_body\n puts('Get separate frame properties of existing image from request body')\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get frames range from existing image. | def get_image_frame_range(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'File')
end | [
"def create_image_frame_range_from_request_body\n puts('Get separate frame range from existing image from request body')\n\n start_frame_id = 1 # Index of the first frame in range\n end_frame_id = 4 # Index of the last frame in range\n out_path = nil\n storage = nil # We are using default C... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get properties of an image. | def get_image_properties(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'ImagingResponse')
end | [
"def image_properties(image_path, directory)\n name = get_image_name(image_path, directory)\n image = get_image(image_path)\n need_wh?(image_path, directory) ? {:name => name, :width => image[:width], :height => image[:height]} : {:name => name}\n end",
"def image_properties(image, directory)\n\t\tname ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the search context status. | def get_image_search_status(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'SearchContextStatus')
end | [
"def status\n context.status\n end",
"def search_status\n if uri_term?\n :single_result\n else\n perform_search\n end\n end",
"def service_status\n client.get_status\n end",
"def status\n request :get, \"_status\"\n end",
"def get_status\n @connecti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get image from search context | def get_search_image(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'File')
end | [
"def search_image\n\t\t# @search_image = Opinion.new\n\t\t@search_results = []\n\tend",
"def search params = {}\n @connection.get(build_path(\"/images/search\", params)) \n end",
"def search_images(searchterm,params={})\n @opensearch.search_images(searchterm,params) \n end",
"def find_image(i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update parameters of existing JPEG2000 image. | def modify_jpeg2000(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'File')
end | [
"def put_drawing_jpeg2000_with_http_info(request)\n raise ArgumentError, 'Incorrect request type' unless request.is_a? PutDrawingJpeg2000Request\n\n @api_client.config.logger.debug 'Calling API: CadApi.put_drawing_jpeg2000 ...' if @api_client.config.debugging\n # verify the required parameter 'drawin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update parameters of existing SVG image. | def modify_svg(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :GET, 'File')
end | [
"def update\n respond_to do |format|\n if @svg_image.update(svg_image_params)\n format.html { redirect_to @svg_image, notice: 'Svg image was successfully updated.' }\n format.json { render :show, status: :ok, location: @svg_image }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update images features in search context. Image data may be passed as zeroindexed multipart/formdata content or as raw body stream. | def update_image_features(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :PUT, nil)
nil
end | [
"def update_search_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end",
"def update_image image\n image.image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n image_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update image and images features in search context. Image data may be passed as zeroindexed multipart/formdata content or as raw body stream. | def update_search_image(request)
http_request = request.to_http_info(@api_client.config)
make_request(http_request, :PUT, nil)
nil
end | [
"def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end",
"def prepare_search_context\n create_search_context\n\n # Upload images to Cloud Storage\n [comparable_image, comparable_image_simila... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List the lists of the specified user. Private lists will be included if the authenticated user is the same as the user whose lists are being returned. | def get_lists(user)
get("/#{user}/lists.json")
end | [
"def playlists(user)\n get(:standard, {:method => \"user.getPlaylists\", :user => user})\n end",
"def user_friends_lists\n user_objects = user_friends\n user_lists = []\n user_objects.each do |user|\n if user \n user_lists << user.lists \n end\n end\n user_lists\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes the specified list. Must be owned by the authenticated user. | def delete_list(user, list)
delete("/#{user}/lists/#{list}.json")
end | [
"def delete_list(list)\n api_delete(:list, {:list => list})\n end",
"def delete_list(list)\n lists_ws.delete_list(list)\n end",
"def delete_owned_lists\n lists.each(&:destroy)\n end",
"def delete_list(list_id:)\n api_request(method: :delete, path: \"lists/#{list_id}\")\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List Members Methods Returns the members of the specified list. | def list_members(user, list)
get("/#{user}/#{list}/members.json")
end | [
"def members(list_id = prelaunch_id)\n @gb.lists.members(id: list_id)\n end",
"def getMembersList()\n\t\tbegin\n\t \t@members=[];\n\t \tuserMembers = TwitterClient.list_members(@selectedList)\n\t \tuserMembers.each do |memberInList|\n\t \t\t@members << memberInList.id\n\t \tend\n\t \t@member... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to having 500 members. | def add_member_to_list(user, list, member_id, options={})
post("/#{user}/#{list}/members.json", options.merge(:id => member_id))
end | [
"def add_member_to_list(user_id, list_id, options={})\n post(\"/lists/members/create.json\", options.merge(:user_id => user_id, :list_id => list_id))\n end",
"def assign_member\n authorize List\n @member.assigned_lists << @list\n json_response({ message: 'List assigned successfully' }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list. | def remove_member_from_list(user, list, member_id)
delete("/#{user}/#{list}/members.json?id=#{member_id}")
end | [
"def remove_member(*args)\n arguments(args, required: [:id, :user])\n\n delete_request(\"/teams/#{arguments.id}/members/#{arguments.user}\",\n arguments.params)\n end",
"def remove_member(member)\n client.delete(\"/cards/#{id}/idMembers/#{member.id}\")\n end",
"def remov... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List Subscribers Methods Returns the subscribers of the specified list. | def list_subscribers(user, list)
get("/#{user}/#{list}/subscribers.json")
end | [
"def list_subscribers( list_id, options={})\n options.merge!(:list_id => list_id)\n args = options.map{|k,v| \"#{k}=#{v}\"}.join('&')\n get(\"/lists/subscribers.json?#{args}\")\n end",
"def list_subscriptions(list_id)\n get(\"contactList/#{list_id}/subscribe\")\n end",
"def subscri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unsubscribes the authenticated user form the specified list. | def unsubscribe_from_list(user, list)
delete("/#{user}/#{list}/subscribers.json")
end | [
"def unsubscribe(list_id, user_id)\n raise NotImplementedError.new\n end",
"def unsubscribes(params = {})\n @api.get(\"#{@api.path}/Recipient/#{@id}/List/Unsubscriptions\", params: params)\n end",
"def unsubscribe_user_userdatalist(user_name)\n @subscribed_userdata_list.delete(user_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
basic check to see if the project is under git version control | def project_is_configured_for_git?
File.directory? '.git'
end | [
"def under_version_control?\n !Dir.glob(\".{git,svn}\").empty?\n end",
"def check_for_git_repo\n raise 'this is not a valid git repo' if !is_git_repo\n end",
"def git?\n !!git_directory\n end",
"def can_access_git?\n true\n end",
"def is_git_repo?\n Pkg::Util.in_proj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
branch project so that we can undo our changes | def branch_project
if project_is_configured_for_git?
begin
# use -d instead of -D so not to remove uncommitted changes
`git branch -d hamlr`
`git checkout -b hamlr`
rescue Exception => e
$stderr.puts "Oh snap! Error: #{e.message}"
exit 1
end
else
$stderr.puts "Use git plea... | [
"def sync_project_branches(repoName)\n #develop branch\n ok = self.reset_branch(repoName, EXODevRemoteName ,SourceBranch, EXOPlatformRemoteName)\n if ok\n # push force to remote branch\n self.push_force_to_remote_branch(repoName, EXODevRemoteName, SourceBranch, TranslationBranch)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the actual person resource object. Specify +true+ as a parameter to fetch the "full" version of the resource (only use this when more data is needed than the basics). | def person_resource(full = false)
q = full ? "#{reg_id}/full" : reg_id
@person_resource ||= {}
@person_resource[full.to_s] ||= person_resource? ? PersonResource.find(q) : nil
@person_resource[full.to_s]
end | [
"def fetch\n response = Request.get(resource_path, custom_option)\n extract_resource(response) || response\n end",
"def student_person_resource\n @student_person_resource ||= person_resource? ? StudentPersonResource.find(reg_id) : nil\n end",
"def show\n @person = Person.load(params[:i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the person resource from the Student Web Service instead of from Person Web Service. | def student_person_resource
@student_person_resource ||= person_resource? ? StudentPersonResource.find(reg_id) : nil
end | [
"def get_student(parameters)\n json_post('students/api.json', parameters)\n end",
"def person(id)\n get(\"/catalog/people/#{id.to_s}\")\n end",
"def get_person\n with_monitoring do\n vet360_id_present!\n raw_response = perform(:get, @user.vet360_id)\n\n PersonRe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For nonMentors, current_locations always returns an empty array. | def current_locations
[]
end | [
"def current_locations\n current_mentor_term_groups.collect(&:location).flatten.uniq.compact\n end",
"def locations\n return @locations\n end",
"def get_locationsCurrent(par)\n locationsCurrent = []\n par.each do |key, value|\n if value === 'current' \n loc = key[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def [](attr_name) instance_eval(attr_name.to_s) end For each ObjectFilter relevant for this person type, run the filter on this person and store the result value in +filter_cache+. | def update_filter_cache!
self.filter_cache = {}
for object_filter in self.class.object_filters
self.filter_cache[object_filter.id] = object_filter.reload.passes?(self)
end
self.filter_cache
end | [
"def filter_one_attribute(obj, attr, value)\n filters = lookup_filter(attr)\n if filters\n filters.each do |p|\n value = case p\n when Symbol\n obj.send(p, attr, value)\n when String\n obj.send(p.to_sym... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the filter cache by checking each ObjectFilter, and then saves the current record by calling +update_attribute+ so that +updated_at+ is not modified. | def update_filter_cache_and_save!
new_filter_cache = update_filter_cache!
update_column(:filter_cache, new_filter_cache.to_yaml)
end | [
"def update_filter_cache!\n self.filter_cache = {}\n for object_filter in self.class.object_filters\n self.filter_cache[object_filter.id] = object_filter.reload.passes?(self)\n end\n self.filter_cache\n end",
"def update\n reload\n update_model_filter\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the person's fullname in the form: Firstname Middlename Lastname If we have a valid +person_resource+, then pass back +person_resource.DisplayName+ instead. | def fullname(opt = {})
options = { :middlename => true, :skip_update => false, :override_with_local => true, :ignore_nickname => false }.merge(opt)
if person_resource? && !options[:skip_update]
update_resource_cache! rescue nil
return display_name unless options[:override_with_local]
end
ret... | [
"def fullname\n return person.fullname if !person.nil? && verified?\n \"#{firstname} #{lastname}\"\n end",
"def person_full_name\n person_full_name = ''\n person_full_name += self.person_prefix + ' ' if self.person_prefix\n person_full_name += self.person_forenames_inline if self.person_forenames_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this Person attended the specified event, and returns true if so. Optionally, provide an EventType or EventGroup and this will return true if the Person attended any events in that type or group. | def attended?(event)
return false unless event.is_a?(Event) || event.is_a?(EventGroup) || event.is_a?(EventType)
if event.is_a?(Event)
return false unless events.include?(event)
event_attendances.find_by_event_id(event.id).attended?
elsif event.is_a?(EventGroup)
attendances = event_attend... | [
"def attended_event?(event)\n attendee = EventAttendee.find_by(event_id: event.id, user_id: id)\n if attendee\n if attendee.attended\n 2\n else\n 1\n end\n else\n 0\n end\n end",
"def attended_event? event\n event_registration = event.events_registrations.find_by(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this Person RSVP'd yes for the specified event, and returns true if so. | def attending?(event)
return false unless event.is_a?(Event)
return false unless events.include?(event)
event_attendances.find_by_event_id(event.id).rsvp?
end | [
"def ready_to_rsvp?(event = nil)\n return false if self.class == Person\n self.validate_ready_to_rsvp = true\n self.valid?\n end",
"def confirmedEvent?(event)\n return !Contribution.find_by(event_id: event.id, user_id: self.id).pending\n end",
"def confirm_event(event)\n participant_event = g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this Person has an attendance option set for the specified event, and returns the value if so. | def attendance_option(event)
return false unless event.is_a?(Event)
return false unless events.include?(event)
event_attendances.find_by_event_id(event.id).attendance_option
end | [
"def attend_to?(event)\n attendances.find_by(event_id: event).try(:attend)\n end",
"def attendance_for(event)\n attendances.where(event_id: event.id).first\n end",
"def attended?(event)\n return false unless event.is_a?(Event) || event.is_a?(EventGroup) || event.is_a?(EventType)\n\n if event.is_a?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the user's firstname or nickname based on Customer preference. | def firstname
Customer.display_nicknames_by_default? ? (nickname.blank? ? read_attribute(:firstname) : nickname) : read_attribute(:firstname)
end | [
"def nickname\n (preferred_name && !preferred_name.strip.empty?) ? preferred_name : first_name\n end",
"def nickname\n (preferredName and not preferredName.strip.empty?) ? preferredName : firstName\n end",
"def preferred_name\n read_attribute(:preferred_name) || primary_first_name\n end",
"def dis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this person's +followup_note_count+ is greater than zero. | def needs_followup?
followup_note_count && followup_note_count > 0
end | [
"def follows?(model)\n 0 < self.followees.where(ff_id: model.id).limit(1).count\n end",
"def following?(user)\n !find_follower(user).nil?\n end",
"def following?\n Follow.where(follower_class: self.class.to_s, follower_id: id).count > 0\n end",
"def user_follows(current_user: , display... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pulls in contact info from the Person Web Service and updates our local cache if it hasn't been updated in the amount of time specified in +PERSON_RESOURCE_CACHE_LIFETIME+. Pass +true+ to force a refresh regardless of the time passed. Returns +true+ if the cache was updated or +false+ if not. | def update_resource_cache!(force = false)
if person_resource? && (resource_cache_expired? || force)
return true if self.update_attributes(
:display_name => person_resource.attributes["DisplayName"],
:firstname => person_resource.attributes["RegisteredFirstMiddleName"],
:lastname... | [
"def update\n if @contact.update(contact_params)\n fresh_when(@contact)\n render json: @contact, status: :ok, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end",
"def cached?\n options[:cache] == true\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the survey_id or generates one if it's nil | def survey_id
generate_survey_id unless new_record?
end | [
"def survey_identifier\n @form || @instrument\n end",
"def real_survey_id\n\t\tSurvey.decode_external_id(self.external_survey_id).first\n\tend",
"def raw_survey_id\n\t\tread_attribute(:survey_id)\n\tend",
"def survey_question(survey_id, id)\n get(\"survey/#{survey_id}/surveyquestion/#{id}\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the survey_id without generating it if it doesn't exist. | def raw_survey_id
read_attribute(:survey_id)
end | [
"def survey_id\n generate_survey_id unless new_record?\n end",
"def real_survey_id\n\t\tSurvey.decode_external_id(self.external_survey_id).first\n\tend",
"def survey_identifier\n @form || @instrument\n end",
"def get_survey_template_id(survey_template_name, catalog_name)\n entry = @@remedy_forms['K... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
People are considered "ready to RSVP" if certain aspects of their profile are complete. Generic "Person" resources are _never_ considered ready to RSVP because they need to be classified as a more specific type of Person first. For all people: name email gender phone number birthdate For Students and Participants: affi... | def ready_to_rsvp?(event = nil)
return false if self.class == Person
self.validate_ready_to_rsvp = true
self.valid?
end | [
"def can_create_new_rtp?\n bc_resident? && !funded_people.empty?\n end",
"def person_type\n offering_interviewer.nil? ? 'applicant' : 'interviewer'\n end",
"def refused_to_participate?\n !self.pr_recruitment_end_date.blank? && self.pr_recruitment_status_code == 2\n end",
"def can_review?(person)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this person has completed the specified training | def completed_training?(training)
return false if training.nil?
c = training_completions.find(:first, :conditions => { :training_id => training.id })
c.nil? ? false : c.completed?
end | [
"def training?\n self.trainings.not_finished.count > 0\n end",
"def learning_successful?\n @step_list[-1].all_correct?\n end",
"def is_training_finished(points)\n res = true\n points.each do | point|\n if point <= NUMBER_OF_CORRECTNESS\n res= false\n return false\n end\n end\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the text of the +background_check_result+ attribute includes either "OK" or "NO RECORD FOUND". This allows staff to allow a student to participate even if a conviction history has been found but the school has approved that student's participation. In that case, the background check result text will inc... | def passed_background_check?
return false if background_check_result.nil?
valid_length = Customer.current_customer.background_check_validity_length || 0
return true if valid_length < 0
return false if (background_check_run_at.nil? || background_check_run_at < valid_length.days.ago)
background_check_... | [
"def check_background_check_result(request_id)\n return_code, response = send_command(\"background_check/check_result\",\n token, {:request_id => request_id})\n return response if return_code == \"200\"\n raise ArgumentError, response[\"error\"]\n end",
"def background_check_pending?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the +background_check_authorized_at+ is not nil but the person hasn't passed the background check yet. This means that a staff person hasn't yet run the check and entered it into the system yet. | def background_check_pending?
!background_check_authorized_at.nil? && (!passed_background_check? && background_check_run_at.nil?)
end | [
"def sex_offender_check_pending?\n !background_check_authorized_at.nil? && (!passed_sex_offender_check? && sex_offender_check_run_at.nil?)\n end",
"def passed_background_check?\n return false if background_check_result.nil?\n valid_length = Customer.current_customer.background_check_validity_length || 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the text of the +sex_offender_check_result+ attribute includes either "OK" or "NO RECORD FOUND". This allows staff to allow a student to participate even if a conviction history has been found but the school has approved that student's participation. In that case, the sex offender check result text will... | def passed_sex_offender_check?
return false if sex_offender_check_result.nil?
valid_length = Customer.current_customer.background_check_validity_length || 0
return true if valid_length < 0
return false if (sex_offender_check_run_at.nil? || sex_offender_check_run_at < valid_length.days.ago)
sex_offen... | [
"def company_convictions_match_found?\n conviction_search_result.first &&\n (conviction_search_result.first.match_result != 'NO')\n end",
"def show_explanation?\n status_checker(2) #Show explanation when everyone is \"confirmed\" or status==2\n end",
"def accepts_outcome_status_of_result?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if a staff person hasn't yet run the check and entered it into the system. | def sex_offender_check_pending?
!background_check_authorized_at.nil? && (!passed_sex_offender_check? && sex_offender_check_run_at.nil?)
end | [
"def needs_background_check?\n core_staff? or volunteer? or official?\n end",
"def verify_staff_member_exists(selected)\n\twhile StaffMember.find_by_id(selected).nil?\n\t\tputs \"\\nNo staff members identified as entered\\n\"\n\t\tshow_all_staff_members\n\t\tselected = make_selection.to_i\n\tend\n\tselected\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if both SO and BG checks passed, false otherwise | def passed_criminal_checks?
passed_sex_offender_check? && passed_background_check?
end | [
"def passed_background_check?\n return false if background_check_result.nil?\n valid_length = Customer.current_customer.background_check_validity_length || 0\n return true if valid_length < 0\n return false if (background_check_run_at.nil? || background_check_run_at < valid_length.days.ago)\n backgro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If both SO and criminal background checks were run, returns later of the two dates on which the checks were run. Useful for displaying a single date for when background checks were passed | def criminal_checks_run_at
if sex_offender_check_run_at && background_check_run_at
[sex_offender_check_run_at, background_check_run_at].max
else
nil
end
end | [
"def end_date\n return checked_in if checked_in\n return Time.zone.today if overdue\n due_date\n end",
"def day_before; last_day; end",
"def last_fixity_date_time_before\n @last_fixity_date_time_before ||= formatted_last_fixity_date_time(blacklight_params['last_fixity_date_time_before'])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if there are any responses "Yes" on the background check form from mentor signup. | def has_background_check_form_responses?
return true if crimes_against_persons_or_financial? || drug_related_crimes?
return true if related_proceedings_crimes? || medicare_healthcare_crimes? || general_convictions?
false
end | [
"def responded?\n !approval_response.blank?\n end",
"def confirm?\n !@session.nil? && !@session.meetup.archived && @session.confirmation_mail == true\n end",
"def awaiting_email_verification?\n return false if email_verified?\n\n pending_notices({ type: 'email', dispatched: true }).any?\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this Person's first (or only) User record is an AnonymousUser. Anonymous users can never be admins. | def is_anonymous_user?
users.first.is_a?(AnonymousUser)
end | [
"def anonymous_user?\n @attributes[:uri] =~ /^anonymous\\:\\/\\/(.*)$/\n $1 || false\n end",
"def anonymous?\n !@anonymous_mode\n end",
"def is_anonymous?\n false\n end",
"def allow_anonymous?\n @allow_anonymous\n end",
"def if_anonymous\n !is_bot? &... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
By default, a person never has a correct login token. | def correct_login_token?(given_token)
false
end | [
"def is_ordinary_user?(facebook_token)\n facebook_token.blank?\n end",
"def needs_login?() false end",
"def skip_authenticate_user_if_token\n initialize_lesson\n update_ok(@lesson.is_public || (logged_in? && session[:user_id].to_i == @lesson.user_id)) if @ok && @lesson.token != params[:token]\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This mentor has a valid login token if there is a value in +login_token+ and the timestamp in +login_token_expires_at+ is in the future. | def has_valid_login_token?
return false if login_token.blank? || login_token_expires_at.nil?
login_token_expires_at.future?
end | [
"def correct_login_token?(given_token)\n false\n end",
"def validate_token\n token = params[:token]\n return false if token.nil?\n \n user = User.validate_token(token)\n return false if user.nil?\n \n login_user(user)\n return true\n end",
"def validate_token\n t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a new random login token and stores a secure hash of the token in the record, along with an expiry date of 1 week from now. | def generate_login_token!
new_login_token = SecureRandom.hex(24)
salt = SecureRandom.hex(24)
hash = token_hash(new_login_token, salt)
update_attributes(:login_token => concatenate_token_record(hash, salt), :login_token_expires_at => 1.week.from_now)
new_login_token
end | [
"def make_token\n secure_digest(Time.now, (1..10).map{ rand.to_s })\n end",
"def generate_new_token\n delete_from_database\n composite = generate_and_save_token(cookies[:uid])\n cookie_manager.persistent_login(cookies[:uid], composite)\n end",
"def make_a_token\n\t\t\treturn Digest::SHA1.hexdigest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uppercases the first letter of the string and does nothing else. | def uppercase_first_letter(str)
str[0..0].upcase + str[1..-1] rescue str
end | [
"def uncapitalize\n (self.length > 0) ? (self[0, 1].downcase + self[1..-1]) : \"\"\n end",
"def upcase_first(string); end",
"def capitalize\n return dup if @num_bytes == 0\n\n str = transform(Rubinius::CType::Lowered, true)\n str = self.class.new(str) unless instance_of?(String)\n\n str.modify!\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current menu item name | def current_menu_item
controller.current_menu_item
end | [
"def menu_item_name\n menu_options[:label] || plural_resource_name_alias.html_safe\n end",
"def current_menu_item\n if action_name == \"index\"\n loaded_menu_items[-2]\n else\n loaded_menu_items[-1]\n end\n end",
"def name\n object.try(:menu_display_name)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
are there works done in the previous stage and ready to be drilled/polished/tempered/delivered? | def available_works?
if prev.valid_tracking?
prev.done > done
else
product_line_quantity > done
end
end | [
"def has_work?\n how_much_more_work > 0\n end",
"def settled?\n return !self.pending?\n end",
"def completed?\n return self.shift_jobs.count > 0\n end",
"def all_aircraft_processed?\n done_queue.length == @arrival_count\n end",
"def distribution_done?\n @started.all?\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
utility method for testing for a tracking object, returns an array with all the following steps cut.tracking_full_path => [:cut, :drill, :polish, :delivery] | def tracking_full_path
full_path = []
current_track = self
loop do
full_path << current_track.stage_name.downcase.to_sym
break unless current_track.next_tracking
current_track = current_track.next_tracking
end
full_path
end | [
"def follow_path( steps, past_steps = [] )\n if steps.is_a?( Hash )\n steps.each do |step, next_steps|\n path_to_this_point = [past_steps, step].flatten\n reflection = reflection_for( path_to_this_point ) rescue nil\n if reflection\n follow_path( next_steps, path_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Inspec helper for the specified host against the specified profile | def initialize(sut, profile)
@sut = sut
@sut.install_package('inspec')
os = fact_on(@sut, 'operatingsystem')
os_rel = fact_on(@sut, 'operatingsystemmajrelease')
@profile = "#{os}-#{os_rel}-#{profile}"
@profile_dir = '/tmp/inspec/inspec_profiles'
@deps_root = '/tmp/inspec'
... | [
"def initialize(sut, profile)\n @inspec_version = ENV['BEAKER_inspec_version'] || 'latest'\n\n @sut = sut\n\n @sut.install_package('git')\n\n if @inspec_version == 'latest'\n @sut.install_package('inspec')\n else\n @sut.install_package(\"inspec-#{@inspec_version}\")\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the inspec tests and record the results | def run
sut_inspec_results = '/tmp/inspec_results.json'
inspec_cmd = "inspec exec '#{@test_dir}' --reporter json > #{sut_inspec_results}"
result = on(@sut, inspec_cmd, :accept_all_exit_codes => true)
tmpdir = Dir.mktmpdir
begin
Dir.chdir(tmpdir) do
if @sut[:hypervisor] ... | [
"def run\n tests.each do |test|\n test.run\n Reporter.print_single_test_result(test)\n end\n end",
"def run\n\n @startDate = Time.now.to_i * 1000\n @status = 'Started'\n start_test_run(create_test_objects(@tests, @runOptions, @id), @cmd)\n @status = 'Completed'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
merging the above arrays into one larger array of smaller arrays | def merge_arrays (first, second)
large_array = []
11.times do |i|
smaller_array = []
smaller_array << first[i]
smaller_array << second[i]
large_array << smaller_array
end
return large_array
end | [
"def merge(array1, array2)\n final_array = []\n (final_array << array1 << array2).flatten.sort.uniq\nend",
"def merge_arrays(a, b)\n a.zip(b).flatten.uniq.sort!\nend",
"def union(*arrays)\n new_arr = []\n \n arrays.each do |array|\n new_arr << array\n end\n\n return new_arr.flatten\nend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return a LIST of all the config keys for the given plugin | def plugin_configs(plugin)
ret = []
if r = @collection.find_one( { plgid: plugin } )
r.keys.each {|k| ret << k unless ['_id', 'plgid'].include?(k) }
end
ret
end | [
"def get_keys()\n\t\t\treturn @config.keys\n\t\tend",
"def config_keys\n config.keys\n end",
"def keys\n @config.keys\n end",
"def keys\n @config.keys\n end",
"def list\n @plugins.keys\n end",
"def get_all_keys\n settings, _ = _get_settings()\n if settings === nil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /parlamentarians GET /parlamentarians.json | def index
page = params[:page]
page = 1 if page.nil? || page == 0
offset = (Integer(page) - 1) * RESULTS_PER_PAGE
offset = offset + 1 if Integer(page) > 1
@parlamentarians = Parlamentarian.find_all(true, RESULTS_PER_PAGE, offset)
@paginated_parlamentarians = @parlamentarians.paginate(:page => pa... | [
"def index\n @parishes = Parish.all\n\n render json: @parishes\n end",
"def index\n @parks = Park.all\n\n render json: @parks\n end",
"def index\n @pains = Pain.all\n render json: @pains\n end",
"def index\n @parks = Park.all\n\n respond_to do |format|\n format.html # index.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a method that will take two numbers, and return whichever is the largest. Difficulty: 2/10 Example: largest_number(100,50) should return 100 largest_number(10,20) should return 20 | def largest_number (number_1, number_2)
if (number_1 == number_2)
return number_1 # could also return number_2 here, doesn't matter which
elsif (number_1 < number_2)
return number_2
elsif (number_1 > number_2)
return number_1
end
end | [
"def max_of_two(number1, number2)\n if number1 > number2\n largest = number1\n else\n largest = number2\n end\n return largest\nend",
"def largest_number (number_1, number_2)\n \n [number_1, number_2].max\n \nend",
"def max_of_two(number1, number2)\n if number1 > number2\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get list of associated attachment_links | def attachment_links()
@attachment_links ||= AttachmentLink.where("master_id = ? AND master_type = ?", id, class_name).limit(attachments_count)
end | [
"def index\n @link_attachments = LinkAttachment.all\n end",
"def attachment_urls\n @list.when_list do\n result = call(\"Lists\", \"get_attachment_collection\", \"listName\" => @list.id, \"listItemID\" => @id)\n return result.xpath(\"//sp:Attachment\", NS).map { |att| att.text }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
attaches attachment to article | def attach(attachment)
if new_attlink(attachment).save
increment_attachments_count
reload_attachments_with attachment
attachment.increment_masters_count
end
end | [
"def attach!(attachment)\n unless send(\"#{attachment.class.name.downcase}_ids\").include?(attachment.id)\n if attachment.is_a?(Task)\n send(attachment.class.name.tableize) << attachment\n else # Leads, Opportunities\n attachment.update_attribute(:campaign, self)\n attachment.send(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The 'remove' method removes a child component from the current component class. | def remove(component)
@children.delete(component)
component.parent = nil
end | [
"def remove_child(component)\n @children.delete(component)\n component.parent = nil\n end",
"def remove item\n @components.remove item\n end",
"def remove_component_at(index:)\n component = @child_components.delete_at(index)\n\n @view.remove_view(component.view)\n\n c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The 'get_child' method will return a child of this class by index. | def get_child(index)
@children[index]
end | [
"def get_child(index)\n @children[index]\n end",
"def child(index = 0)\r\n children[index]\r\n end",
"def child(index)\n @children[index]\n end",
"def get(index)\n @children[index]\n end",
"def [](index)\n @children[index]\n end",
"def get_child(name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build the icon URL from the icon slug. | def set_icon_url(page)
if page['iconSlug']
page.data['iconUrl'] = "https://cdn.jsdelivr.net/npm/simple-icons/icons/#{page['iconSlug']}.svg"
end
end | [
"def icon_url(icon)\n icon_set_url % icon\n end",
"def icon_url\n @icon_url || icon_emoji\n end",
"def icon_url style = :original\n icon.url(style, timestamp: false)\n end",
"def site_icon_url(size = 512, url = '', blog_id = 0)\n esc_url(get_site_icon_url(size, url, blog_id ))... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set properly the column presence/label if it was overridden. | def set_overridden_columns_label(page)
date_column_names = [
'releaseDateColumn', 'releaseColumn', 'discontinuedColumn',
'activeSupportColumn', 'eolColumn', 'extendedSupportColumn'
]
for date_column in date_column_names
if page.data[date_column].is_a? String
... | [
"def label_column; @label_column ||= LABEL_COLUMNS.find{|c|columns.include?(c)}; end",
"def column_label column; labels_for_columns[column.to_s] || default_column_label( column.to_s ); end",
"def column_name\n name.presence || label.to_s_default\n end",
"def allow_format_columns=(value)\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Flag all cycles that can be hidden (see 50). The goal of this function is to hide only a single run of rows, at the very end, if they are all unmaintained. This function presume that all cycles are ordered by their release date, so a cycle can be hidden only if: it is not the first cycle, it is unmaintained (see set_is... | def flag_oldest_unmaintained_releases(page)
min_total_cycles = 6 # apply only if the number of cycles is greater than this
min_hidden_cycles = 3 # apply only if the number of hidden cycles is greater than this (must be < min_total_cycles)
releases = page.data['releases']
if releases.len... | [
"def set_cycle_discontinued_fields(cycle)\n explode_date_or_boolean_field(cycle, 'discontinued', 'is_discontinued', 'discontinued_from')\n end",
"def all_hidden(&block)\n @all_hidden = true\n yield\n ensure\n @all_hidden = nil\n end",
"def hide_unused_nodes(graph)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build the cycle id from the permalink. | def set_cycle_id(cycle)
cycle['id'] = cycle['releaseCycle'].tr('/', '-')
end | [
"def permalink\n discussion.to_s.parameterize.split(\"-\").slice(0..4).join(\"-\")\n end",
"def cycle_id\n return @cycle_id\n end",
"def cycle_id=(value)\n @cycle_id = value\n end",
"def generate_permalink\n if self.title.present? && self.permalink.bl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set lts to false if it has no value and explode it to is_lts (boolean) and lts_from (Date). See explode_date_or_boolean_field(...) for more information. | def set_cycle_lts_fields(cycle)
if not cycle.has_key?('lts')
cycle['lts'] = false
end
explode_date_or_boolean_field(cycle, 'lts', 'is_lts', 'lts_from')
end | [
"def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)\n if not cycle.has_key?(field_name)\n return\n end\n\n value = cycle[field_name]\n if value.is_a?(Date)\n cycle[boolean_field_name] = (Date.today > value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Explode support to is_active_support_over (boolean) and active_support_until (Date). See explode_date_or_boolean_field(...) for more information. | def set_cycle_active_support_fields(cycle)
explode_date_or_boolean_field(cycle, 'support', 'is_active_support_over', 'active_support_until', true)
end | [
"def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)\n if not cycle.has_key?(field_name)\n return\n end\n\n value = cycle[field_name]\n if value.is_a?(Date)\n cycle[boolean_field_name] = (Date.today > value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Explode extendedSupport to is_extended_support_over (boolean) and extended_support_until (Date). See explode_date_or_boolean_field(...) for more information. | def set_cycle_extended_support_fields(cycle)
explode_date_or_boolean_field(cycle, 'extendedSupport', 'is_extended_support_over', 'extended_support_until', true)
end | [
"def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)\n if not cycle.has_key?(field_name)\n return\n end\n\n value = cycle[field_name]\n if value.is_a?(Date)\n cycle[boolean_field_name] = (Date.today > value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Explode eol to is_eol (boolean) and eol_from (Date). See explode_date_or_boolean_field(...) for more information. | def set_cycle_eol_fields(cycle)
explode_date_or_boolean_field(cycle, 'eol', 'is_eol', 'eol_from')
end | [
"def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)\n if not cycle.has_key?(field_name)\n return\n end\n\n value = cycle[field_name]\n if value.is_a?(Date)\n cycle[boolean_field_name] = (Date.today > value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Explode discontinued to is_discontinued (boolean) and discontinued_from (Date). See explode_date_or_boolean_field(...) for more information. | def set_cycle_discontinued_fields(cycle)
explode_date_or_boolean_field(cycle, 'discontinued', 'is_discontinued', 'discontinued_from')
end | [
"def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)\n if not cycle.has_key?(field_name)\n return\n end\n\n value = cycle[field_name]\n if value.is_a?(Date)\n cycle[boolean_field_name] = (Date.today > value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Some product cycle fields (field_name) can be either a date or a boolean. This function create two additional variables, one of boolean type (boolean_field_name) and the other of Date type (date_field_name) to simplify usages in templates or Jekyll plugins. The invert parameter must be set according to the date nature.... | def explode_date_or_boolean_field(cycle, field_name, boolean_field_name, date_field_name, invert = false)
if not cycle.has_key?(field_name)
return
end
value = cycle[field_name]
if value.is_a?(Date)
cycle[boolean_field_name] = (Date.today > value)
cycle[date... | [
"def set_cycle_discontinued_fields(cycle)\n explode_date_or_boolean_field(cycle, 'discontinued', 'is_discontinued', 'discontinued_from')\n end",
"def get_boolean_field(field_name)\n\t\tend",
"def compute_days_toward_now_for_all_dates(cycle)\n for field in ['support', 'eol', 'discontinued', 'e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute the number of days toward now for all cycle's dates (support, eol...), and add those values to the cycle's data in new fields (days_toward_support, days_toward_eol...). | def compute_days_toward_now_for_all_dates(cycle)
for field in ['support', 'eol', 'discontinued', 'extendedSupport']
next if not cycle.has_key?(field)
field_value = cycle[field] # either a date or a boolean
new_field_name = 'days_toward_' + field
if field_value.is_a?(Dat... | [
"def calc_due_date\n if !self.terms.blank?\n d = Term.in_days(self.terms)\n self.due_date = self.date + d\n end\n end",
"def days_validation\n @start_cycle = @vote_setting.start_cycle.to_date \n @end_cycle = @vote_setting.end_cycle.to_date\n @days_count = (@end_cycle - @start_cycle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute whether the cycle is still maintained and add the result to the cycle's data. A cycle is maintained if at least one of the active support / eol / discontinued / extended support dates is in the future or is true. This function must be executed after compute_days_toward_now_for_all_dates because it makes use of ... | def set_is_maintained(cycle)
is_maintained = false
for daysTowardField in ['days_toward_support', 'days_toward_eol', 'days_toward_discontinued', 'days_toward_extendedSupport']
if cycle.has_key?(daysTowardField) and cycle[daysTowardField] >= 0
is_maintained = true
break... | [
"def compute_days_toward_now_for_all_dates(cycle)\n for field in ['support', 'eol', 'discontinued', 'extendedSupport']\n next if not cycle.has_key?(field)\n\n field_value = cycle[field] # either a date or a boolean\n new_field_name = 'days_toward_' + field\n\n if field_val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
compare two Amortization instances | def ==(amortization)
self.principal == amortization.principal and self.rates == amortization.rates and self.payments == amortization.payments
end | [
"def compare(t1, t2)\n extract = proc{|t,x| Array(x).inject(t){|m,a| m[a]} }\n reused_instance.each do |atr, dir|\n x, y = extract[t1,atr], extract[t2,atr]\n comp = Support.robust_compare(x, y)\n comp *= -1 if dir == :desc\n return comp unless comp == 0\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
amortize the balance of loan with the given interest rate | def amortize(rate)
# For the purposes of calculating a payment, the relevant time
# period is the remaining number of periods in the loan, not
# necessarily the duration of the rate itself.
periods = @periods - @period
amount = Amortization.payment @balance, rate.monthly, periods
pm... | [
"def gain_interest\n interest_amount = (@balance * @interest_rate) / 100\n @balance = interest_amount + @balance\n end",
"def add_interest(rate)\n interest_amount = @balance * rate/100\n return @balance = @balance + interest_amount\n end",
"def add_interest(rate)\n interest = balance ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns true or false depending on if keyspace exists in the current cluster. Returns true if keyspace exists, false if it does not. | def exists?
@executor.call({
command: :keyspaces,
transformer_arguments: {
executor: @executor,
},
}).any? { |keyspace| keyspace.name == @name }
end | [
"def keyspace_exists?(keyspace)\n klass = OpenStruct.new(column_family: 'system.schema_keyspaces', default_consistency: 'QUORUM')\n cql = DatastaxRails::Cql::ColumnFamily.new(klass)\n results = cql.select('count(*)').conditions('keyspace_name' => keyspace).execute\n results.first['count'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get all column families for keyspace. Returns Array of Cassanity::ColumnFamily instances. | def column_families
@executor.call({
command: :column_families,
arguments: {
keyspace_name: @name,
},
transformer_arguments: {
keyspace: self,
}
})
end | [
"def column_families\n return false if Cassandra.VERSION.to_f < 0.7\n\n schema.cf_defs.inject(Hash.new){|memo, cf_def| memo[cf_def.name] = cf_def; memo;}\n end",
"def column_families\n check_view_and_load(:SCHEMA_VIEW)\n @grpc.column_families.map do |cf_name, cf_grpc|\n ColumnF... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /manage/article_types GET /manage/article_types.json | def index
@manage_article_types = Admin::ArticleType.all
end | [
"def types\n respond_to?(:articleType) ? articleType : []\n end",
"def index\n @article_types = ArticleType.all\n end",
"def index\n @admin_article_types = Admin::ArticleType.all\n end",
"def index\n @article_types = ArticleType.all\n\n respond_to do |format|\n format.html #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /manage/article_types POST /manage/article_types.json | def create
@manage_article_type = Admin::ArticleType.new(manage_article_type_params)
respond_to do |format|
if @manage_article_type.save
format.html { redirect_to manage_article_types_path, notice: '创建成功.' }
format.json { render :show, status: :created, location: @manage_article_type }
... | [
"def create\n @article_type = ArticleType.new(params[:article_type])\n\n respond_to do |format|\n if @article_type.save\n format.html { redirect_to @article_type, notice: 'Article type was successfully created.' }\n format.json { render json: @article_type, status: :created, location: @arti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /manage/article_types/1 PATCH/PUT /manage/article_types/1.json | def update
respond_to do |format|
if @manage_article_type.update(manage_article_type_params)
format.html { redirect_to manage_article_types_path, notice: '更新成功.' }
format.json { render :show, status: :ok, location: @manage_article_type }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @article_type.update_attributes(article_type_params)\n format.html { redirect_to action: :index, notice: 'Update Success.' }\n format.json { render action: :index, status: :accepted }\n else\n format.html { render action: :edit }\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /manage/article_types/1 DELETE /manage/article_types/1.json | def destroy
@manage_article_type.destroy
respond_to do |format|
format.html { redirect_to manage_article_types_url, notice: '删除成功.' }
format.json { head :no_content }
end
end | [
"def destroy\n @article_type = ArticleType.find(params[:id])\n @article_type.destroy\n\n respond_to do |format|\n format.html { redirect_to article_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_article_type.destroy\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.