query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
The entry's french name. | def french_name
self[4]
end | [
"def name(locale = nil)\n locale = GetText.locale.to_s if locale.nil?\n ret = self.names[locale]\n if ret.blank?\n ret = self.id.nil? ? '' : self.names['en']\n end\n ret\n end",
"def spanish_name\n self[5]\n end",
"def localized_name\n send(\"name_\" + I18n.locale.to_s.downcase)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method should retrieve accounts which needs to be refreshed for specified collector | def get_accounts(collector, limit)
service = Service.where(name: collector).first
accounts = service.
user_proxies.
limit(limit).
order([:refresh_date, 'ASC'])
end | [
"def refresh\n request(:post, \"/aggregation/v1/customers/#{customer_id}/accounts\")\n end",
"def collect(collectors)\n logger.info(\"[ \" + Time.now.to_s + \" ]\" + \" Collect task invoked\")\n collectors.each do |collector_name|\n begin\n collector = @collectors[collector_name]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches resources for specified collectors | def collect(collectors)
logger.info("[ " + Time.now.to_s + " ]" + " Collect task invoked")
collectors.each do |collector_name|
begin
collector = @collectors[collector_name]
accounts = get_accounts collector_name, collector.settings[:request_limit]
success_accounts = collector.colle... | [
"def list_collectors request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_collectors_request request_pb\n query_string_params = if query_string_params.any?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new media URL record in the database | def create_media_url(assignment_id, url, user_id, submitted_at)
# Generate a thumbnail for the URL
thumbnail_url = nil
site_and_slug = nil
if url
site_and_slug = url.extract_site_and_slug
thumbnail_url = Video::Metadata.thumbnail_url(site_and_slug[:site_tag], site_and_slug[:site_id])
end... | [
"def create_new_media(data_set)\n enter_media_info_data data_set\n click_save_button\n when_exists(delete_button, Config.short_wait)\n end",
"def create\n @media_link = MediaLink.new(params[:media_link])\n\n respond_to do |format|\n if @media_link.save\n format.html { redirect_to @medi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve binary shipping labels for printing | def print_shipping_labels(shipment_info, style: 1, start_position: 1, num_labels: 4, debug: false)
request = FriendlyShipping::Request.new(
url: API_BASE + API_PATHS[:print_shipping_labels] + "?" \
"ProNumber=#{shipment_info.pro_number}&" \
"Style=#{style}&" \
"Star... | [
"def print_labels\n list = @data.display_list\n # select addresses that need labels\n label_data = list.select {|address_entry| address_entry.make_label }\n\n values = { \n 'labels' => label_data.map {|address| address.add_to_hash({}) }\n }\n report_path = print_report(values, Reports::SHIPPI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Delete Order Item Group. Delete an order item group. FIXME: This method doesn't work. Throw no action error. | def delete_order_item_group(id)
@client.raw('delete', "/ecommerce/order-items-groups/#{id}", nil, nil, @contact_v1_url)
end | [
"def delete_order_item_group(id)\n @client.raw('delete', \"/ecommerce/order-items-groups/#{id}\")\n end",
"def detach_order_item_from_order_item_group(order_item_id, group_id)\r\n @client.raw('put', \"/ecommerce/order-items/detach/#{order_item_id}/order-items-groups/#{group_id}\", nil, nil, @contact_v1_url... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a path and separator, splits the path string using the separator and pops off the last element of the split array. | def split_and_pop(path:, separator: '/')
path.split(separator)[0..-2]
end | [
"def split(path)\n array = path.kind_of?(String) ? path.split(\"/\") : path.dup\n array.shift if nil_or_empty_string?(array[0])\n array.pop if nil_or_empty_string?(array[-1])\n array\n end",
"def chop_basename(path)\n base = File.basename(path)\n if /\\A#{SEPARATOR... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if object exists and if existing object is of a given type. | def obj_exists_and_is_not_type?(obj:, type:)
obj.nil? ? false : obj != type
end | [
"def saved_object_exists?(type, id)\n begin\n get_saved_object_by_id(type, id).present?\n rescue ApiExceptions::NotFoundError\n false\n end\n end",
"def check_if_exists(obj, field, attributes = [], override_type = nil)\n # Not all types share the same v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an array of hashes, returns an array of hash values. | def map_array_of_hashes(arr_hashes)
return if arr_hashes.nil?
[].tap do |output_array|
arr_hashes.each do |hash|
output_array.push hash.values
end
end
end | [
"def burn_array_elements(array)\n hashes = []\n array.each do |element|\n hashes << element if element.is_a? Hash\n end\n return hashes\n end",
"def array_of_hashes_to_array(hash_array)\n out = []\n if !hash_array.is_a?(Array)\n out << hash_array\n else\n hash_array.length.tim... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extracts a lock token from an If headers. | def extract_lock_token(if_header)
token = if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)
token.flatten.first if token.is_a? Array
end | [
"def lock_token\n get_header 'HTTP_LOCK_TOKEN'\n end",
"def extract_header_token(env)\n BEARER_TOKEN_REGEX.match(env['HTTP_AUTHORIZATION'])&.[](1)\n end",
"def auth_token\n Hash[included_headers.map{|key,value| [key, headers[value]]}]\n end",
"def extract_bearer_token(request)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tutorials POST /tutorials.json | def create
@tutorial = current_user.tutorials.create(tutorial_params)
respond_to do |format|
if @tutorial.save
format.html { redirect_to @tutorial, notice: 'Tutorial was successfully created.' }
format.json { render :show, status: :created, location: @tutorial }
else
format.... | [
"def create\n @tutorials = Tutorial.all\n @tutorial = Tutorial.new(tutorial_params)\n\n if @tutorial.save\n render json: @tutorial\n else\n render json: @tutorial.errors.full_messages, status:400\n end\n end",
"def create\n @tutorial = @framework.tutorials.build(tutorial_par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns a list of invoices for an Account. Endpoint: GET /api/v1/invoices.json start_date Date to filter from. (Default: 1 year ago) end_date Date to filter to. (Default: now) Returns an Array | def index
@invoices = @account_invoices.where(invoices: { created_at: @start_date...@end_date })
end | [
"def invoices\n Invoice\n .includes(:packages)\n .where(invoice_date: date_range)\n .order(invoice_date: :desc)\n .limit(50)\n end",
"def invoices\n @invoices ||= funded_person\n .invoices_in_fiscal_year(fiscal_year)\n .select(&:include_in_reports?)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns a list of Invoices due Endpoint: GET /api/v1/invoices/due.json start_date Date to filter from. (Default: 1 year ago) end_date Date to filter to. (Default: 30 days from now) Returns an Array | def due
@invoices = @account_invoices.where(invoices: { due_on_date: @start_date...@end_date })
end | [
"def list_invoices_past_due(account_id)\n data, _status_code, _headers = list_invoices_past_due_with_http_info(account_id)\n return data\n end",
"def invoices\n Invoice\n .includes(:packages)\n .where(invoice_date: date_range)\n .order(invoice_date: :desc)\n .limit(50)\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns a list of Invoices expected Endpoint: GET /api/v1/invoices/expected.json start_date Date to filter from. (Default: 1 year ago) end_date Date to filter to. (Default: 30 days from now) Returns an Array | def expected
@invoices = @account_invoices.joins(:payment_profiles)
.where(payment_profiles: { expected_payment_date: @start_date...@end_date })
respond_to do |format|
format.json { render json: @invoices.to_json(include: :payment_profiles) }
end
end | [
"def index\n @invoices = @account_invoices.where(invoices: { created_at: @start_date...@end_date })\n end",
"def due\n @invoices = @account_invoices.where(invoices: { due_on_date: @start_date...@end_date })\n end",
"def invoices\n Invoice\n .includes(:packages)\n .where(invoice_date: date_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns a list of expected invoicing Endpoint: GET /api/v1/invoices/payment_predictions.json start_date Date to filter from. (Default: 1 year ago) end_date Date to filter to. (Default: 30 days from now) Returns an Array | def payment_predictions
@results = Project.payment_prediction_results(@account, params, @start_date, @end_date)
@totals = Project.payment_prediction_totals(@account, params, @start_date, @end_date)
end | [
"def expected\n @invoices = @account_invoices.joins(:payment_profiles)\n .where(payment_profiles: { expected_payment_date: @start_date...@end_date })\n respond_to do |format|\n format.json { render json: @invoices.to_json(include: :payment_profiles) }\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns allocated amount for time period Endpoint: GET /api/v1/invoices/allocated.json | def allocated
@amount = InvoiceUsage.amount_cents_allocated_for_period(Account.find_by_site_address(request.subdomain), @start_date, @end_date)
end | [
"def outstanding_invoices(issued_from, issued_to)\n records \"invoice\", \"/invoices/outstanding/#{issued_from}/#{issued_to}\"\n end",
"def billable_allocation(date=Date.today)\n resource_assignments.in_date_range(date,date).to_a.sum(&:billable_allocation)\n end",
"def pending\n @ledger_entries = @or... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /departamentos POST /departamentos.json | def create
@departamento = Departamento.new(departamento_params)
respond_to do |format|
if @departamento.save
format.html { redirect_to @departamento, notice: 'Departamento was successfully created.' }
format.json { render :show, status: :created, location: @departamento }
else
... | [
"def create\n @departamento = Departamento.new(departamento_params)\n\n if @departamento.save\n render json: @departamento, status: :created, location: @departamento\n else\n render json: @departamento.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n request = RestClie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /departamentos/1 PATCH/PUT /departamentos/1.json | def update
respond_to do |format|
if @departamento.update(departamento_params)
format.html { redirect_to @departamento, notice: 'Departamento was successfully updated.' }
format.json { render :show, status: :ok, location: @departamento }
else
format.html { render :edit }
... | [
"def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n\n redirect_to :action ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /departamentos/1 DELETE /departamentos/1.json | def destroy
@departamento.destroy
respond_to do |format|
format.html { redirect_to departamentos_url, notice: 'Departamento was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n request = RestClient.delete File.join(API_SERVER,\"rest-api/departments\",params['id'])\n redirect_to :action => :index\t\n end",
"def destroy\n @departamento.destroy\n\n head :no_content\n end",
"def destroy\n @departamento1.destroy\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Converts all instance variables in the class into json(String). Using a loop and checks for the last variable so it doesn't have a comma. =end | def toJson
json = " {\n"
self.instance_variables.each_with_index do |i,index|
json += " \"#{i[1..-1]}\": \"#{self.instance_variable_get(i)}\""
if index != self.instance_variables.size - 1
json += ",\n"
else
json += "\n"
end
end
json += " }"
end | [
"def as_json\n hash = {}\n instance_variables.each{|var| hash[var.to_s.gsub(/@/, '')] = instance_variable_get var}\n hash\n end",
"def as_json(_options = {})\n check_names\n hash = {}\n instance_variables.each do |var|\n name = var[1..]\n\n case name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This function opens the file, converts it into nokogiri. Then uses xpath to sort the xml into an array. That array becomes the instance variables for an email data type above. Then the email data type gets pushed into an array. It also has a error check, to make sure there is actually a file in the location sent... | def openFile(emaillist,emailXML)
begin
emails = Nokogiri::XML(File.open(emailXML))
emails.xpath("//record").each { |f| emaillist.push(Email.new(f.css(
'id//text()','first_name//text()','last_name//text()',
'email//text()','gender//text()','ip_address//text()',
'send_date//text()','email_body//text()','ema... | [
"def get_elements_from_filename(fileSpec)\n # Split fileSpec into path and filename\n var = Array.new()\n (var[1], var[2]) = File.split( fileSpec )\n # Determine file extension\n tempExt = File.extname(var[2])\n\n debug_out \"Testing file read location, #{fileSpec}... \"\n\n\n # Open file...\n fFileHANDLE =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new VMConnection to generate project JSON data. Returns true if json_data attributes is present. | def run
connection = VMConnection.new(report)
json_data = connection.generate_files_and_read_json
if json_data
self.json_data = json_data
save
return true
end
false
end | [
"def create\n @project = Project.find(params[:project_id])\n @project_connection = @project.build_project_connection(project_connection_params)\n\n respond_to do |format|\n if @project_connection.save\n format.html { redirect_to new_project_project_choice_path(@project), notice: 'Project connec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert from SEER to COP per the method specified in "Achieving the 30% Goal: Energy and cost savings analysis of ASHRAE Standard 90.12010 Thornton, et al 2011 | def seer_to_cop(seer)
cop = nil
# First convert from SEER to EER
eer = (-0.0182 * seer * seer) + (1.1088 * seer)
# Next convert EER to COP
cop = eer_to_cop(eer)
return cop
end | [
"def eer_to_cop(eer)\n \n cop = nil\n\n # r is the ratio of supply fan power to total equipment power at the rating condition,\n # assumed to be 0.12 for the reference buildngs per PNNL.\n r = 0.12\n \n cop = (eer/3.413 + r)/(1-r)\n \n return cop\n \nend",
"def cvss(data)\n\tav = data[\"av2\"]\n\tac = da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert from EER to COP per the method specified in "Achieving the 30% Goal: Energy and cost savings analysis of ASHRAE Standard 90.12010 Thornton, et al 2011 | def eer_to_cop(eer)
cop = nil
# r is the ratio of supply fan power to total equipment power at the rating condition,
# assumed to be 0.12 for the reference buildngs per PNNL.
r = 0.12
cop = (eer/3.413 + r)/(1-r)
return cop
end | [
"def seer_to_cop(seer)\n \n cop = nil\n\n # First convert from SEER to EER\n eer = (-0.0182 * seer * seer) + (1.1088 * seer)\n \n # Next convert EER to COP\n cop = eer_to_cop(eer)\n \n return cop\n \nend",
"def cp_e\n end",
"def eficiencia_energetica\n (vct / (emisiones[:co2] + emisiones[:terre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert from COP to kW/ton | def cop_to_kw_per_ton(cop)
return 3.517/cop
end | [
"def kconv(str, out_code, in_code = AUTO)\n opt = '-'\n case in_code\n when ::NKF::JIS\n opt << 'J'\n when ::NKF::EUC\n opt << 'E'\n when ::NKF::SJIS\n opt << 'S'\n when ::NKF::UTF8\n opt << 'W'\n when ::NKF::UTF16\n opt << 'W16'\n end\n\n case out_code\n when ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A helper method to convert from kW/ton to COP | def kw_per_ton_to_cop(kw_per_ton)
return 3.517/kw_per_ton
end | [
"def cop_to_kw_per_ton(cop)\n \n return 3.517/cop\n \nend",
"def to_cubic_yard(**options) = convert_to('cubic-yard', **options)",
"def to_cmyk\n k = 1.0 - @g.to_f\n Color::CMYK.from_fraction(0, 0, 0, k)\n end",
"def to_cmyk\n c = 1.0 - @r.to_f\n m = 1.0 - @g.to_f\n y = 1.0 - @b.to_f\n\n k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A helper method to convert from AFUE to thermal efficiency | def afue_to_thermal_eff(afue)
return afue # Per PNNL doc, Boiler Addendum 90.1-04an
end | [
"def to_therm_us(**options) = convert_to('therm-us', **options)",
"def combustion_eff_to_thermal_eff(combustion_eff)\n \n return combustion_eff - 0.007 # Per PNNL doc, Boiler Addendum 90.1-04an\n \nend",
"def convert(temp_value,conversion_type)\n if conversion_type.to_s == \"FTC\"\n 5.0/9.0*(temp_value.to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A helper method to convert from combustion efficiency to thermal efficiency | def combustion_eff_to_thermal_eff(combustion_eff)
return combustion_eff - 0.007 # Per PNNL doc, Boiler Addendum 90.1-04an
end | [
"def afue_to_thermal_eff(afue)\n \n return afue # Per PNNL doc, Boiler Addendum 90.1-04an\n \nend",
"def heat_pump_coefficient_of_performance\n secondary_carriers = inputs.map { |input| input.carrier.key } -\n [fever.efficiency_based_on, fever.efficiency_balanced_with]\n\n primary_carrier... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert one infiltration rate at a given pressure to an infiltration rate at another pressure per method described here: where the infiltration coefficient is 0.65 | def adjust_infiltration_to_lower_pressure(initial_infiltration_rate_m3_per_s, intial_pressure_pa, final_pressure_pa, infiltration_coefficient = 0.65)
adjusted_infiltration_rate_m3_per_s = initial_infiltration_rate_m3_per_s * (final_pressure_pa/intial_pressure_pa)**infiltration_coefficient
return adjusted_infiltra... | [
"def adjust_infiltration_to_prototype_building_conditions(initial_infiltration_rate_m3_per_s)\n\n # Details of these coefficients can be found in paper\n alpha = 0.22 # unitless - terrain adjustment factor\n intial_pressure_pa = 75.0 # 75 Pa\n uh = 4.47 # m/s - wind speed\n rho = 1.18 # kg/m^3 - air density\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert the infiltration rate at a 75 Pa to an infiltration rate at the typical value for the prototype buildings per method described here: | def adjust_infiltration_to_prototype_building_conditions(initial_infiltration_rate_m3_per_s)
# Details of these coefficients can be found in paper
alpha = 0.22 # unitless - terrain adjustment factor
intial_pressure_pa = 75.0 # 75 Pa
uh = 4.47 # m/s - wind speed
rho = 1.18 # kg/m^3 - air density
cs = 0.1617... | [
"def adjust_infiltration_to_lower_pressure(initial_infiltration_rate_m3_per_s, intial_pressure_pa, final_pressure_pa, infiltration_coefficient = 0.65)\n\n adjusted_infiltration_rate_m3_per_s = initial_infiltration_rate_m3_per_s * (final_pressure_pa/intial_pressure_pa)**infiltration_coefficient\n\n return adjusted... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a unique name for `item` among the folder's existing contents by appending a serial number to it, if necessary. E.g. "logo.png" will be named "logo.png (1)" if the files named "logo.png" and "logo.png (0)" exist in the folder. | def next_uniq_child_name(item)
taken_names = contents_names(item).map(&:downcase)
name_generator = FileName.new(item.name, path: :relative, add: :always,
format: '(%d)', delimiter: ' ')
new_name = item.name
new_name = name_generator.create while taken_names.i... | [
"def make_unique_id(item)\n return item['id'] if item['id']\n\n unique_id = \"\"\n unique_id << item.title if item.title\n\n if summary = item.summary\n if summary.length < 200\n unique_id << summary\n else\n first_100 = summary[0,100]\n unique_id << firs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Take Courseadvance_start_at_duration into account when calculating folder's start datetime. | def effective_start_at
start_at - course&.advance_start_at_duration
end | [
"def self_directed_started?(course_user = nil)\n if course&.advance_start_at_duration\n time_for(course_user).start_at.blank? ||\n time_for(course_user).start_at - course.advance_start_at_duration < Time.zone.now\n else\n started?\n end\n end",
"def self_directed_started?\n if course... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches the names of the contents of the current folder, except for an excluded_item, if one is provided. | def contents_names(excluded_item = nil)
excluded_material = excluded_item.instance_of?(Course::Material) ? excluded_item : nil
excluded_folder = excluded_item.instance_of?(Course::Material::Folder) ? excluded_item : nil
materials_names = materials.where.not(id: excluded_material).pluck(:name)
subfolders... | [
"def get_files_in_folder folder_name\n all = self.get_files\n folder_files = all.keep_if{|one| one.include?(\"#{folder_name}/\") && (one.size > folder_name.size + 1)}\n folder_files.map!{|one| one.gsub(\"#{folder_name}/\", \"\")}\n end",
"def get_children_of_special_folder name\n url = base... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return false to prevent the userstamp gem from changing the updater during duplication | def record_userstamp
!duplicating?
end | [
"def record_userstamp\n !@duplicating\n end",
"def allow_manual_timestamp_update?\n @allow_manual_timestamp_update\n end",
"def updated?\n updater && author != updater\n end",
"def update_version?\n append_version?\n end",
"def requires_modified_files?\n false\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to get rid of the commas and dollar sign, I first make the argument cost into a string, then I put it into an array with the split method on '.' . $4,500.578 would give me [$4,500, 578] I iterate over the first element of the array and get rid of all the char that aren't numbers for the decimal part, I round the... | def modify(cost)
answer = ''
if cost == cost.to_f || cost == cost.to_i
return cost
else
cost = cost.to_s
arr = cost.split('.')
arr[0].each_char do |c|
if isNum?(c)
answer += c.to_s
end
end
end
return answer.to_i + arr[1].to_i.round(2)* 0.01
end | [
"def convert_to_price(string)\n price_string = string.gsub(\",\", \"\")\n price = /\\$(\\d+\\.\\d+)/.match(price_string) # $XX.XX\n price ||= /\\$(\\d+)/.match(price_string) # $XX\n price.nil? ? 0.0 : price[0][1..-1].to_f # [1..-1] to remove the dollar sign\n end",
"def cost_pounds(amount)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
a hash where the key is the trip id and the value is the amount of total saved. If nothing has been saved, the trip.id is not a key | def hash_trip_id_total_saved(trips)
hash = {}
trips.each do |trip|
if trip.savings!= 0
hash[trip.id] = total_saved_for_trip(trip)
end
end
return hash
end | [
"def my_trips_hash(trip)\n trips_hash = { \"0\" => trip_hash(trip) }\n trips_hash[\"1\"] = trip_hash(trip.next_trip) if (trip.next_trip and trip.next_trip.selected_itinerary)\n trips_hash\n end",
"def sum_trip_data(trip)\n @new_trip_miles = (@new_trip_miles + trip.miles_driven).round... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generate a random dns_name if azure_dns_name is empty | def get_dns_name(azure_dns_name, prefix = "az-")
return azure_dns_name unless azure_dns_name.nil?
if locate_config_value(:azure_vm_name).nil?
azure_dns_name = prefix + SecureRandom.hex(( MAX_VM_NAME_CHARACTERS - prefix.length) / 2)
else
azure_dns_name = locate_config_value(:a... | [
"def get_dns_name(azure_dns_name, prefix = \"az-\")\n return azure_dns_name unless azure_dns_name.nil?\n\n if config[:azure_vm_name].nil?\n (prefix + SecureRandom.hex((MAX_VM_NAME_CHARACTERS - prefix.length) / 2))\n else\n config[:azure_vm_name]\n end\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define a interpret method that interprets article data after it parsed | def interpret(i)
article = Article.new
article.title = !i.title.nil? ? i.title : 'n/a'
article.source = @source
article.pub_date = !i.pubDate.nil? ? i.pubDate : nil
name = !i.source.nil? ? i.source.content : 'n/a'
article.author = (name[0..2] == 'By ') ? name.slice(3..name.size) : name
art... | [
"def interpret(d)\n article = Article.new\n\n if d['headline'] != []\n if !d['headline']['main'].nil?\n article.title = d['headline']['main']\n elsif !d['headline']['name'].nil?\n article.title = d['headline']['name']\n end\n end\n if article.title.nil?\n article.title ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pds_projects POST /pds_projects.json | def create
@pds_project = PdsProject.new(pds_project_params)
respond_to do |format|
if @pds_project.save
format.html { redirect_to @pds_project, notice: 'Pds project was successfully created.' }
format.json { render :show, status: :created, location: @pds_project }
else
form... | [
"def post_new_project\n self.class.params\n options = {:body =>{:project=>\n {:title => @@params[\"title\"],\n :description => @@params[\"description\"]}}}\n self.class.post(\"/projects.json\", options)\n end",
"def create_project(name)\n post('projects', {:name => name})[\"proj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pds_projects/1 PATCH/PUT /pds_projects/1.json | def update
respond_to do |format|
if @pds_project.update(pds_project_params)
format.html { redirect_to @pds_project, notice: 'Pds project was successfully updated.' }
format.json { render :show, status: :ok, location: @pds_project }
else
format.html { render :edit }
forma... | [
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.json { head :no_content }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def up... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pds_projects/1 DELETE /pds_projects/1.json | def destroy
@pds_project.destroy
respond_to do |format|
format.html { redirect_to pds_projects_url, notice: 'Pds project was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @root = \"projects\"\n \n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /recipies GET /recipies.json | def index
@recipies = Recipy.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @recipies }
end
end | [
"def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end",
"def index\n @recips = Recip.all\n\n render json: @recips.as_json\n end",
"def index\n @recipies = Recipy.paginate(paginate_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /recipies/1 GET /recipies/1.json | def show
@recipy = Recipy.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @recipy }
end
end | [
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def index\n @recips = Recip.all\n\n render json: @recips.as_json\n end",
"def index\n @recipies = Recipy.paginate(paginate_params)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /recipies/new GET /recipies/new.json | def new
@recipy = Recipy.new
2.times {@recipy.ingridients.build}
@items = Item.all
respond_to do |format|
format.html # new.html.erb
format.json { render json: @recipy }
end
end | [
"def new\n @newrelic = Newrelic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newrelic }\n end\n end",
"def new\n @regress = Regress.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @regress }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /recipies POST /recipies.json | def create
@recipy = Recipy.new(params[:recipy])
respond_to do |format|
if @recipy.save
format.html { redirect_to @recipy, notice: 'Recipy was successfully created.' }
format.json { render json: @recipy, status: :created, location: @recipy }
else
format.html { render action:... | [
"def create\n #byebug\n @recip = Recip.new(recip_params)\n\n if @recip.save\n render json: @recip, status: :created, location: @recip\n else\n render json: @recip.errors, status: :unprocessable_entity\n end\n end",
"def create\n @recipy = Recipy.new(recipy_params)\n\n params[:recip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /recipies/1 PUT /recipies/1.json | def update
@recipy = Recipy.find(params[:id])
respond_to do |format|
if @recipy.update_attributes(params[:recipy])
format.html { redirect_to @recipy, notice: 'Recipy was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n if @recipy.update(recipy_params)\n render :show, status: :ok, location: @recipy\n else\n render json: @recipy.errors, status: :unprocessable_entity\n end\n end",
"def update\n @recip = Recip.find(params[:id])\n\n if @recip.update(recip_params)\n head :no_content\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /recipies/1 DELETE /recipies/1.json | def destroy
@recipy = Recipy.find(params[:id])
@recipy.destroy
respond_to do |format|
format.html { redirect_to recipies_url }
format.json { head :no_content }
end
end | [
"def destroy\n @recip.destroy\n\n head :no_content\n end",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @residencial = Residencial.find(params[:id])\n @residencial.destroy\n\n respond_to do |format|\n format.html { redirect_to res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shortcut method to retrieve the ArtRest::System::GeneralConfiguration resource. Args : +base_url+ > Our Artifactory server's base URL +options+ > A Hash containing username and password Returns : The ArtRest::System::GeneralConfiguration resource | def get(base_url, options)
System::GeneralConfiguration.new("#{base_url}/api/system/configuration", options)
end | [
"def retrieve_system_configuration()\n start.uri('/api/system-configuration')\n .get()\n .go()\n end",
"def retrieve_system_configuration()\n start.uri('/api/system-configuration')\n .get()\n .go()\n end",
"def _get_config(rel_path, view, api_version = 1)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /idti_services GET /idti_services.json | def index
@idti_services = IdtiService.all
end | [
"def services\n params = { command: 'account_services' }\n get('/json.php', params)\n end",
"def find_services_by_item(id, options={})\n self.class.get(\"/items/#{id}/services.json?apikey=#{apikey}\", :query => options)\n end",
"def get_node_services(service_id)\n reques... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /idti_services POST /idti_services.json | def create
@idti_service = IdtiService.new(idti_service_params)
respond_to do |format|
if @idti_service.save
format.html { redirect_to @idti_service, notice: 'Idti service was successfully created.' }
format.json { render :show, status: :created, location: @idti_service }
else
... | [
"def add_service(service={})\n request :post, '/services', service\n end",
"def create_service(service = {}, options = {})\n options[:service] = service\n response = post \"/services\", options\n response[:service] \n end",
"def add_service_to_item(id, options={})\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /idti_services/1 PATCH/PUT /idti_services/1.json | def update
respond_to do |format|
if @idti_service.update(idti_service_params)
format.html { redirect_to @idti_service, notice: 'Idti service was successfully updated.' }
format.json { render :show, status: :ok, location: @idti_service }
else
format.html { render :edit }
... | [
"def update\n @service = Service.find(params[:id])\n\n update_depending(params[\"service\"][\"dependings\"])\n update_dependant(params[\"service\"][\"inverse_dependings\"])\n\n respond_to do |format|\n if @service.update_attributes(service_params)\n format.html { redirect_to services_path(:a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /idti_services/1 DELETE /idti_services/1.json | def destroy
@idti_service.destroy
respond_to do |format|
format.html { redirect_to idti_services_url, notice: 'Idti service was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_service(service_id)\n request(:delete, \"/service/#{service_id}\")\n end",
"def destroy\n service = Service.find_by(id: params[:id])\n service.destroy\n end",
"def delete\n verify_request!\n unless uuids = @request.params[\"uuids\"]\n raise \"Provide lis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /mailinglists/new GET /mailinglists/new.xml | def new
@mailinglist = Mailinglist.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @mailinglist }
end
end | [
"def new\n @mailing_list = MailingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mailing_list }\n end\n end",
"def new\n @mailing_list_item = MailingListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /mailinglists POST /mailinglists.xml | def create
@mailinglist = Mailinglist.new(params[:mailinglist])
respond_to do |format|
if @mailinglist.save
flash[:notice] = ''
format.html { redirect_to :controller => "home", :action => "gracias_mailinglist" }
format.xml { render :xml => @mailinglist, :status => :created, :loca... | [
"def create\n @mailing_list = MailingList.new(params[:mailing_list])\n\n respond_to do |format|\n if @mailing_list.save\n format.html { redirect_to(@mailing_list, :notice => 'MailingList was successfully created.') }\n format.xml { render :xml => @mailing_list, :status => :created, :locati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /mailinglists/1 PUT /mailinglists/1.xml | def update
@mailinglist = Mailinglist.find(params[:id])
respond_to do |format|
if @mailinglist.update_attributes(params[:mailinglist])
flash[:notice] = 'Mailinglist was successfully updated.'
format.html { redirect_to(@mailinglist) }
format.xml { head :ok }
else
for... | [
"def update\n @mailing_list = MailingList.find(params[:id])\n\n respond_to do |format|\n if @mailing_list.update_attributes(params[:mailing_list])\n format.html { redirect_to(@mailing_list, :notice => 'MailingList was successfully updated.') }\n format.xml { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /mailinglists/1 DELETE /mailinglists/1.xml | def destroy
@mailinglist = Mailinglist.find(params[:id])
@mailinglist.destroy
respond_to do |format|
format.html { redirect_to(mailinglists_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @mailing_list = MailingList.find(params[:id])\n @mailing_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailing_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mailing_list_item = MailingListItem.find(params[:id])\n @mailing_li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add rectangle filled with given color. Give color in RGB hex format (e.g. '558ed5') | def add_filled_rectangle(transform, color)
shape = Shapes::FilledRectangle.new(transform, color)
shape_tree_xml.add_child(shape.build_node)
end | [
"def fill_with(color)\n SDL::FillRect(@screen, nil, convert(color))\n end",
"def fill(color)\n SDL.FillRect(@sdl_surface, nil, color.to_i(:surface))\n end",
"def full_fill(color)\r\n fill_rect(rect, color)\r\n end",
"def draw_solid_rect(color, x1, y1, x2, y2)\n send_command( 0x78, color... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a slide number that is recognized by Powerpoint as such and automatically updated See textbox for formatting. | def add_slide_number(transform, number, formatting={})
shape = Shapes::SlideNumber.new(transform, number, formatting)
shape_tree_xml.add_child(shape.build_node)
end | [
"def nextSlide\n\t\tif @currentSlide < @slides.length - 1\n\t\t\t@currentSlide+=1\n\t\t\tdisplaySlide\n\t\tend\n\n\tend",
"def set_next_slide\n if self.sequence-1>=1\n @slide=Slide.find_by_sequence_and_presentation_id(self.sequence-1,self.presentation_id)\n @slide.next_slide=self.id\n @slide.sav... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to locate the specified JAR(s) and require them. First we try to load the jar with the current load path, as this allows a library user to control where the JARs should be loaded from by setting the classpath or JRuby load path. Only if that fails do we fallback to attempting to locate the JARs on our own. | def load_jars(*jars)
jars.each do |jar|
unless $LOADED_FEATURES.find{ |f| f =~ Regexp.new(jar) }
log.finest "Loading jar #{jar}..."
begin
loaded = require(jar)
rescue LoadError
loaded = find_jar(jar)
... | [
"def require_jars(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.each do |path|\n jar_pattern = File.join(path,\"**\", \"*.jar\")\n Dir[jar_pattern].each {|jar_file| require jar_file}\n end\n end",
"def require_jars!\n require 'jruby'\n\n # ask marc-marc4j gem to load... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the specified jar using EPM_ORACLE_HOME as a starting point. | def find_jar(jar)
oh = java.lang.System.getProperty('EPM_ORACLE_HOME') || ENV['EPM_ORACLE_HOME']
unless oh
raise ConfigurationError, "No EPM_ORACLE_HOME defined. Set this as an environment " +
"variable or Java system property, or else add #{jar} to the classpath."
en... | [
"def which_jar(options)\n env_jar = ENV['CALLIGRAPHUS_LOCATION']\n opt_jar = options[:jar]\n return opt_jar if opt_jar && File.exist?(opt_jar)\n return env_jar if env_jar && File.exist?(env_jar)\n end",
"def oracle\n config_var = shift_argument\n config_vars = get_config_vars(config_var)\n u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
helper to create sample controlled vocab | def create_sample_controlled_vocab_terms_attributes(array)
attributes = []
array.each do |type|
attributes << { label: type }
end
attributes
end | [
"def prep_vocab(vocab)\n o_file = \"#{@lda_data_dir}/lda_vocab.dat\"\n output = File.open(o_file, 'w')\n\n vocab.each do |v|\n output.puts v\n end\n output.close\n end",
"def create_vocabulary(documents)\n vocabulary = Set.new\n documents.each do |d|\n vocabulary = vocabulary | d.t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
To add a new set of CV: example_cv = SampleControlledVocab.where(title: 'CV Title').first_or_create!( sample_controlled_vocab_terms_attributes: create_sample_controlled_vocab_terms_attributes(['CV 1', 'CV 2', 'CV 3']) ) Can later be used like that: create_custom_metadata_attribute(title: 'CM Metadata attribute using CV... | def create_custom_metadata_attribute(title:, required:, sample_attribute_type:, sample_controlled_vocab: nil)
CustomMetadataAttribute.where(title).create!(title: title, required: required,
sample_attribute_type: sample_attribute_type,
... | [
"def create_sample_controlled_vocab_terms_attributes(array)\n attributes = []\n array.each do |type|\n attributes << { label: type }\n end\n attributes\nend",
"def create(cv)\n if cv.public_id.nil? then\n raise ArgumentError.new(\"Controlled value create is missing a public id\")\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validates that the email is unique per active users | def email_is_unique
active_users = User.active.where(:email => self.email)
active_users = active_users.exclude(self) unless self.new_record?
errors.add :email, 'ya existe' if active_users.count(:id) > 0
end | [
"def unique_email_user\n if self.class.where(email: email).count > 0\n errors.add(:email, :taken)\n end\n end",
"def is_email_unique_compared_to_user\n user_with_email = User.find_by_email(cust_email)\n #logger.info \"AppLog: #{cust_email}, #{user_with_email}\"\n if ! user_with_email.ni... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resize the image to fit within the specified dimensions while retaining the original aspect ratio. If necessary, will pad the remaining area with the given color, which defaults to transparent (for gif and png, white for jpeg). === Parameters [width (Integer)] the width to scale the image to [height (Integer)] the heig... | def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)
width = dimension_from width
height = dimension_from height
manipulate! do |img|
img.resize_to_fit!(width, height)
filled = ::Magick::Image.new(width, height) { |image| image.background_color = ... | [
"def resize_and_pad(width, height, background=:transparent, gravity='Center')\n manipulate! do |img|\n img.combine_options do |cmd|\n cmd.thumbnail \"#{width}x#{height}>\"\n if background == :transparent\n cmd.background \"rgba(255, 255, 255, 0.0)\"\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resize the image per the provided geometry string. === Parameters [geometry_string (String)] the proportions in which to scale image === Yields [Magick::Image] additional manipulations to perform | def resize_to_geometry_string(geometry_string)
manipulate! do |img|
new_img = img.change_geometry(geometry_string) do |new_width, new_height|
img.resize(new_width, new_height)
end
destroy_image(img)
new_img = yield(new_img) if block_given?
new_img
end
en... | [
"def resize_to_geometry_string(geometry_string); end",
"def resize!( geometry )\n process! do |img|\n img.change_geometry( geometry ) do |c, r, i|\n i.resize(c,r)\n end\n end\n end",
"def resize!( geometry )\n manipulate! do |img|\n img.change_geometry( geomet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Position of point on the left side | def left
Point.new(@x - 1, @y)
end | [
"def left\n self.position[:x]\n end",
"def absolute_left\n @x\n end",
"def left_side\n absolute_left\n end",
"def left_val(pt)\n self.points[\"#{Point.new(pt.x-1,pt.y, nil)}\"]\n end",
"def lower_left\n @lower_left ||= world.point(x_min, y_min)\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Position of point on the right side | def right
Point.new(@x + 1, @y)
end | [
"def right_side\n absolute_right\n end",
"def top_right\n Point[x + width, y]\n end",
"def bottom_right\n @position + @dimensions\n end",
"def bottom_right\n Point[@x + width, @y + height]\n end",
"def bottom_right\n [@right, @bottom].point\n end",
"def topRight\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse the outermost describe block from a Jasmine spec file returns nil if no describe block is found | def spec_description(path)
File.read(path).scan(/describe.+?['"]([^'"]+)/).flatten.first
end | [
"def suite_from_first_describe(file)\n File.foreach(file) do |line|\n return Regexp.last_match[1] if line =~ /describe\\s*[(\"']+(.*?)[\"')]+/ # '\n end\n end",
"def head\n if @exp.test_case?\n rspec_describe_block\n else\n s(:class, @exp.name, @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /intakes/new GET /intakes/new.json | def new
@intake = Intake.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @intake }
end
end | [
"def new\n @fake_thing = FakeThing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fake_thing }\n end\n end",
"def new\n @take = Take.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @take }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /intakes POST /intakes.json | def create
@intake = Intake.new(params[:intake])
respond_to do |format|
if @intake.save
flash[:success] = "Intake was successfully created."
format.html { redirect_to @intake, notice: 'Intake was successfully updated.' }
else
format.html { render action: "new" }
form... | [
"def create\n @intake = current_user.intakes.build(intake_params)\n\n respond_to do |format|\n if @intake.save\n @intake.calculate_calories\n format.html { redirect_to intakes_url, notice: 'Intake was successfully created.' }\n format.json { render :show, status: :created, location: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /intakes/1 PUT /intakes/1.json | def update
@intake = Intake.find(params[:id])
respond_to do |format|
if @intake.update_attributes(params[:intake])
format.html { redirect_to @intake, notice: 'Intake was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n @intake = Intake.find(params[:id])\n\n respond_to do |format|\n if @intake.update_attributes(params[:intake])\n format.html { redirect_to(@intake, :notice => t('intake.title2')+\" \"+t('updated')) }\n format.xml { head :ok }\n else\n format.html { render :action =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /intakes/1 DELETE /intakes/1.json | def destroy
@intake = Intake.find(params[:id])
@intake.destroy
respond_to do |format|
flash[:success] = "Intake successfully detroyed!"
format.html { redirect_to intakes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url, notice: 'Intake was successfully destro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Note: This test will only pass with test account credentials which have asynchronous adjustments enabled. | def test_successful_asynchronous_adjust
assert authorize = @gateway_latam.authorize(@amount, @credit_card, @options)
assert_successful_response(authorize)
assert adjust = @gateway_latam.adjust(@amount * 2, authorize.authorization, @options)
assert_success adjust
assert capture = @gateway_latam.captu... | [
"def test_failed_synchronous_adjust_using_adjust_data\n authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))\n assert_success authorize\n\n options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
to create a valid pares, use the test credentials to request `test_3ds_enroll_request_via_purchase` with debug=true. Extract this XML and generate an accessToken. Using this access token to create a form, visit the stepUpURL provided and check the network exchange in the browser dev console for a CCA, which will contai... | def test_successful_3ds_validate_purchase_request
assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares))
assert_equal '100', response.params['reasonCode']
assert_equal '0', response.params['authenticationResult']
assert respons... | [
"def test_successful_ach_purchase\n assert response = @gateway.purchase(50, @check)\n assert_success response, 'This is probably failing due to your Payflow test account not being set up for ACH.'\n assert_equal 'Approved', response.message\n assert response.test?\n assert_not_nil response.authorizat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Testplan URIs can contain variables in the form :varname. This method looks at the request parameters and then at the usecase's resource hash for a replacement value. If not found, returns nil. | def find_replacement_value(name, params, container, base_uri)
value = nil
#Stella.ld "REPLACE: #{name}"
#Stella.ld "PARAMS: #{params.inspect}"
#Stella.ld "IVARS: #{container.instance_variables}"
if name.to_sym == :HOSTNAME && !base_uri.nil?
value = base_uri.host
elsif params... | [
"def replace_memorized_variables(string_value, remove_quotes = true)\n # if JsonSpec variables are present, replace any potential references to them in the URL\n JsonSpec.memory.each do |doc|\n var_name = doc[0]\n # doc[1] is stored with quotes \".....\" so we have to remove them if told to (usually yes)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the appropriate response handler by executing the HTTP response status against the configured handlers. If several match, the first one is returned. | def find_response_handler(container, req)
handler = nil
req.response.each_pair do |regex,h|
Stella.ld "HANDLER REGEX: #{regex.to_s} (#{container.status})"
regex = /#{regex}/ unless regex.is_a? Regexp
handler = h and break if container.status.to_s =~ regex
end
handler
... | [
"def status_handler_for( status_code )\n\t\tself.log.debug \"[:errors] Looking for a status handler for %d responses\" % [ status_code ]\n\t\thandlers = self.class.status_handlers\n\t\tranges = handlers.keys\n\n\t\tranges.each do |range|\n\t\t\treturn handlers[ range ] if range.include?( status_code )\n\t\tend\n\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if a coupon merchant code already exists Determines if a coupon merchant code already exists. | def does_coupon_code_exist(merchant_code, opts = {})
data, _status_code, _headers = does_coupon_code_exist_with_http_info(merchant_code, opts)
data
end | [
"def generate_coupon_code\n self.coupon_code = loop do\n generated_code = \"eps57554e2\" + SecureRandom.hex(3) + \"gwd\"\n break generated_code unless Record.exists?(coupon_code: generated_code)\n end\n end",
"def coupon_code_taken?\n \t\t#coupon_found = Coupon.where('coupon_code like B... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a coupon Retrieves a single coupon using the specified coupon profile oid. | def get_coupon(coupon_oid, opts = {})
data, _status_code, _headers = get_coupon_with_http_info(coupon_oid, opts)
data
end | [
"def stripe_coupon\n return nil if stripe_coupon_id.nil?\n\n Stripe::Coupon.retrieve(stripe_coupon_id, { api_key: Stripe.api_key })\n end",
"def find(coupon_id)\n response = client.get_with_retry(\"sites/#{client.site_id}/store/coupons/#{coupon_id}\", 3)\n if response.success?\n Coup... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a coupon by merchant code Retrieves a single coupon using the specified merchant code. | def get_coupon_by_merchant_code(merchant_code, opts = {})
data, _status_code, _headers = get_coupon_by_merchant_code_with_http_info(merchant_code, opts)
data
end | [
"def show_by_code\r\n obj = Coupon.find_by_coupon_code(params[:code])\r\n \r\n if obj.nil?\r\n render :json => { result: \"fail\", reason: \"no match coupon object\" }, :status => 400 \r\n else\r\n render :json => { result: \"success\", coupon: obj }, :status => 200\r\n end \r\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve coupons Retrieves coupons for this account. If no parameters are specified, all coupons will be returned. You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. | def get_coupons(opts = {})
data, _status_code, _headers = get_coupons_with_http_info(opts)
data
end | [
"def coupons\n coupons = links.coupons.embedded.coupons\n CouponsCollection.new(resource, coupons)\n end",
"def all(options = nil)\n request = Request.new(@client)\n path = \"/coupons\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve coupons by query Retrieves coupons from the account. If no parameters are specified, all coupons will be returned. You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. | def get_coupons_by_query(coupon_query, opts = {})
data, _status_code, _headers = get_coupons_by_query_with_http_info(coupon_query, opts)
data
end | [
"def get_coupons(opts = {})\n data, _status_code, _headers = get_coupons_with_http_info(opts)\n data\n end",
"def coupons\n company_id = params[:company_id]\n @coupons = Coupon.where(:company_id => company_id)\n end",
"def all(options = nil)\n request = Request.new(@client)\n path ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve values needed for a coupon editor Retrieve values needed for a coupon editor | def get_editor_values_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: CouponApi.get_editor_values ...'
end
# resource path
local_var_path = '/coupon/editor_values'
# query parameters
query_params = {}
# header pa... | [
"def coupon_details\n Hash.new\n end",
"def coupons\n fee_adjustments.coupon\n end",
"def coupon\n return @invoice[:discount][:coupon][:id] if @invoice[:discount]\n end",
"def index\n @coupon_codes = @restaurant.coupon_codes\n end",
"def index\n @coupon_codes = CouponCode.all\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert a coupon Insert a coupon on the UltraCart account. | def insert_coupon(coupon, opts = {})
data, _status_code, _headers = insert_coupon_with_http_info(coupon, opts)
data
end | [
"def add_coupon(coupon)\n self.class.add_coupon(cart_id, coupon)\n end",
"def apply_coupon(coupon)\n assert_customer_exists\n\n customer = as_stripe_customer\n\n customer.coupon = coupon\n\n customer.save\n end",
"def add_coupon\n # Make sure coupons are enabled\n if CartCon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count a victory for the player. | def victory
@wins += 1
end | [
"def track_victory(winnerofturn) #algorythmic\n if winnerofturn == @Player1\n @win_counter[\"P1\"] += 1\n elsif winnerofturn == @Player2\n @win_counter[\"P2\"] += 1\n end\n end",
"def appearances(player_id)\n appearances = 0\n Stat.where(player_id: player_id, appearance:true).each do |st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count a defeat for the player. | def defeat
@losses += 1
end | [
"def cmd_defend\n state = counter_attack\n if @world[:health] > 0\n puts \"Catching your breath, you gained 1 health!\"\n @world[:health] += 1\n end\n return state\n end",
"def eat(food)\n\tif food.eaten == true\n\t\tputs \"om nom nom\"\n\tend\n\t@meals_eaten += 1\nend",
"def eat\n inv... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count that the player was red. | def as_red
@red += 1
end | [
"def appearances(player_id)\n appearances = 0\n Stat.where(player_id: player_id, appearance:true).each do |stat|\n if stat.match.status\n appearances += 1\n end\n end\n appearances\n end",
"def won_red?\n :red == winner\n end",
"def lost_red?\n :red == winner\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count that the player was blue. | def as_blue
@blue += 1
end | [
"def blue_goals\n self.scores.joins(:player)\n .where(players: { team_id: self.blue_team_id })\n .count\n end",
"def blue_screen_count\n return @blue_screen_count\n end",
"def as_red\n @red += 1\n end",
"def appearances(player_id)\n appearances ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create or update a tier1 interface If an interface with the interfaceid is not already present, create a new interface. If it already exists, replace the interface with this object. | def create_or_replace_tier1_interface(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})
data, _status_code, _headers = create_or_replace_tier1_interface_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts)
data
end | [
"def create_or_replace_tier1_interface_0(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})\n data, _status_code, _headers = create_or_replace_tier1_interface_0_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts)\n data\n end",
"def attach_interfac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create or update a tier1 interface If an interface with the interfaceid is not already present, create a new interface. If it already exists, replace the interface with this object. | def create_or_replace_tier1_interface_0(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})
data, _status_code, _headers = create_or_replace_tier1_interface_0_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts)
data
end | [
"def create_or_replace_tier1_interface(tier_1_id, locale_services_id, interface_id, tier1_interface, opts = {})\n data, _status_code, _headers = create_or_replace_tier1_interface_with_http_info(tier_1_id, locale_services_id, interface_id, tier1_interface, opts)\n data\n end",
"def attach_interface(ed... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List Tier1 interfaces Paginated list of all Tier1 interfaces | def list_tier1_interfaces_with_http_info(tier_1_id, locale_services_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.list_tier1_interfaces ...'
end
# verify the required parameter 'tier... | [
"def list_tier1_interfaces_0_with_http_info(tier_1_id, locale_services_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.list_tier1_interfaces_0 ...'\n end\n # verify the required pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List Tier1 interfaces Paginated list of all Tier1 interfaces | def list_tier1_interfaces_0_with_http_info(tier_1_id, locale_services_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.list_tier1_interfaces_0 ...'
end
# verify the required parameter '... | [
"def list_tier1_interfaces_with_http_info(tier_1_id, locale_services_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysInterfacesInterfacesApi.list_tier1_interfaces ...'\n end\n # verify the required parame... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this user belong to the Alumni group? | def alumni?
roles.where(name: Ability.alumni_group_name).exists?
end | [
"def user_pertenece_al_grupo?(user)\n return self.users.include?(user)\n end",
"def member_of_group\n\t\tif not @group.user_list.include?(current_user.id)\n\t\t\trespond(ERR_INVALID_PERMISSIONS)\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend",
"def belongs_to?(group)\n group.all_users.include? self\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this user belong to the Faculty group? | def faculty?
roles.where(name: Ability.faculty_group_name).exists?
end | [
"def faculty?\n\t\tmember_of.downcase.include? \"faculty\"\n\tend",
"def is_faculty\r\n self.user_type == User::Types::Faculty\r\n end",
"def faculty?\n affiliations 'capFaculty'\n end",
"def faculty?\n \tmember_of.downcase.include? \"faculty\"\n end",
"def is_faculty?\n\t\tassignments.eac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this user belong to the Staff group? | def staff?
roles.where(name: Ability.staff_group_name).exists?
end | [
"def is_staff?(user)\n Role.has_entry? user, :staff, self\n end",
"def user_is_in_group?(user, group)\n user.has_group?(group)\n end",
"def can_see_staff?(staff)\n role_names.include?(Roles::STAFF_SUPERVISOR) || staff.username == username\n end",
"def is_group_member?(user_id)\n GroupUs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this user belong to the Student group? | def student?
roles.where(name: Ability.student_group_name).exists?
end | [
"def user_is_in_group?(user, group)\n user.has_group?(group)\n end",
"def user_in_group?(user, group)\n return get_user_groups(user).include?(group)\n end",
"def belongs_to?(group)\n group.all_users.include? self\n end",
"def current_user_has_student_privileges?\n current_user_has_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets up attributes returned from CAS. No need to save the object: that's done via devise_cas_authenticatable. | def cas_extra_attributes=(attributes)
self.username = attributes['uid']
self.email = attributes['email']
self.given_name = attributes['givenName']
self.surname = attributes['surname']
self.lnumber = attributes['lnumber']
update_roles_from_attributes(attributes)
end | [
"def cas_extra_attributes=(extra_attributes)\n extra_attributes.each do |name, value|\n # I prefer a case over reflection; this is safer if we suddenly get an\n # extra attribute without column\n case name.to_sym\n when :givenname\n self.cas_givenname = value\n when :surname\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Callback to ensure that we store a username, as that's what's used for uniqueness. We occasionally provide a depositor in some ingest cases, but that relies on the email address and _not_ the username. We'll capture the username as anything | def ensure_username
return unless username.blank?
self.username = email.gsub(/@.*$/, '')
end | [
"def create_username() #t\n email_username = self.email.gsub(/(\\A([\\w\\.\\-\\+]+))@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i, \"\\\\1\")\n email_username = email_username.gsub(/\\W/, \"\")\n username_try = email_username\n \n i = 1\n found_unique_username = false\n while(!found_unique_username)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper for setting expire headers. Examples: | def expire(duration)
headers['Cache-Control'] = "max-age=#{duration.to_i}"
headers['Expires'] = duration.from_now.httpdate
end | [
"def expire!\n headers['Age'] = max_age.to_s if fresh?\n end",
"def expires\n return @expires if @expires\n\n @expires = parse_datefield(headers, 'expires')\n end",
"def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.expiry_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calculate the total salary of many employees | def total_salary(employees)
total = 0
employees.each do |employee|
# Don't know/care what kind of `Employee` (regular, Manager,
# or CEO) this is. We can treat them all the same.
total += employee.wage
end
end | [
"def salary_total\n employees.map {|e| e.salary}.reduce(:+)\n end",
"def total_salary(employees)\n total = 0\n employees.each do |employee|\n # Don't know/care what kind of `Employee` (regular, Manager,\n # or CEO) this is. We can treat them all the same.\n total += employee.wage\n end\n total \n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets attributes from a hash. Example: pokemon.assign_attributes(pokemon_number: 25, name: 'Pikachu') | def assign_attributes(**attributes)
attributes.each do |key, value|
send("#{key}=", value)
end
end | [
"def assign_values(hash)\n raise ArgumentError, 'Parameter must be hash.' unless hash.is_a? Hash\n\n hash.each do |p, v|\n raise ArgumentError, \"Wrong attribute: #{p}\" unless respond_to? p\n instance_variable_set(\"@#{p}\", v)\n end\n end",
"def apply_attributes_from_hash( _objec... | {
"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.