query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
A functional group of related transaction sets, within the scope of X12 standards, consists of a collection of similar transaction sets enclosed by a functional group header and a functional group trailer | def functional_group_loop
[functional_group_header, transactions, functional_group_trailer(@batch.id)].compact
end | [
"def functional_group_loop\n segments = []\n segments << functional_group_header\n segments << transactions\n segments << functional_group_trailer(nil)\n segments = segments.compact\n segments\n end",
"def ordered_groups\n output = Array.new\n set_group = proc{|title, fields|\n outpu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generating check level segments | def generate_check
Output835.log.info "\n\nCheck number : #{@check.check_number} undergoing processing"
transaction_segments =[ transaction_set_header, financial_info, reassociation_trace]
transaction_segments << ref_ev_loop if @facility_output_config.details[:ref_ev_batchid]
transaction_segments += [r... | [
"def create_segments\n Segment.split_to_segments(build_waypoints)\n end",
"def health_remark_code_segments\n @eob = service.insurance_payment_eob\n facility = @eob.check_information.job.batch.facility\n health_remark_code_segments = []\n health_remark_code_segments << compute_lq(\"in\")\n healt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The TRN segment is used to uniquely identify a claim payment and advice. | def reassociation_trace
simple_client_array_for_1000000009 = ["NAVICURE", "ASCEND CLINICAL LLC"]
trn_elements = ['TRN', '1', ref_number]
if simple_client_array_for_1000000009.include? (@client_name)
trn_elements << '1000000009'
elsif @check_amount.to_f > 0 && @check.payment_method == "EFT"
t... | [
"def trn\n get :trn\n end",
"def reassociation_trace\n trn_elements = ['TRN', '1', ref_number]\n if @check_amount.to_f > 0 && @check.payment_method == \"EFT\"\n trn_elements << '1' + @facility.facility_tin if @facility.facility_tin.present?\n else\n trn_elements << '1999999999'\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The N1 loop allows for name/address information for the payee which would be utilized to address remittance(s) for delivery. | def payee_identification_loop(repeat = 1)
payee = get_facility
if payee
if ( payee.name.blank? || payee.address_one.blank? || payee.city.blank? || payee.state.blank? || payee.zip_code.blank?)
@claim = payee.clone
payee = @facility #if any of the billing provider address details is missing ... | [
"def payee_identification_loop(repeat = 1)\n payee = get_facility\n if payee\n if ( payee.name.blank? || payee.address_one.blank? || payee.city.blank? || payee.state.blank? || payee.zip_code.blank?)\n @claim = payee.clone\n payee = @facility #if any of the billing provider address details i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generating Eob level segments | def generate_eobs
Output835.log.info "\n\nPatient account number : #{@eob.patient_account_number}"
Output835.log.info "This EOB has #{@services.length} service lines"
Output835.log.info "This is a CLAIM LEVEL EOB" if @is_claim_eob
claim_segments = [claim_payment_loop, include_claim_dates]
claim_seg... | [
"def Segment\n A = 1\n B = 2\n C = 4\n D = 8\n E = 16\n F = 32\n G = 64\n H = 128\n J = 256\n K = 512\n M = 1024\n N = 2048\n P = 4096\n\n def initialize(segments=0)\n @segments = segments\n end\n\n def s(seg=Segment.new)\n Segment.new seg.segments + SOUTH\n end\nend",
"def segments\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get claim_number for payer_group not of type 'PatPay' | def claim_number
@eob.claim_number.to_s
end | [
"def get_payer_group\r\n case payer_type\r\n when 'PatPay'\r\n 'PatPay'\r\n else\r\n 'Insurance'\r\n end\r\n end",
"def claim_number\n str = eob.check_information.check_number.to_s if eob.check_information\n (str += '_' + eob.claim_number) if !eob.claim_number.blank?\n str\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Used when additional reference numbers specific to the claim in the CLP segment are provided to identify information used in the process of adjudicating this claim | def other_claim_related_id
if @eob.insurance_policy_number.present?
elem = ['REF','IG', @eob.insurance_policy_number].trim_segment.join(@element_seperator)
end
end | [
"def other_claim_related_id\n elem = []\n if !eob.insurance_policy_number.blank?\n elem << 'REF'\n elem << 'IG'\n elem << eob.insurance_policy_number\n elem = Output835.trim_segment(elem)\n elem.join(@element_seperator)\n end\n end",
"def sequence_ref\n\t\t\t\t\traise \"Please d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generating service level segments | def generate_services
is_adjustment_line = @service.adjustment_line_is?
service_segments = []
service_segments << service_payment_information unless is_adjustment_line
service_segments << service_date_reference
unless is_adjustment_line
cas_segments, pr_amount, crosswalked_codes = Output835.ca... | [
"def segments\n @segments ||= generate_segments\n end",
"def create_segments\n Segment.split_to_segments(build_waypoints)\n end",
"def segments\n #segments = @route.segments.select do |segment|\n # [ActionController::Routing::DynamicSegment, ActionController::Routing::StaticSegment].inclu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
supplies payment and control information to a provider for a particular service | def service_payment_information(eob = nil,service = nil,check = nil,is_claim_eob = nil,payer = nil)
@service = @service.nil?? service : @service
['SVC', composite_med_proc_id, @service.amount('service_procedure_charge_amount'), @service.amount('service_paid_amount'),
svc_revenue_code, @service.service_qu... | [
"def service_payment_info_loop\n end",
"def service_payment_information(eob = nil,service = nil,check = nil,is_claim_eob = nil,payer = nil)\n @service = @service.nil? ? service : @service\n ['SVC', composite_med_proc_id, @service.amount('service_procedure_charge_amount'), @service.amount('service_paid_amo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The DTM segment in the SVC loop is to be used to express dates and date ranges specifically related to the service identified in the SVC segment If service from and to dates are same, only print one segment with qual 472 Else print one segment each for the two dates | def service_date_reference
svc_date_segments = []
from_date = @service.date_of_service_from.strftime("%Y%m%d") unless @service.date_of_service_from.blank?
to_date = @service.date_of_service_to.strftime("%Y%m%d") unless @service.date_of_service_to.blank?
from_eqls_to_date = (from_date == to_date)
is_... | [
"def service_date_reference\n svc_date_segments = []\n from_date = @service.date_of_service_from.strftime(\"%Y%m%d\") unless @service.date_of_service_from.blank?\n to_date = @service.date_of_service_to.strftime(\"%Y%m%d\") unless @service.date_of_service_to.blank?\n svc_date_segments << ['DTM', '150', f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Identifies the orionvm cloud === Return true:: If the orionvm cloud can be identified false:: Otherwise | def looks_like_orionvm?
hint?('orionvm') || looks_like_orionvm_v2? || looks_like_orionvm_v3?
end | [
"def cloud?\n self.automatic.has_key?(:cloud)\n end",
"def manage_ip?\n case type.hotspot\n when 'hsv1-mem' then true\n when 'hsv2-bam' then false\n else false\n end\n end",
"def is_current_cloud?\n # See https://developers.google.com/compute/docs/instances#dmi\n `grep Google /sys/firm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines whether IP address is private (reserved) === Parameters address:: IP address to test (ie '192.168.0.1') | def is_private?(address)
[
IPAddr.new('10.0.0.0/8'),
IPAddr.new('172.16.0.0/12'),
IPAddr.new('192.168.0.0/16'),
].any? do |i|
i.include? address
end
end | [
"def private_ip_address?\n ip_address? && IpAddress.new(text).private?\n end",
"def is_private(ip)\n\t\tpriv = FALSE\n\t\tif (ip_int(\"10.0.0.0\")..ip_int(\"10.255.255.255\")) === ip_int(ip)\n\t\t\tpriv = TRUE\n\t\telsif (ip_int(\"172.16.0.0\")..ip_int(\"172.31.255.255\")) === ip_int(ip)\n\t\t\tpriv = TRU... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override to disable heartbeat | def run
unless @heartbeat_type == :none
super
end
end | [
"def shutdown\n\t\tself.stop_heartbeat\n\t\tsuper\n\tend",
"def disable_heartbeat(name, opts = {})\n data, _status_code, _headers = disable_heartbeat_with_http_info(name, opts)\n return data\n end",
"def restart\n\t\tself.stop_heartbeat\n\t\tsuper\n\t\tself.start_heartbeat\n\tend",
"def heartbeat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper method that will give you a joined pods/metrics query proxy. | def metrics
pods.outer_join(:github_pod_metrics).on(:id => :pod_id).join(:cocoadocs_pod_metrics).on(:id => :pod_id)
end | [
"def metrics\n pods.join(:github_pod_metrics).on(:id => :pod_id)\n .join(:cocoadocs_pod_metrics).on(:id => :pod_id)\n end",
"def metrics\n pods.join(:github_pod_metrics).on(:id => :pod_id)\n end",
"def afnetworking_github_pod_metrics\n Domain.github_pod_metrics.where(pod_id: afnetworking.id).a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up an array of the first count tag IDs with the specified batch URN. Output parameters tagIds (array of string, `E12345678912345678`) ... Array of RFID tag identifiers | def get_query_tags(batch_urn,
count = 100000)
# prepare query url
_query_builder = Configuration.base_uri.dup
_query_builder << '/rest/tag/queryTags'
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
'batchUrn' => batch_urn,
'c... | [
"def add_tag_return_IDs(tag)\n # Split and strip the tags\n tags = tag.split(\",\").collect{|x| x.strip}\n i = 0\n iDs = []\n while i < tags.count do\n # Check if tag exist, if not - add it\n if Teg.find_by_teg(tags[i]).nil?\n\tTeg.new(:teg => tags[i]).save\n end\n # Insert into... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a message to a single numeric tag code. Idempotent Behaviour This endpoint is idempotent and will respond with an appropriate HTTP status code to indicate the actual result 200 OK message available 400 BAD_REQUEST problem occurred, check message parameter for detailed information 401 UNAUTHORIZED user not authorize... | def create_get_single_tag_code_message(body)
# prepare query url
_query_builder = Configuration.base_uri.dup
_query_builder << '/rest/tag/message'
_query_url = APIHelper.clean_url _query_builder
# prepare headers
_headers = {
'accept' => 'application/json',
'content... | [
"def message\n RESPONSE_MESSAGES[code]\n end",
"def message_id_tag(params={:id => 0, :text => nil, :location=>:body, :action=>:generate})\n#puts \"**** params=#{params}\"\n case params[:action]\n when :generate\n if params[:location] == :body\n return \"##{params[:id]}\"\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get application data from tags, which returns data encoded on the tags. This function also returns the lock state of the application data. Idempotent Behaviour This endpoint is idempotent and will respond with an appropriate HTTP status code to indicate the actual result 200 OK tags found and result available (also ret... | def create_get_application_data_from_tags(body)
# prepare query url
_query_builder = Configuration.base_uri.dup
_query_builder << '/rest/tag/value'
_query_url = APIHelper.clean_url _query_builder
# prepare headers
_headers = {
'accept' => 'application/json',
'conten... | [
"def read\n return unless locks\n\n result = locks.find(data_bag_id)\n\n result.to_hash if result\n end",
"def create_get_keys_used_for_tag_authentication(body)\n\n # prepare query url\n _query_builder = Configuration.base_uri.dup\n _query_builder << '/rest/tag/key'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up an array of the first count batchUrns with the specified customer PO. NOTE: Only one customerPO can be specified. Output parameters batchUrns (array of string, `urn:uuid:smartracgroup:batch:99990001`) ... Array of batch URNs | def get_query_batches(customer_po,
count = 100000)
# prepare query url
_query_builder = Configuration.base_uri.dup
_query_builder << '/rest/tag/queryBatches'
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
'customerPO' => customer... | [
"def batch_path\n if @discovery_document['batchPath']\n return @batch_path ||= (\n self.document_base.join(Addressable::URI.parse('/' +\n @discovery_document['batchPath']))\n ).normalize\n else\n return nil\n end\n end",
"def send_batc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get authentication keys for encoded tags, which can be used to access the tag memory. The key names, content and access rules need to be defined when ordering the tags. It is possible to have several applications with their corresponding keys on a tag. Idempotent Behaviour This endpoint is idempotent and will respond w... | def create_get_keys_used_for_tag_authentication(body)
# prepare query url
_query_builder = Configuration.base_uri.dup
_query_builder << '/rest/tag/key'
_query_url = APIHelper.clean_url _query_builder
# prepare headers
_headers = {
'accept' => 'application/json',
'co... | [
"def keys_tag(project_id, params)\n path = sprintf(\"/api/v2/projects/%s/keys/tag\", project_id)\n data_hash = {}\n post_body = nil\n \n if params.present?\n unless params.kind_of?(PhraseApp::RequestParams::KeysTagParams)\n raise PhraseApp::ParamsHelpers::ParamsError.new(\"Expec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new key value entry inside a dictionary with the specified name at the root of this database. Successful completion means the named dictionary will contain one more entry than it need even if it did not previously exist. | def create_entry( dictionary_name, key_name, value )
KeyError.not_new( dictionary_name, self )
KeyError.not_new( key_name, self )
KeyError.not_new( value, self )
self[ dictionary_name ] = {} unless self.has_key?( dictionary_name )
self[ dictionary_name ][ key_name ] = value
end | [
"def insert_directory(directory, directory_name)\n if !directory.has_key?(directory_name)\n directory[directory_name] = Hash.new{}\n end\nend",
"def insert_name_into_hash(hash, name)\r\n sub_hash = {}\r\n if hash[name]\r\n if !hash[name].kind_of? Array\r\n ha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete an existing key value entry inside the dictionary with the specified name at the root of this database. Successful completion means the named dictionary will contain one less entry if that key existed. | def delete_entry( dictionary_name, key_name )
KeyError.not_new( dictionary_name, self )
KeyError.not_new( key_name, self )
self[ dictionary_name ].delete( key_name )
end | [
"def delete_value(name)\n\t\treturn self.client.sys.registry.delete_value(self.hkey, name)\n\tend",
"def delete_document(name)\n #We have to delete <info, <emapping, <amapping, <content, and field in envId:collId:documents\n doc_id = get_document_id(name)\n return unless doc_id\n @builder = Tr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
edit item in the json file and save | def edit(class_name, object)
begin
@data = get_all()
# go through all items in the file
@data[class_name].map!{|item|
if item["id"] == object["id"]
object
else
item
end
}
... | [
"def edit\n require 'ruby-debug'; debugger\n if storage.respond_to?(\"json_file\")\n output \"#{cyan(\"Boom!\")} #{Platform.edit(storage.json_file)}\"\n else\n output \"This storage backend #{red storage.class} does not store #{cyan(\"Boom!\")} data on your computer\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get from json file class data | def get_data(class_name)
return JSON.parse(File.read(@database_file))[class_name]
# error handling
rescue Errno::ENOENT
File.open(@database_file, 'w+')
File.write(@database_file, [])
retry
end | [
"def read\n JSON.parse(File.read(@json))\n end",
"def retrieve\n raise \"Can't retrieve from JSON file. Use text file.\"\n end",
"def parse json; return JSON.parse File.read json end",
"def fetch_json_info\n return {} unless File.exist?(@json_file)\n content = Fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get pets client from json using client id and returning it | def get_pet_list_by_client_id(client_id)
pet_list = []
for pet in get_data("pets")
if client_id == pet["client_id"]
pet_list.push(pet)
end
end
return pet_list
end | [
"def get_client_by_id client_id\n @clients[client_id]\n end",
"def find_client(id:)\n response = get(\"clients/#{id}\")\n PhysitrackApi::Response.from(response)\n end",
"def client_by_id(id)\n clients.select { |client| client.id == id }.first\n end",
"def get_client_by_id(id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get tasks list of the jobs from json using job id and returning it | def get_task_list_by_job_id(job_id)
list_tasks = []
for task in get_data("tasks")
if job_id == task["job_id"]
list_tasks.push(task)
end
end
return list_tasks
end | [
"def get_job(id)\n conn = @client.get do |req|\n req.url \"/api/v2/job/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def list_all_with_details\n response_json = @client.api_get_request(\"\")\n response_json[\"jobs\"]\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get jobs from json using difference of job date and local date now returning jobs for next 7 days | def get_jobs_last_7_days()
@data = get_all()
now = Time.now.to_date
jobs = []
for job in @data["jobs"]
parsed_date = Date.strptime(job["date"], "%d/%m/%Y")
days_difference = (parsed_date - now).to_i
if days_difference <= 7 && days_difference >= 0
... | [
"def get_jobs(url)\n result = JSON.parse(get_data(url))\n job_list = []\n result[\"jobs\"].each do |job_data|\n @@total_job_count += 1\n next if job_data[\"color\"] == \"blue\"\n\n build_score = -1\n build_text = \"\"\n test_score = -1\n test_text = \"\"\n health_report = job_data[\"healthRe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get jobs list from json using client id and returning it | def get_jobs_by_client_id(client_id)
jobs = []
for job in get_data("jobs")
if client_id == job["client_id"]
jobs.push(job)
end
end
return jobs
end | [
"def getMyJobList\n request \"/Job/getMyJobList.json\"\n end",
"def list_all_with_details\n response_json = @client.api_get_request(\"\")\n response_json[\"jobs\"]\n end",
"def list_jobs(json_payload={})\n conn = @client.get do |req|\n req.url '/api/v2/job/list?'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
In production this route kicks in, and in dev we load /assets/modejson.js from the /app/assets/javascripts/modejson.js location.. | def mode_json
path = 'node_modules/ace-builds/src-min-noconflict/mode-json.js'
file_contents = File.read(path)
render js: file_contents, content_type: Mime::Type.lookup('application/javascript')
end | [
"def config_js\n [\n src_config_path.join('routes.js').to_s,\n src_config_path.join('router.js').to_s,\n src_config_path.join('app.js').to_s\n ]\n end",
"def request_debug_assets?; end",
"def ext\n respond_to do |format|\n format.js {\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a static route in EOS. May add or overwrite an existing route. ===Commands ip route [router_ip] [distance] [tag ] [name ] | def create(destination, nexthop, opts = {})
cmd = "ip route #{destination} #{nexthop}"
cmd << " #{opts[:router_ip]}" if opts[:router_ip]
cmd << " #{opts[:distance]}" if opts[:distance]
cmd << " tag #{opts[:tag]}" if opts[:tag]
cmd << " name #{opts[:name]}" if opts[:name]
... | [
"def create_route(route_table_id, destination_cidr_block, options = {})\n request_hash = { 'RouteTableId' => route_table_id,\n 'DestinationCidrBlock' => destination_cidr_block }\n request_hash['GatewayId'] = options[:gateway_id] unless options[:gateway_id].right_blank?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validates that role exists in config file | def role_valid
if (APP_CONFIG["user_roles"]+SYSTEM_DATA["user_roles"]).select{|role| role["name"] == self.role}.empty?
errors.add(:role, "Role does not exist in config")
end
end | [
"def validate_role(role)\n if @role_config.include?(role)\n role\n else\n raise UndefinedRole, \"#{role.inspect} not defined\"\n end\n end",
"def validate(role, _environments, cookbooks, roles) # rubocop:disable CyclomaticComplexity\n # validate the role passed in ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clear all tokens that have expired | def clear_expired_tokens
access_tokens.where("token_expire < ?", Time.now).destroy_all
end | [
"def expire_all_tokens!\n tokens.map(&:expire!)\n end",
"def revoke_all_tokens\n token_expiration = DateTime.now + JWTAuth::JWTAuthenticator.refresh_exp\n active_tokens = self.active_tokens\n\n return if active_tokens.blank?\n\n ActiveToken.transaction do\n active_tokens.each { |token| token.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create new FantasyStat load_tournament_list load_tournament_game_data create_leagues load_player_data | def load_fantasy_stats
load_tournament_list
load_tournament_game_data
create_leagues
load_player_data
end | [
"def create_teams\n # Get relevant players data and balance for team creation.\n players_pool = users.pluck(:user_id, :rating)\n balanced_teams_hash = balance_players(players_pool)\n\n # Create real teams for match with the balanced team hash.\n Team.create_for_match(balanced_teams_hash, id)\n sav... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A pull request has been closed | def process_closed_pull_request(pull_request)
pr_name = pull_request['base']['repo']['full_name'].to_s
pr_number = pull_request['number'].to_s
pr_key = pr_name + ":" + pr_number
current_commit_hash = pull_request['head']['sha'].to_s
# Delete the PR from the redis store
@redis.del(pr_key)
re... | [
"def close\n return unless request_exists?\n @github.close_issue source_repo, @current_request.number\n unless request_exists?('open', @current_request.number)\n puts 'Successfully closed request.'\n end\n end",
"def process_closed_pull_request(pull_request)\n pr_name = pull_request['base']['... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A PR review has been reported | def process_created_review(review_payload)
pr_name = review_payload['repository']['full_name'].to_s
pr_number = review_payload['pull_request']['number'].to_s
comment_user = review_payload['review']['user']['id'].to_s
approvals = evaluate_review_state(review_payload['review']['state'])
current_commit... | [
"def submit_pull_request_review(repo, number, review, event, options = T.unsafe(nil)); end",
"def atest_ID_25863_reposted_review()\n # Need clarification\n end",
"def pull_request_review?\n github_event == 'pull_request_review'\n end",
"def print_pr_resume(prs)\n if prs.any?\n puts \"[PRS... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates and submits a status for the commodus review | def submit_status(pr_name, pr_number, current_commit_hash, comment_user, approvals)
pr_key = pr_name + ":" + pr_number
# Grab the stored payload
stored_payload_value = @redis.hget(pr_key, current_commit_hash)
# Ensure that a key actually exists
if !stored_payload_value.nil?
stored_payload = ... | [
"def process_created_review(review_payload)\n pr_name = review_payload['repository']['full_name'].to_s\n pr_number = review_payload['pull_request']['number'].to_s\n comment_user = review_payload['review']['user']['id'].to_s\n approvals = evaluate_review_state(review_payload['review']['state'])\n curr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates the PR review state | def evaluate_review_state(state)
net_pluses = 0
if state == "approved"
net_pluses = 1
elsif state == "changes_requested"
net_pluses = -1
end
return net_pluses
end | [
"def unreviewed_pr_ck(comm_st)\n puts comm_st.statuses[0]['state']\n @unreviewed_pr = false\n rescue NoMethodError\n @unreviewed_pr = true\n # in this situation we have no reviews-tests set at all.\n end",
"def releasable?; review_state? :ready; end",
"def reviewed?\n @status == :reviewed\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the view_model class for the given model instance. Note: ViewModels are usually of class ViewModels::. (As returned by default_view_model_class_for) Override specific_mapping if you'd like to install your own. OR: Override default_view_model_class_for(model) if you'd like to change the default. | def view_model_class_for model
specific_view_model_class_for(model) || default_view_model_class_for(model)
end | [
"def model_class\n unless instance_variable_defined?(:@model_class)\n # try to auto-detect the model class based on our name\n self.model_class_name =\n ViewModel::Registry.infer_model_class_name(self.view_name)\n end\n\n @model_class\n end",
"def model_class\n @mod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets self.hotness according to the idea's age, upvotes/downvotes, and whether or not the idea has 'preferred' status. Hotness is used to determine where in the list the idea will appear. We've used the same algorithm as reddit does for sorting its contents. At present, having posting an idea later gives more hotness to... | def set_hotness!
preferred_weight = self.preferred ? PREFERRED_MAGNITUDE : 0
vote_weight = vote_tally + preferred_weight
newness = self.created_at.to_f || Time.now.to_f
sign = vote_weight < 0 ? -1 : 1
upvote_magnitude = [ vote_weight.abs, 1.1 ].max... | [
"def calc_hot_score\n points = upvotes - downvotes\n time_ago_in_hours = ((Time.now - created_at) / 3600).round\n score = hot_score(points, time_ago_in_hours)\n\n update_attributes(points: points, hot_score: score)\n end",
"def hot_count=(value)\n @hot_count = value\n end",
"def hot_count\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sets the idea's vote_tally field to be equal to the number upvotes minus the number of downvotes it has | def set_vote_tally!
self.vote_tally = self.get_upvotes.size - self.get_downvotes.size
end | [
"def calculate_tallied_votes\n self.tallied_votes = upvotes - downvotes\n self.save\n end",
"def get_vote_tally\n return self.get_upvotes.size - self.get_downvotes.size\n end",
"def votes\n self.up_votes - self.down_votes\n end",
"def unvote_for(idea)\n voted_ideas.delete(idea)\n t = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a downvote to the idea and then saves it, causing the idea's hotness to update | def downvote_and_update(user)
self.disliked_by user
self.save
end | [
"def downvote\n if self.rating == nil\n self.rating = 0\n end\n self.rating-=1\n self.save\n self.rating\n end",
"def upVote(rushee)\n verifyApproval(rushee)\n self.approvals.find_by(rushee: rushee).update_attribute(\"vote\", true) \n end",
"def vote up\n end",
"def vote_for(ide... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the tally of votes for the idea (upvotes downvotes) | def get_vote_tally
return self.get_upvotes.size - self.get_downvotes.size
end | [
"def set_vote_tally!\n self.vote_tally = self.get_upvotes.size - self.get_downvotes.size\n end",
"def tally_votes\n tallies = {}\n if vote_tallies.present?\n vote_tallies.each do |vote_tally|\n tallies[vote_tally.candidacy] = vote_tally.vote_count\n end\n else\n votes.each do |v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
converts idea.youtube_link into the form needed to make the video embeddable | def embed_link
return nil if self.youtube_link.nil?
id_regex = /(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
youtube_id = self.youtube_link.match(id_regex)
return nil if youtube_id.nil?
return YOUTUBE_EMBED_PREFIX + youtube_id[1] + "?rel=0"
end | [
"def convert_to_youtube_embed_link\n self.video_url.gsub!(/(youtube.com\\/)(.)*v=([\\w\\-_]+)(.)*$/, '\\1embed/\\3')\n end",
"def convert_to_embedded_url\n youtube_id = youtube_video_id_from_link(url)\n self.url = youtube_embedded_url(youtube_id) if youtube_id\n end",
"def youtube_embed_url\n Vide... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the idea has preferred status, false otherwise | def preferred?
self.preferred
end | [
"def awarded_by_interview_committee?\n application_interview_decision_type.nil? ? false : application_interview_decision_type.yes_option\n end",
"def active?\n name = self.review_status.name\n name == 'In Review' || name == 'Pending Repost' || name == 'Review On-Hold'\n end",
"def win?\n milestone... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert an Excel serialformat date to a Ruby date object | def serial_to_date (s)
# round down and convert from string if need be
# zero day is actually "Jan 0" and indexing starts from 1, so subtract 2
s = s.to_i() - 2
# add to zero day
return JAN_1_1900 + s
end | [
"def ruby_to_excel(date, use_1904=false)\n date = date.to_datetime\n base = base_date(use_1904)\n date_float = (date - base).to_f\n date_float += 1 if adjust_for_stupid_leap_year?(date, use_1904)\n date_float\n end",
"def excel_to_ruby(val=0.0, use_1904=false)\n val = val.to_f\n\n base = bas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts the string form of a number to the bestfitting numeric type. | def str_to_number(s)
val_str = s.to_s()
if INT_REGEX.match(val_str)
return val_str.to_i()
elsif FLOAT_REGEX.match(val_str)
return val_str.to_f()
else
raise ArgumentError, "can't understand numeric format '#{s}'"
end
end | [
"def convert_string_to_number(str); end",
"def convert_string_to_number(str)\n matches = RE_NUMBER_STR.match(str)\n\n s = matches[:sign] == '-' ? -1 : 1\n i = matches[:integer].to_i\n f = matches[:fractional].to_i\n d = matches[:fractional] ? matches[:fractional].length : 0\n t = mat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns array of strings to print out for syntax. | def syntax
t = @cmd_args
t = [[t]] if !t.is_a? Array
args = []
count = 0
t.each do |expected_array|
count += 1
if count == 1
str = "Syntax: #{@cmd_name}"
else
str = " #{@cmd_name}"
end
expected_array.each do |expected|
# each expe... | [
"def syntax\n contents.zip(gaps).flatten\n end",
"def syntaxes\n Uv.syntaxes\n end",
"def syntaxes\r\n playbook.syntaxes\r\n end",
"def syntaxes\n playbook.syntaxes\n end",
"def terminalList\n [\n %w[ asterisk * ],\n %w[ at_sign @ ],\n %w[ ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
automatically creates new rooms and digs them out in a direction. if a room is supplied we use it unconditionally. | def buildwalk(dir, supplied=nil)
if supplied
if supplied.is_a?(Room)
found = {:room=>supplied}
else
view "Linking failed. Target was not a room." + ENDL
return nil
end
else
m = Automap.new(in_room, [(-1..1),(-1..1)], {:full_traverse=>true})
found = m.find(... | [
"def create_rooms\n $room1 = Room.new(\"Room 1\", \"This is room 1\", {}, {fork: $fork, bag: $bag, balloon: $balloon, key: $key, chest: $chest})\n $room2 = Room.new(\"Room 2\", \"This is room 2\", {}, {})\n $room3 = Room.new(\"Room 3\", \"This is room 3\", {}, {})\n $room4 = Room.new(\"Room 4\", \"This is room ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
continuously check for new messages | def start()
unread = notifications()['UnreadMessage'].to_i
@thread = Thread.new do
loop do
unread_messages = notifications()['UnreadMessage'].to_i
if unread_messages > unread then
@callback.call if @callback
unread = unread_messages
end
sleep ... | [
"def check_and_update_msgs\n\t\ttodos = todo_msgs\n\t\tdel_msgs_by_time(find_latest_time(todos))\n\t\tadd_next_ocurrences(todos) # add another if recurring\n\t\tpretify_msgs(todos)\n\tend",
"def sleep_until_change\n @imap.idle do |r|\n begin\n Catfriend.whisper \"#{id}: #{r}\"\n next if r.in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a byte array representing this command, appropriate for sending to the sign's serial port | def to_bytes
# set defaults
self.sender ||= :pc
self.receiver ||= 1
bytes = []
bytes.concat [0x00] * 5 # start of command
bytes.concat [0x01] # <SOH>
bytes.concat self.sender.to_bytes # Sender... | [
"def command_payload_bytes\n raise MovingsignApi::NotImplementedError, \"Needs to be implemented in subclass.\"\n end",
"def build_payload(command)\n [PAYLOAD_START, command, 0, 0, 0, 0, 0, 0].pack('CCCCCCCC')\n end",
"def to_s\n return command\n end",
"def to_binary\n return '' u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns command specific byte array payload | def command_payload_bytes
raise MovingsignApi::NotImplementedError, "Needs to be implemented in subclass."
end | [
"def build_payload(command)\n [PAYLOAD_START, command, 0, 0, 0, 0, 0, 0].pack('CCCCCCCC')\n end",
"def to_bytes\n # set defaults\n self.sender ||= :pc\n self.receiver ||= 1\n\n bytes = []\n\n bytes.concat [0x00] * 5 # start of command\n bytes.concat ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set definition and create events | def definition_attributes=(definition_attributes)
self.definition = ActivityDefinition::BaseActivityDefinition.from_attributes definition_attributes
self.create_events_from_definition
end | [
"def create_events\n @events = []\n @lines.each do |l|\n e = Event.new l\n @events << e\n end\n end",
"def on_def(name, params, bodystmt); end",
"def create_default_events\n EventType::DEFAULT_EVENTS.each_value do |e|\n event = self.event_types.find_by_name(e[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /users/:user_id/uploads Create an upload for the given user. Uploading the image happens behind the scenes in the Upload model. | def create
@upload = @user.uploads.build(upload_params)
authorize @upload
respond_to do |format|
if @upload.save
format.json { render json: @upload }
format.html { redirect_to user_uploads_path(@user) }
else
format.json { render json: @upload.errors }
format.json... | [
"def create\n\t\trequire_user\n\t\t@uploads = Upload.new(params[:upload])\n\t\tcurrent_user.uploads << @uploads\n\t\t@uploads.user_id = current_user.id\n\n\t\tif @uploads.save && current_user.save\n\t\t\tredirect_to user_uploads_path, :notice => \"Upload saved!\"\n\t\telse\n\t\t\tredirect_to user_uploads_path, :not... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /users/:user_id/uploads/:id Deletes the given user upload. | def destroy
@upload = @user.uploads.find(params[:id])
authorize @upload
@upload.destroy
redirect_to user_uploads_path(@user)
end | [
"def destroy\n @upload = current_user.uploads.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(uploads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @userfile = Userfile.find(params[:id])\n @userfile.destroy\n\n respond_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create grants array define a method to search for duplicates search for grant number in grants array | def grant_search(grants, grant_number)
# set up location = nil
return if grant_number == nil
duplicate_index = nil
# search grant hash in the array and if find the duplicate, then set up index # location
grants.each_with_index do |grant, i|
if grant[:grant_number] == grant_number
duplicate_index = ... | [
"def grants_sub_list\n users = GrantsData.has_grants.concat User.marked_complete_grants\n users = users.uniq\n subs = Array.new()\n users.each do |u|\n if User.is_charity(u)\n subs.push(u)\n end\n end\n session[:grants_sub] = subs.count()\n subs\nend",
"def assigned_investors(sale_rep)\n assign... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /helps/1 GET /helps/1.json | def show
@help = Help.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @help }
end
end | [
"def show\n @helptext = Helptext.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @helptext }\n end\n end",
"def show\n @shelter = Shelter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /helps/new GET /helps/new.json | def new
@help = Help.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @help }
end
end | [
"def new\n @shelter = Shelter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shelter }\n end\n end",
"def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a cache method, and expiry predicate fn and a on_miss fn and returns the value of the cache_method | def read(cache_method, expired_fn: self.class.default_expired_fn, on_miss: F.identity)
if cache.send(cache_method) && !expired_fn.(cache, cache_method) #not_expired?(cache_method)
log_cache_hit
get(cache_method)
else
log_cache_failure
write(cache_method, on_miss.(get(cache_method)))
... | [
"def caching_method(method) \n returning send(\"_queued_method_#{method}\") do |results|\n Rails.cache.write queued_method_key(method), results\n Rails.cache.delete queued_method_queued_key(method)\n end\n end",
"def cached_call func, ttl, *params\n \n #\n cache_key ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up the generator class. Require its class file, find the class in ObjectSpace, tag it with this spec, and return. | def klass
unless @klass
require class_file
@klass = lookup_class
@klass.spec = self
end
@klass
end | [
"def lookup_class\r\n ObjectSpace.each_object(Class) do |obj|\r\n return obj if obj.ancestors.include?(Rails::Generator::Base) and\r\n obj.name.split('::').last == class_name\r\n end\r\n raise NameError, \"Missing #{class_name} class in #{class_file}\"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search for the first Class descending from Rails::Generator::Base whose name matches the requested class name. | def lookup_class
ObjectSpace.each_object(Class) do |obj|
return obj if obj.ancestors.include?(Rails::Generator::Base) and
obj.name.split('::').last == class_name
end
raise NameError, "Missing #{class_name} class in #{class_file}"
end | [
"def lookup_class\n ObjectSpace.each_object(Class) do |obj|\n return obj if obj.ancestors.include?(Rails::Generator::Base) and\n obj.name.split('::').last == class_name\n end\n raise NameError, \"Missing #{class_name} class in #{class_file}\"\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the watch for the object, or a new watch if none found. The new watch should be active if the object is new, correspoding to the watch being on by default when the user creates a new CI or Outage. | def watched_by_or_new(user)
watched_by(user) || watches.build(user: user, active: !persisted?)
end | [
"def watching\n @watching ||= ApiFactory.new 'Repos::Watching'\n end",
"def watching\n @watching ||= ApiFactory.new 'Activity::Watching'\n end",
"def watcher(name)\n watchers.find { |watcher| watcher.name == name }\n end",
"def watching?(object)\n interest_in(object) == :watching\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /active_stats/new GET /active_stats/new.json | def new
@active_stat = ActiveStat.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @active_stat }
end
end | [
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stat }\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /active_stats POST /active_stats.json | def create
@active_stat = ActiveStat.new(params[:active_stat])
respond_to do |format|
if @active_stat.save
format.html { redirect_to @active_stat, :notice => 'Active stat was successfully created.' }
format.json { render :json => @active_stat, :status => :created, :location => @active_sta... | [
"def stats\n get 'stats', format: 'json'\n end",
"def send_stats\n first_time = @prev_stat.empty?\n stats = build_request\n @stat.keys.each { |k| stats[k] = @stat[k] - @prev_stat[k] }\n @prev_stat.replace(@stat)\n # These should be reported as absolute values\n [:mt, :ma, :mc].ea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /active_stats/1 PUT /active_stats/1.json | def update
@active_stat = ActiveStat.find(params[:id])
respond_to do |format|
if @active_stat.update_attributes(params[:active_stat])
format.html { redirect_to @active_stat, :notice => 'Active stat was successfully updated.' }
format.json { head :ok }
else
format.html { rend... | [
"def update_statistics\n HTTP.post(\"/video/#{@id}/stats\")\n true\n end",
"def update\n @stat = Stat.find(params[:id])\n\n if @stat.update(stat_params)\n head :no_content\n else\n render json: @stat.errors, status: :unprocessable_entity\n end\n end",
"def update\n logge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /active_stats/1 DELETE /active_stats/1.json | def destroy
@active_stat = ActiveStat.find(params[:id])
@active_stat.destroy
respond_to do |format|
format.html { redirect_to active_stats_url }
format.json { head :ok }
end
end | [
"def destroy\n @backend_stat = Backend::Stat.find(params[:id])\n @backend_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to backend_stats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /active_stats/team/1 GET /active_stats/team/1.json | def team
@team = Team.where('team_id = ?', params[:id])
@active_stats = ActiveStat.where('team_id = ?', params[:id])
respond_to do |format|
format.html
format.json
end
end | [
"def get_team_stats()\n query_params = { }\n headers = {}\n body = nil\n\n path = \"/team/stats\"\n\n @client.request(\n method: :get,\n path: path,\n query: query_params,\n headers: headers,\n body: body)\n end",
"def get_team_stats(team); end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The schema defines some tags that may not be empty. This method removes any such empty tags from the tree. | def delete_invalid_empty_tags!(node)
node.children.reject! do |child|
if child.is_a?(TagNode)
if child.children.empty? and !@schema.tag_may_be_empty?(child.tag_name)
true
else
delete_invalid_empty_tags!(child)
false
end
end
end
node
end | [
"def delete_empty_tags\n sorted_tags = Tag.all.sort_by { |tag| tag.articles.count }\n return if sorted_tags.first.articles.count > 0\n\n sorted_tags.each { |tag| tag.delete if tag.articles.count == 0 }\n end",
"def destroy_empty\n if content.empty? and children.empty?()\n _unhook!\n destroy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether Markdown implements the PHP Markdown extra syntax. Note: it is not guaranteed that if this is false, then no special features will be used. | def markdown_extra?
true
end | [
"def markdown?\n @use_markdown && markdown_processor\n end",
"def markdown?\n defined?(RDiscount) or defined?(BlueCloth)\n end",
"def markdown_allowed?\n @markdown_allowed\n end",
"def markdown?\n @source == :markdown || @source == :md\n end",
"def supported?(syntax)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
a Rational Number (two ints reping the num and denom of a rat num) outputs: Array (an arr of denoms that are part of an Egyptian Fraction rep of the num) reqs: take a Rational Number rtn an arr reping an Egyptian Fraction rep of the num struct: Array (to hold denoms) algo: init the output arr to [] init a sum at 0 init... | def egyptian(rat_num)
arr = []
sum = 0
temp_sum = sum
denom = 1
while sum < rat_num && denom < 1_000_000
temp_sum += Rational(1, denom)
if temp_sum > rat_num # overshot
temp_sum = sum # reset
else
sum = temp_sum
arr << denom
end
# p "denom = #{denom}, sum = #{sum}, arr = ... | [
"def egyptian(rational_num)\n\ttotal = 0\n\tresult = []\n\tdenominator = 1 \n\tloop do \n\t\tif total + Rational(1, denominator) <= rational_num \n\t\t\ttotal += Rational(1, denominator)\n\t\t\tresult << denominator \n\t\tend \n\t\treturn result if total == rational_num \n\t\tdenominator += 1\n\tend\nend",
"def u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 230, 57960] inputs: Array (an arr of denoms that are part of an Egyptian Fraction rep of the num) outputs: a Rational Number (two ints reping the num and denom of a rat num) reqs: take an arr reping an Egyptian Fraction rep of the num rtn a Rational Number struct: num (to hold sum ... | def unegyptian(arr)
sum = 0
arr.each { |denom| sum += Rational(1, denom) }
sum
end | [
"def egyptian(rat_num)\n arr = []\n sum = 0\n temp_sum = sum\n denom = 1\n while sum < rat_num && denom < 1_000_000\n temp_sum += Rational(1, denom)\n if temp_sum > rat_num # overshot\n temp_sum = sum # reset\n else\n sum = temp_sum\n arr << denom\n end\n # p \"denom = #{denom}, s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reload the balancer data from the API | def balancer_reload(balancer)
if balancer.persisted?
begin
load_balancer_data(balancer)
rescue Miasma::Error::ApiError::RequestError => e
if e.response_error_msg.include?("LoadBalancerNotFound")
balancer.state = :terminated
ba... | [
"def balancer_reload(balancer)\n if(balancer.persisted?)\n result = request(\n :path => \"/loadbalancers/#{balancer.id}\",\n :method => :get,\n :expects => 200\n )\n lb = result.get(:body, 'loadBalancer')\n balancer.load_dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch balancers or update provided balancer data | def load_balancer_data(balancer = nil)
params = Smash.new("Action" => "DescribeLoadBalancers")
if balancer
params["LoadBalancerNames.member.1"] = balancer.id || balancer.name
end
result = all_result_pages(nil, :body,
"DescribeLoadBa... | [
"def balancer_reload(balancer)\n if(balancer.persisted?)\n result = request(\n :path => \"/loadbalancers/#{balancer.id}\",\n :method => :get,\n :expects => 200\n )\n lb = result.get(:body, 'loadBalancer')\n balancer.load_dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all load balancers | def balancer_all(options = {})
load_balancer_data
end | [
"def balancer_all(options={})\n result = request(\n :path => '/loadbalancers',\n :method => :get,\n :expects => 200\n )\n result.fetch(:body, 'loadBalancers', []).map do |lb|\n Balancer.new(\n self,\n :id => lb[:id],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Round 3 Write a function called toonify that takes two parameters, accent and sentence. If accent is the string "daffy", return a modified version of sentence with all "s" replaced with "th". If the accent is "elmer", replace all "r" with "w". Feel free to add your own accents as well! If the accent is not recognized, ... | def toonify(accent, sentence)
if accent == 'daffy'
return sentence.gsub('s', 'th')
elsif accent == 'elmer'
return sentence.gsub('r', 'w')
else
return sentence
end
end | [
"def toonify(accent, sentence)\n if accent == \"daffy\"\n return sentence.gsub('s', 'th')\n elsif accent == \"elmer\"\n return sentence.gsub('r', 'w')\n else\n return sentence\n end\nend",
"def toonify(accent, sentence)\n\tif accent === \"daffy\"\n\t\tp sentence.gsub(\"s\", \"th\")\n\t\t#gsub(pattern... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /generic_monographs POST /generic_monographs.json | def create
@generic_monograph = DisGenericMonograph.new(generic_monograph_params)
if @generic_monograph.save
flash[:notice] = "Task was successfully created."
respond_with(@generic_monograph)
else
flash[:notice] = "Task was not created."
end
end | [
"def create\n @generic_monograph = GenericMonograph.new(generic_monograph_params)\n\n respond_to do |format|\n if @generic_monograph.save\n format.html { redirect_to @generic_monograph, notice: 'Generic monograph was successfully created.' }\n format.json { render :show, status: :created, l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /generic_monographs/1 PATCH/PUT /generic_monographs/1.json | def update
respond_to do |format|
if @generic_monograph.update(generic_monograph_params)
format.html { redirect_to @generic_monograph, notice: 'Combination dose was successfully updated.' }
format.json { render :show, status: :ok, location: @generic_monograph }
else
format.html {... | [
"def update\n respond_to do |format|\n if @generic_monograph.update(generic_monograph_params)\n format.html { redirect_to @generic_monograph, notice: 'Generic monograph was successfully updated.' }\n format.json { render :show, status: :ok, location: @generic_monograph }\n else\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /generic_monographs/1 DELETE /generic_monographs/1.json | def destroy
@generic_monograph.destroy
respond_to do |format|
format.html { redirect_to generic_monographs_url, notice: 'Combination dose was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @generic_monograph.destroy\n respond_to do |format|\n format.html { redirect_to generic_monographs_url, notice: 'Generic monograph was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_generic_monograph.destroy\n respond_to do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches through the instance variables of the class and creates a class method on the MetricFu module to read the value of the instance variable from the Configuration class. | def add_class_methods_to_metric_fu
instance_variables.each do |name|
method_name = name[1..-1].to_sym
method = <<-EOF
def self.#{method_name}
configuration.send(:#{method_name})
end
EOF
MetricFu.module_eval(method)
end
... | [
"def class_variables() end",
"def _set_instance_vars_from_config(config)\n config.config_options.each do |config_option|\n # Only internalize relevant config options µ\n case config_option\n when :plan,:project,:server,:devkey\n config_value = config.send(config_option)\n @l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches through the instance variables of the class and creates an attribute accessor on this instance of the Configuration class for each instance variable. | def add_attr_accessors_to_self
instance_variables.each do |name|
method_name = name[1..-1].to_sym
MetricFu::Configuration.send(:attr_accessor, method_name)
end
end | [
"def populating_attr_accessor(*symbols)\n attr_writer *symbols\n populating_attr_reader *symbols\n end",
"def metadata_accessors\n metamodel_klass.attributes.each do |attribute|\n next if respond_to?(attribute.name)\n\n define_singleton_method(attribute.name) do\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add the :stats task to the AVAILABLE_METRICS constant if we're running within rails. | def set_metrics
if rails?
@metrics = MetricFu::AVAILABLE_METRICS + [:stats, :rails_best_practices]
else
@metrics = MetricFu::AVAILABLE_METRICS
end
end | [
"def tasks_stats\n output_examples_total unless options[:report_only_tasks]\n output_task_totals\n end",
"def metrics\n with_stats_lock do\n @stats_hash.keys.map { |spec| spec.to_s }\n end\n end",
"def register_metrics!\n return if @registered\n @re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this method will count all of the a specific trip instance has had. I'm guessing I can use a previous method written. Trips method? will give me an integer back. | def trip_count
trips.count
end | [
"def trip_count\n trips.count\n end",
"def trip_count\n trips.length\n end",
"def trip_count\n trips = Trip.all.select {|trip_instance| trip_instance.listing == self}.length\n end",
"def count \n trips.length\n end",
"def get_trip_num\n user= User.find(self.id)\n num =(us... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specifies the answers to be referred to by the given labels. These labels must match the labels given to Machinesend. def process_answers ary1 = [] ary2 = [] answers.each do |a| ... end label group1: ary1 label group2: ary2 end Use this method inside a process block or inside a Machineprocess_answers method definition. | def label (hash)
@labeled_answers.merge! hash
end | [
"def answers_labels\n @answer_group && EvaluationAnswerGroup.find(@answer_group).labels\n end",
"def labels\n @answers.collect{|x| x.is_a?(Array) ? x.first : x}\n end",
"def labels(values)\n values.reduce({}) do |labels,value|\n labels[value] = (label_proc || DEFAULT_LABEL_PROC).... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a hash of the answers currently at this machine, keyed by language | def answers_keyed_by_language
hash = Hash.new {|h,k| h[k] = [] }
answers.each {|answer| hash[answer.language] << answer }
hash
end | [
"def answers\n @answers ||= {}\n end",
"def language_hash\n HashWithIndifferentAccess.new(PrismicRails.config.languages)\n end",
"def keyword_hash(lang=@lang)\n LANGUAGES[lang]\n end",
"def user_languages_hash\n result = Hash.new\n\n I18n.available_locales.each do |locale... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a new answer with the given blueprint and parents. def process_answers answers.each do |a| ary1 << make_answer(a.blueprint, a) ary2 << make_answer(a.blueprint.reverse, a) end label group1: ary1 label group2: ary2 end Use this method inside a process block or inside a Machineprocess_answers method definition. | def make_answer (blueprint, *parents)
parent_ids = parents.collect {|answer| answer.id }
Answer.new(nil, blueprint, @location, @location, parent_ids, Factory.cycle, nil)
end | [
"def ensure_answers\n self.answers ||= []\n (questioning.level_count || 1).times.each do |i|\n rank = (questioning.level_count || 1) > 1 ? i + 1 : nil\n answers[i] ||= Answer.new(questioning: questioning, rank: rank)\n end\n end",
"def build_prerequisite_answers\n existing_answers = prerequ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the number of answers currently at this machine without forcing the answers to load. def process_answers if answer_count > 500 ... end label group1: ary1 end Use this method inside a process block or inside a Machineprocess_answers method definition. | def answer_count
return @answers.length if @answers
Factory.count_answers_at_machine(@location)
end | [
"def answers_count\n self.answer_sets.size\n end",
"def answer_count\n if is_standard?\n respond_to?(:copy_answer_count_col) ? copy_answer_count_col || 0 : copies.inject?(0){|sum, c| sum += c.answer_count}\n else\n respond_to?(:answer_count_col) ? answer_count_col || 0 : questionings.inject(0)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pricetypes/1 PATCH/PUT /pricetypes/1.json | def update
respond_to do |format|
if @pricetype.update(pricetype_params)
format.html { redirect_to @pricetype, notice: 'Pricetype was successfully updated.' }
format.json { render :show, status: :ok, location: @pricetype }
else
format.html { render :edit }
format.json { r... | [
"def update\n respond_to do |format|\n if @patch_type.update(patch_type_params)\n format.html { redirect_to admin_patch_types_path, notice: 'Patch type was successfully updated.' }\n format.json { render :index, status: :ok, location: @patch_type }\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pricetypes/1 DELETE /pricetypes/1.json | def destroy
@pricetype.destroy
respond_to do |format|
format.html { redirect_to pricetypes_url, notice: 'Pricetype was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @perf_type.destroy\n respond_to do |format|\n format.html { redirect_to perf_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wraps the deep_cloneable gem deep_clone method to allow using the predefined associations and options from our Cloneable.acts_as_cloneable macro. | def deep_clone!(options = {})
processed_options = Para::Cloneable::IncludeTreeBuilder.new(self, cloneable_options).build
options = options.reverse_merge(processed_options)
callback = build_clone_callback(options.delete(:prepare))
deep_clone(options) do |original, clone|
Para::Clon... | [
"def deep_clone!(options = {})\n dictionary = options[:dictionary] ||= {}\n\n processed_options = Para::Cloneable::IncludeTreeBuilder.new(self).build\n options = options.reverse_merge(processed_options)\n callback = build_clone_callback(options.delete(:prepare))\n\n deep_clone(options) do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We ensure that the passed callback is actually callable on the object we're cloning. This is needed for associations because deep_cloneable calls the callback for every associated object. | def build_clone_callback(callback)
case callback
when Proc
callback
when Symbol
->(original, clone) {
original.send(callback, clone) if original.respond_to?(callback, true)
}
end
end | [
"def cloneable_receiver\n @cloneable_receiver ||= begin\n self.class.cloneable_options[:to].new\n rescue\n self.class.new\n end\n end",
"def safe_clone\r\n self.clone\r\n end",
"def add_callback(type, options, &block)\n options[:bind_to_object] = true\n supe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns webdriver capabilities for chrome browser | def chrome_capabilities
Selenium::WebDriver::Remote::Capabilities.chrome(
logging_prefs: {browser: 'ALL'},
'chromeOptions' => {
'args' => %w[--ignore-certificate-errors],
'w3c' => false
},
'acceptSslCerts' => true,
'acceptInsecureCerts' => true
)
end | [
"def capabilities\n execute(:get, 'capabilities')\n end",
"def browserstack\n # Documentation and the code for this class can be found here\n # http://www.rubydoc.info/gems/selenium-webdriver/0.0.28/Selenium/WebDriver/Remote/Capabilities\n # https://github.com/SeleniumHQ/selenium/blob/m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Registers :chrome webdriver options in Capybara framework | def register_chrome_driver
Capybara.register_driver :chrome do |app|
if ENV['SELENIUM_GRID'] == 'false'
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: chrome_capabilities)
else
Capy... | [
"def use_chrome_to_test\n \t\tclient = Selenium::WebDriver::Remote::Http::Default.new\n \tclient.timeout = 120\n\t Capybara.register_driver :chrome do |app|\n\t Capybara::Selenium::Driver.new(\n\t app,\n\t :browser => :chrome,\n\t :http_client => client,\n\t :swit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns webdriver capabilities for firefox browser | def firefox_capabilities
Selenium::WebDriver::Remote::Capabilities.firefox(
logging_prefs: {browser: 'ALL'},
'acceptSslCerts' => true,
'acceptInsecureCerts' => true,
'native_events' => true
)
end | [
"def firefox\n options = Selenium::WebDriver::Firefox::Options.new(profile: firefox_profile)\n options.headless! if config.headless\n\n options\n end",
"def firefox\r\n @web_browser.firefox\r\n end",
"def firefox\n @web_browser.firefox\n end",
"def capabilities\n execu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Registers :firefox webdriver options in Capybara framework | def register_firefox_driver
Capybara.register_driver :firefox do |app|
if ENV['SELENIUM_GRID'] == 'false'
options = Selenium::WebDriver::Firefox::Options.new
Capybara::Selenium::Driver.new(app, browser: :firefox,
options: options,
... | [
"def firefox\n # For future reference configuring Firefox via Selenium appears to be done\n # via the options argument, and a Selenium::WebDriver::Firefox::Options\n # object.\n # https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings\n # https://www.rubydoc.info/gems/selenium-webdriver/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return absolute uri for path | def absolute_uri_path(path)
"#{root_uri}#{path}"
end | [
"def uri(path)\n return nil unless path\n root = asset_roots.detect { |root| Processor.parent_path?(root, path) }\n '/' + path.relative_path_from(root).to_s\n end",
"def absolute_uri(uri)\n uri.relative? ? URI.join(@uri, uri) : uri\n end",
"def absolute_path(path)\n path... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return host with optional port Only returns port if protocols default port diffes from actual port. | def host_with_port
uhost, uport = self.host, self.port
if port != protocol.default_port
"#{uhost}:#{uport}"
else
uhost
end
end | [
"def optional_port\n standard_port? ? nil : port\n end",
"def port_string\n (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : \":#{port}\"\n end",
"def port_string\n port == standard_port ? '' : \":#{port}\"\n end",
"def port\n if raw_host_wit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if a format is known. Returns the associated content type. | def known_format?(f)
FORMAT_TO_CONTENT_TYPE[f]
end | [
"def format\n @format ||= Mime.detect_format(content_type, @config)\n end",
"def verify_requested_format!\n mimes = collect_mimes_from_class_level\n collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)\n\n unless collector.negotiate_format(request)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N. Examples [2, 4, 0, 100, 4, 11, 2602, 36] Should return: 11 (the only odd number) ... | def find_outlier(array)
odd_array=[]
even_array=[]
array.each do |i|
odd_array << i if i % 2 == 0
even_array << i if i % 2 != 0
end
odd_array.size > even_array.size ? even_array[0] : odd_array[0]
end | [
"def find_outlier(arr)\n even = arr.select { |num| num.even? }\n odd = arr.select { |num| num.odd? }\n\n even.count > odd.count ? odd[0] : even[0]\nend",
"def find_outlier(num_arr)\n new_arr = num_arr.select { |num| num.odd? } # [1, 3]\n\n return new_arr.first if new_arr.size == 1\n (num_arr - new_arr).fir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Checks to see if the LinkedList is empty. Examples | def empty?
@head.next == nil
end | [
"def is_empty()\n @head == nil\n end",
"def is_empty?\n if self.head == nil\n return true\n else\n return false\n end\n end",
"def empty?\n head.nil? && tail.nil?\n end",
"def empty?\n list.empty?\n end",
"def empty?\n @head.next == @tail ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Finds and removes the first occurrence of a Node with the desired value. value the Ruby object value to find and remove from the LinkedList Examples | def remove(value)
element = self.head
previous_element = @head
while element.value != value
if element.next.nil?
return nil
else
previous_element = element
element = element.next
end
end
previous_element.next = element.next
element
end | [
"def delete_value value\r\n #find the pointer to the wanted node using LIST-SEARCH(value)\r\n #then delete that node with LIST-DELETE-BY-NODE(node)\r\n delete_node(self.search(value))\r\n end",
"def test_it_can_remove_a_node_by_value\n list = LinkedList.new(\"start\")\n list.append(\"chilula\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A helper method to validate the state | def validate_state(state = {}); end | [
"def validate!(state)\n # The state is a Hash-like object (HLO) with a value\n # at key MACHINE_KEY\n unless state[MACHINE_KEY]\n raise InvalidMachine, \"no state machine found: #{state}\"\n end\n\n # The machine has a current state \n unless state[MACHINE_KEY][:current]\n raise InvalidM... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sees in the datacenter exists or not | def datacenter_exists?(name)
filter = Com::Vmware::Vcenter::Datacenter::FilterSpec.new(names: Set.new([name]))
dc_obj = Com::Vmware::Vcenter::Datacenter.new(vapi_config)
dc = dc_obj.list(filter)
raise format("Unable to find data center: %s", name) if dc.empty?
end | [
"def datacenter_exists?(name)\n filter = Com::Vmware::Vcenter::Datacenter::FilterSpec.new(names: Set.new([name]))\n dc_obj = Com::Vmware::Vcenter::Datacenter.new(vapi_config)\n dc = dc_obj.list(filter)\n\n raise format('Unable to find data center: %s', name) if dc.empty?\n ... | {
"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.