query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Checks to see if any new promotions have been applied to the order. | def new_promotions?
!new_promotions.empty?
end | [
"def existing_promotions?\n !existing_promotions.empty?\n end",
"def pending_promotions?\n !pending_promotions.empty?\n end",
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).cal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see if there are any promotions pending/applied to the order. | def pending_promotions?
!pending_promotions.empty?
end | [
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def existing_promotions?\n !existing_promotions.empty?\n end",
"def related_promotions?\n !related_promotions.empty?\n end",
"def need_deliver_order_items\n order_items.select(&:need_deliver?)\n end",
"def check_prepaid... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks for any promotions that have already been applied to the order. | def existing_promotions?
!existing_promotions.empty?
end | [
"def promotions\n @promotions ||= order.promotions\n end",
"def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end",
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def pending_promotions?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
An array of IDs of the promotions that have been applied, used to dump the previous promotion state to session. | def promotion_id_dump
pending_promotions.map(&:id)
end | [
"def previous_promotion_ids\n @previous_promotion_ids ||= []\n end",
"def promotions\n @promotions ||= order.promotions\n end",
"def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the IDs of promotions that were previously applied to the order. | def previous_promotion_ids
@previous_promotion_ids ||= []
end | [
"def promotions\n @promotions ||= order.promotions\n end",
"def printer_order_ids\n poids = []\n self.order_line_items.each do |li|\n poids << li.printer_order_id unless poids.include?(li.printer_order_id)\n end\n\n return poids\n end",
"def promotion_id_dump\n pending_promotions.map(&:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see if there is a code promotion applied to the order and that it is successful. | def code_promotion_successful?
promotion_results.code_based.successful?
end | [
"def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_based.failed?\n end",
"def has_promotion_code?\n begin\n return (!order_payload[:custom_fields][:netsuite_custbody][\"coupon_code\"].blank? or !sales_order.promo_code.internal_id.blank?)\n rescue\n return false... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see if there is a promotion code set against this order. If it is nil, then code promotions are pending i.e. haven't been checked yet. | def code_promotion_unchecked?
promo_code.blank?
end | [
"def has_promotion_code?\n begin\n return (!order_payload[:custom_fields][:netsuite_custbody][\"coupon_code\"].blank? or !sales_order.promo_code.internal_id.blank?)\n rescue\n return false\n end\n end",
"def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see if a promotion code has been entered, promotions have been applied and that the order has failed to qualify for any code based promotions. | def code_promotion_failed?
!promo_code.blank? and promotion_results.code_based.failed?
end | [
"def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to apply promotions to this order. It'll return any promotions it successfully applies. | def apply_promotions!
raise PromotionApplyError unless pending_promotions.empty?
@promotion_results = Promotion.active.apply!(self)
apply_adjustments!
# Convert all the applied promotions into an array of decorated
# promotions.
@pending_promotions = applied_promotions.map {|p| ::Promotions::De... | [
"def apply!(order)\n result = check(order)\n if result.successful?\n order.applied_promotions.build(:promotion => self)\n result.effects = effects.map {|e| e.apply!(order, result.conditions)}\n end\n\n result\n end",
"def apply_promotions!\n transaction do\n adjustments.destroy_all\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create [num] SHF applications in the given state return the list of SHF applications created | def create_shf_apps_in_state(num, state, create_date: Time.current)
shf_apps = []
num.times do
shf_apps << create(:shf_application, state: state, created_at: create_date,
updated_at: create_date)
end
shf_apps
end | [
"def create_apps_in_states(create_date: Time.current)\n\n NUM_APPS_IN_STATE.each_pair do |state, number|\n create_shf_apps_in_state(number, state, create_date: create_date)\n end\n\n end",
"def get_recent_shf_apps(start_date, end_date)\n\n @recent_shf_apps = ShfApplication.updated_in_date_range(s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create applications in all states and set the created_at: and updated_at dates to create_date default create_date = Time.zone.now | def create_apps_in_states(create_date: Time.current)
NUM_APPS_IN_STATE.each_pair do |state, number|
create_shf_apps_in_state(number, state, create_date: create_date)
end
end | [
"def create_shf_apps_in_state(num, state, create_date: Time.current)\n shf_apps = []\n\n num.times do\n shf_apps << create(:shf_application, state: state, created_at: create_date,\n updated_at: create_date)\n end\n\n shf_apps\n end",
"def apply_create_timestamp\n creat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add an uploaded file to the SHF application | def add_uploaded_file(shf_app)
shf_app.uploaded_files << create(:uploaded_file, actual_file: File.open(UPLOAD_PNG_FILE))
end | [
"def add(file_path)\n @store.upload(file_path)\n end",
"def add_file(p0) end",
"def add_file(file_path)\n Resource.client.add_file(self, file_path)\n end",
"def upload\n end",
"def add_file(file_path)\n Dropio::Client.instance.add_file(self, file_path)\n end",
"def append_file(key, file)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a member with a membership fee payment, branding fee paid return the member | def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year,
payment_create_date: Time.zone.now,
membership_status: :current_member)
u = create... | [
"def create_member_with_payments_on(payment_start_dates = [Date.today])\n # make the member with the first payment start date:\n first_payment_start_date = payment_start_dates.first\n new_member = create(:member, first_day: first_payment_start_date)\n new_member_co = new_member.shf_application.companies... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a paid up member with a given company number, make a payment with the expire date. | def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now)
u = create(:member_with_membership_app, company_number: company_number)
u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)
c... | [
"def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year,\n payment_create_date: Time.zone.now,\n membership_status: :current_member)\n u ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /event_registrations/1 DELETE /event_registrations/1.json | def destroy
@registration = Registration.find(params[:id])
@event = @registration.event
@registration.destroy
respond_to do |format|
format.html { redirect_to manage_event_path(@event), notice: 'Event registration was successfully destroyed.' }
format.json { head :no_content }
end
... | [
"def destroy\n @event_registration.destroy\n respond_to do |format|\n format.html { redirect_to event_registrations_path}\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_registration = EventRegistration.find(params[:id])\n @event_registration.destroy\n\n respond... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instructions when there is missing license information, but the user has specified disableapi preventing remote license sources being used. | def no_remote_instructions(unlicensed)
puts <<-INST
There is no license defined for #{counter(unlicensed)}. You are running with the `--disable-api`
option. If you remove this option, gemterms will attempt to use RubyGems and
other sources for license information.
INST
true
end | [
"def supports_api\n license = License.get\n\n if license and not license.supports_api?\n errors.add :license, \" - this product does not support API access\"\n end\n end",
"def check_license()\n return true\n end",
"def license_evaluation\n response = { message: \"Endpoint deprecated. Lice... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /birds POST /birds.json Add new bird in data Sanctuary | def create
@bird = Bird.new(bird_params)
if @bird.save
render json: @bird, status: :created
else
render json: @bird.errors, status: :unprocessable_entity
end
end | [
"def add_bird\n bird_obj = bird_params\n continent = params['continents']\n unless continent.nil?\n continent = continent.split(',').map { |v| v.strip } if continent.is_a?(String)\n if continent.is_a?(Array) && !continent.blank?\n continent = continent[0].split... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /birds/1 GET /birds/1.json Return specific bird provided by bird id | def bird_specification
@bird = Bird.find(params[:id])
if @bird
@bird = JSON.parse(@bird.to_json)
@bird["id"]=params[:id]
render json: @bird.except("_id"), status: :ok
else
render :nothing => true, status: :not_found
end
end | [
"def show\n @bird = Bird.find(params[:id])\n\n render json: @bird, status: :ok\n end",
"def index\n @birds = Bird.all\n respond_to do |format|\n format.json { render json: get_birds_response(@birds), status: :ok } # Method available in birds_helper.rb\n end\n end",
"def birdspotter\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
end ======================================================================================== Problem 2: Golden Ratio Golden Ratio is ratio between consecutive Fibonacci numbers calculate the golden ratio up to specified precision validate using MiniTest unit tests module Assignment08 | def golden_ratio(precision)
x = fib(99)/fib(98).to_f
x.round(precision)
end | [
"def fibonacci(n)\n golden_ratio = (1 + 5**0.5) / 2\n ((golden_ratio**n + 1) / 5**0.5).to_i\nend",
"def test_gold_total\n\t\tgold_val = 20.67 * @f.get_gold\n\t\tassert_equal gold_val, @f.calculate_gold_worth\n\tend",
"def fib(n)\n golden_ratio = (1 + 5**0.5) / 2\n ((golden_ratio**n + 1) / 5**0.5).to_i\nend"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Row explanation: [ "language", prs ] Output: [ ["Ruby", 3], ... ["CSS", 1] ] | def language_prs
languages.map do |language|
[language.fetch("language").name, language.fetch("prs")]
end
end | [
"def rows\n text.split(\"\\n\").map do |element|\n mapped = element.split.map do |item|\n item.to_i\n end\n require 'pry'; binding.pry\n end\n end",
"def localize_column(row)\n row\n .map do |key, value|\n next [key, value] unless key.match?(LANGUAGE_SET)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Transforms a SQLiX embedded XML Document. Takes a valid XML document as either a string or url, including local filename, or REXML::Document. Use the seeds hash to feed the references of the initial row element. Returns the resulting XML Document as a string, or as an REXML::Document if that was given. sqlix:query elem... | def transform(xml_source, seeds={})
if xml_source.is_a?(REXML::Document)
xml_document = xml_source
else
src = fetch_xml(xml_source)
xml_document = REXML::Document.new(src)
end
queries = REXML::XPath.match(xml_document.root,'//x:query', {'x' => 'http://www.transami.net/nam... | [
"def xml_to_solr( text, solr_doc=Solr::Document.new )\n doc = REXML::Document.new( text )\n doc.root.elements.each do |element|\n solr_doc << Solr::Field.new( :\"#{element.name}_t\" => \"#{element.text}\" )\n end\n\n return solr_doc\n end",
"def to_solr_xml(opts={})\n blanks = ['', [], ['']... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
q! method, she's an odd one, takes a query and returns an array of Row objects produced but also inserts those Row objects into this Row's (self) children it is also neccessary to pass the DBConnection object the query will be run against this actually pisses me off in that the whole point of having this class | def q!(query, db)
# build bindings from references
bindings = []
if query.references
query.references.each do |reference|
bindings << @row[reference]
end
end
# query
qry = query.query.gsub(''',"'").gsub('"','"') # replace single ... | [
"def drillthrough(query)\n RowSet.new @connection.create_statement.execute_query(query.to_s)\n end",
"def query_entries(sql, *sqlargs) # :yields: entry\n @db.execute(sql, *sqlargs) do |row|\n yield Entry.new.load_from_database_row(row)\n end\n end",
"def run(rows, query_logger: nil)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this is a mesh builder which returns this Row (self) as xml | def xml
base = REXML::Element.new(@name)
if @row.class == DBI::Row # only if we have a row otherwise return an empty xml node
# prime
context = nil
rowcontext = base
# loop through each column
@row.each_with_name do |val, colpath|
context = ... | [
"def to_xml(builder, include_dims=true)\n builder.grid do |xml|\n xml.cube\n dims_to_xml(xml) if include_dims\n xml.slices do |xml|\n xml.slice :rows => @row_count, :cols => @col_count do |xml|\n xml.data do |xml|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
watch comment user id list without `ignore` option | def watch_comment_by_user_ids
self.watch_comment_by_user_actions.where("action_option is null or action_option != ?", "ignore").pluck(:user_id)
end | [
"def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end",
"def notify_watchers(comment_id)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This action is called on ajax autocomplete call. It checks if user has rights to view data. URL parameters: [table] Table (collection) model name in lower case indicating table which will be searched. [id] Name of id key field that will be returned. Default is '_id' [input] Search data entered in input field. [search] ... | def autocomplete
# return '' unless session[:edit_mode] > 0 #
return render text: t('drgcms.not_authorized') unless dc_user_can(DcPermission::CAN_VIEW)
# TODO Double check if previous line works as it should.
table = params['table'].classify.constantize
id = [params['id']] || '_id'
# call method in class ... | [
"def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Action for restoring document data from journal document. | def restore_from_journal
# Only administrators can perform this operation
unless dc_user_has_role('admin')
return render inline: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json, formats: 'js'
end
# selected fields to hash
restore = {}
params[:select].each {|key,value| restore[key] = valu... | [
"def restore_from_journal\r\n # Only administrators can perform this operation\r\n unless dc_user_has_role('admin')\r\n return render plain: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json\r\n end\r\n # selected fields to hash\r\n restore = {} \r\n params[:select].each { |key,value| restore[key] = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Paste data from clipboard into text_area and update documents in destination database. This action is called twice. First time for displaying text_area field and second time ajax call for processing data. | def paste_clipboard
# Only administrators can perform this operation
return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin')
result = ''
respond_to do |format|
# just open new window to same url and come back with html request
format.html { return render('paste_clipbo... | [
"def paste_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n result = ''\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clears all session data related to login. | def clear_login_data
session[:edit_mode] = 0
session[:user_id] = nil
session[:user_name] = nil
session[:user_roles] = nil
cookies.delete :remember_me
end | [
"def clear_login_data\n self.account = nil\n self.timeout_at = nil\n self.logged_in = false\n end",
"def clear\n @session.delete :uid\n @session.delete :ulogin\n end",
"def clear_sessions \n sessions.each do |key, session|\n logger.info \"Closing: #{key}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes various variables when a new Crawler object is instantiated | def initialize(site)
puts "Rcrawl Version #{VERSION} initializing..."
@links_to_visit = Array.new
@visited_links = Array.new
@external_links = Array.new
@raw_html = Hash.new
@rules = RobotRules.new('Rcrawl')
@user_agent = "Rcrawl/#{VERSION} (http://rubyforge.org/projects/rcrawl/)"
@sites = Hash.... | [
"def initialize (params = {})\t\t\n\t\t@verbose=params.fetch(:verbose, false)\n\t\t@http_timeout=params.fetch(:http_timeout, 5000)\n\t\t@crawl_depth=params.fetch(:crawl_depth, 4)\n\t\t@crawl_page_limit=params.fetch(:crawl_page_limit, 1000)\n\t\t@max_parallel=params.fetch(:max_parallel, 40)\n\t\t# Discovered data st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
HTML processing module for raw HTML storage | def process_html(document)
# Add link and raw HTML to a hash as key/value
# for later storage in database
unless @raw_html.has_value?(document)
print "."
@raw_html[@document.base_uri.to_s] = document
end
end | [
"def html_parser; end",
"def handle_html b, html, plain_text\n html\n end",
"def post_process(html)\n html\n end",
"def process(markup)\n markup\n end",
"def content_from(html, url)\n \n def extract_pre_from(html)\n regex = /<pre.*?>.*?<\\/pre>/m\n pre_list = html.scan re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns last_name, first_name or just first_name if no last_name exists | def full_name_last_first
return self.first_name unless (self.last_name.length > 0)
return (self.last_name + ", " + self.first_name)
end | [
"def get_first_and_last_name\n if first_name && last_name && !first_name.empty? && !last_name.empty?\n [first_name, last_name]\n elsif description.present?\n [\n description.split(' ')[0],\n description.split(' ')[1]\n ]\n else\n [name[0..4], ''] # Return just the first 5 ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"Sand", "Water", "Fish", and "Sun" appear without overlapping (regardless of the case). Examples sum_of_a_beach("WAtErSlIde") ==> 1 sum_of_a_beach("GolDeNSanDyWateRyBeaChSuNN") ==> 3 sum_of_a_beach("gOfIshsunesunFiSh") ==> 4 sum_of_a_beach("cItYTowNcARShoW") ==> 0 | def sum_of_a_beach (beach)
(beach.scan(/sand|water|fish|sun/i) || []).length
end | [
"def countApplesAndOranges(start_house_loc, end_house_loc, apple_loc, orange_loc, apples, oranges)\n apples.collect! { |apple| apple_loc + apple }.keep_if { |apple| (start_house_loc..end_house_loc).include? apple }\n oranges.collect! { |orange| orange_loc + orange }.keep_if { |orange| (start_house_loc..end_house_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
2.Get all windmill id for a given wind Form. | def getmill
formid = Windmill.where(windformid: params[:id])
if formid.present?
render json: formid.as_json(only:[:no])
else
render json: {massage: 'Windform not found'}
end
end | [
"def getform\n\tgetform = Windmill.where(no: params[:no])\n\tif getform.present?\n render json: getform.as_json(only: [:windformid])\n\telse\n\t\trender json: {massage: 'No windfrom available in this id'}\n\tend\nend",
"def all_form_field_ids(form_id)\n fields = []\n field_maps[form_id].each... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
4.Get a wind form for a given wind mill id | def getform
getform = Windmill.where(no: params[:no])
if getform.present?
render json: getform.as_json(only: [:windformid])
else
render json: {massage: 'No windfrom available in this id'}
end
end | [
"def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend",
"def get_form(id)\n forms.find { |form| form['id'] == id }\n end",
"def form(form_id)\n if f = ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
executes easy_install command with the passed arguments | def ezy_install(*args)
easy_install *args
rescue NoMethodError => e
if pathname = which('easy_install')
self.class.commands :easy_install => pathname
easy_install *args
else
raise e
end
end | [
"def run(*args)\n require 'rubygems'\n optparse(*args)\n build_gems\n end",
"def run_install\n require 'fileutils'\n install_path = ARGV.shift || '.'\n FileUtils.mkdir_p install_path unless File.exists?(install_path)\n install_file \"#{CC_ROOT}/config/config.example.y... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /albums/1 DELETE /albums/1.json | def destroy
@album = @user.albums.find(params[:id])
@album.destroy
respond_to do |format|
format.html { redirect_to albums_url }
format.json { head :no_content }
end
end | [
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns absolute and movingaverage values of time to repair ()complete unplanned cards) since supplied time. | def time_to_repair(since_time, unit: :second)
total_repair_time = 0
total_repairs = 0
ttr = { point_values: {}, moving_averages: {} }
# Unplanned cards created after since_time, in order of creation.
cards.where('cards.created_at > ?', since_time).where('cards.label = ?', Card::LABEL_UNPLANNED).ord... | [
"def calculate_local_mean_time_of(h, ra, t)\n h + ra - (0.06571 * t) - 6.622\n end",
"def average_time()\n sum = 0\n if all_rides.length != 0\n all_rides().each { |ride| sum += ride.completion_time() }\n return sum / (all_rides().count)\n else\n return 0\n end \n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns absolute and movingaverage values of time between failures (creation of unplanned card and completion of last unplanned card) since supplied time. | def time_between_failures(since_time, unit: :second)
total_uptime = 0
total_failures = 0
tbf = { point_values: {}, moving_averages: {} }
# Unplanned cards created after since_time, in order of creation.
unplanned_cards = cards.where('cards.created_at > ?', since_time).where('cards.label = ?', Card:... | [
"def average_execution_time\n successes = Timberline.redis.xmembers(attr(\"success_stats\")).map { |item| Envelope.from_json(item)}\n times = successes.map do |item|\n if item.finished_processing_at\n item.finished_processing_at.to_f - item.started_processing_at.to_f\n elsif item.fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns hash containing timestamp and details from ServerLog and Card | def logs_and_cards_with_timestamp(since_time)
required_logs = server_logs.where('server_logs.created_at > ?', since_time).order('server_logs.created_at DESC')
required_cards = cards.where('cards.created_at > ?', since_time).order('cards.created_at DESC')
formatted_logs_info = required_logs.inject({}) do |s... | [
"def hash\n @timestamp.hash\n end",
"def hash\n data = [store.id, user.id, timestamp].join('$')\n Base64.encode64(OpenSSL::HMAC.digest('SHA256', store.private_key, data)).chomp\n end",
"def timestamp\n @packet.timestamp\n end",
"def calculate_checksum\n last_checksum = previous_event&.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse the command line arguments example 'c 23 f text.csv' = :count = 23 and :path = text.csv | def parse_arguments
OptionParser.new do |parser|
# parser.banner = "Usage: init.rb -c <integer>"
parser.on("-c", "--count COUNT", Integer, "Specify number of uuid's to generate") do |c|
@options[:count] = c
end
parser.on("-f", "--file FILE", "Specify path to save csv file example -f ... | [
"def parse_arg\n url = ARGV[1]\n base_url = url.split('/')[0..-2].join('/')\n channel_name = url.split('/')[-2]\n timestamp = (url.split('/')[-1][1..-1]).to_f / 1_000_000\n count = ARGV[2].to_i || 1000\n {\n token: ARGV[0], base_url: base_url, channel_name: channel_name,\n oldest: timestamp, count: coun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts account to a Struct::Account and sets it. | def account=(account)
@account = account ? Struct::Account.new(account) : account
end | [
"def set_account\n unless self.role_before_type_cast == 0\n key = Eth::Key.new\n data = SecureRandom.alphanumeric(8)\n unique_id = self.id.to_s\n\n Client.personal_import_raw_key(key.private_hex,data) rescue nil \n self.account_password = Encrypt_me.call(self.id,self.created_at,data) res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts user to a Struct::User and sets it. | def user=(user)
@user = user ? Struct::User.new(user) : user
end | [
"def user=(value)\n @user = value\n end",
"def user=(value)\n @user = value\n end",
"def set_user\n cu = @current_user\n unless cu.is_a?(User) && cu.persisted? && !cu.disabled\n raise \"Attempting to set user with non user: #{cu.nil? ? 'nil' : cu}\"\n end\n\n w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This sets the mode so OpenSSL knows to encrypt or decrypt, etc. | def initialize_cipher_for(mode)
@cipher.send mode
@cipher.key = @config['key']
@cipher.iv = @config['iv']
end | [
"def initialize_cipher_for(mode)\n @cipher.send mode\n @cipher.key = @config[:key]\n @cipher.iv = @config[:iv]\n end",
"def set_ssl(mode = true)\n @fu_ssl = mode\n end",
"def mode\n attributes.fetch(:mode) do\n Ably::Util::Crypto::DEFAULTS.fetch(:mode)\n end.downcase\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def set_defaults self.badge ||= " end we can call the concern here | def set_defaults
self.badge ||= Placeholder.image_generator(height: '150', width: '150')
end | [
"def set_default_values_skill\n self.badge ||= Placeholder.image_generator(height: 250, width: 250) # self.=> is similar to 'this' keyword. referencing this specific skill.\n #if main_image is nil put my default value else put users inputted image value\n #setting default values for images\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Agrega enlaces de notas | def enlaces_notas resumen
mensaje = ""
notas = resumen.notas.order "updated_at DESC"
if notas.count > 0
notas.each_with_index do |nota,i|
mensaje += link_nota nota
mensaje += "-" if i < resumen.notas.count-1
end
end
return mensaje
end | [
"def comisiones_asignadas\n asunto.comisiones if asunto\n end",
"def notificaciones\n end",
"def trg_soma_itens\n self.pedido.gerenciar_acoes\n self.pedido.save\n end",
"def solicitudes_atrasadas\n end",
"def guarda_nombres_comunes_todos\n dame_nombres_comunes_todos\n\n if x_nombre_comun_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Trigger auto approve update rescue task Author: Aniket Date: 06/07/2018 Reviewed By: | def trigger_auto_approve_update_rescue_task(user_extended_details_id)
BgJob.enqueue(
AutoApproveUpdateJob,
{
client_id: @client_id,
reprocess: 1,
user_extended_details_id: user_extended_details_id
}
)
Rails.logger.info("---- enqueue_job AutoApprove... | [
"def auto_approve!\n update_attribute(:approved_at,DateTime.now)\n update_attribute(:approved_by, User.APPLICATION)\n write_key!\n end",
"def auto_approve\n if !self.auto_approved && self.approval_status.nil?\n UserMailer.auto_approved_email(self).deliver\n self.auto_approved = true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the function param is defined as an output for the action in the ddl | def contains_output?(output)
@ddl[:output].keys.include?(output)
end | [
"def is_output_file?\n self.data_type == 'outputs' && self.parameter_type.match(/File/).present?\n end",
"def has_output?\n return !@outputs.empty?\n end",
"def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end",
"def available_action?(action_name); end",
"def validat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Similar to `case`, except it uses a `ResultPatternMatch` instead. | def result_case(target, destructure: false, &fn)
Qo::PatternMatchers::ResultPatternMatch
.new(destructure: destructure, &fn)
.call(target)
end | [
"def match_case\n return @match_case\n end",
"def case!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = CASE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at lin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new type of pattern matcher from a set of branches | def create_pattern_match(branches:)
Qo::PatternMatchers::PatternMatch.create(branches: branches)
end | [
"def build_matcher(options, whitelist_option, blacklist_option); end",
"def convert_to_branchsets( *patterns )\n\t\tself.log.debug \"Turning %d patterns into branchsets.\" % [ patterns.length ]\n\t\treturn patterns.collect do |pat|\n\t\t\tkey, val = pat.split( /\\s*=\\s*/, 2 )\n\t\t\tself.log.debug \" making a f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /refunds GET /refunds.json | def index
respond_to do |format|
format.html # index.html.erb
format.json { render json: @refunds }
end
end | [
"def refunds(options = nil)\n request = Request.new(@client)\n path = \"/transactions/\" + CGI.escape(@id) + \"/refunds\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n a = Array.new\n body = respo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /refunds/1 GET /refunds/1.json | def show
@refund = Refund.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @refund }
end
end | [
"def retrieve(id)\n @client.make_request(:get, \"refunds/#{id}\", MODEL_CLASS)\n end",
"def refunds(options = nil)\n request = Request.new(@client)\n path = \"/transactions/\" + CGI.escape(@id) + \"/refunds\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /refunds/new GET /refunds/new.json | def new
@refund = Refund.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @refund }
end
end | [
"def new\n @refund = Refund.new\n @refund.sale_item = SaleItem.find(params[:sale_item])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @refund }\n end\n end",
"def create\n @refund = Refund.new(params[:refund])\n\n respond_to do |format|\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /refunds/1 PUT /refunds/1.json | def update
@refund = Refund.find(params[:id])
respond_to do |format|
if @refund.update_attributes(params[:refund])
format.html { redirect_to @refund, notice: 'Refund was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n @refund = Refund.find(params[:id])\n\n respond_to do |format|\n if @refund.update_attributes(params[:refund])\n format.html { redirect_to @refund, notice: 'Refund was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /refunds/1 DELETE /refunds/1.json | def destroy
@refund = Refund.find(params[:id])
@refund.destroy
respond_to do |format|
format.html { redirect_to refunds_url }
format.json { head :no_content }
end
end | [
"def destroy\n @refund = Refund.find(params[:id])\n @refund.destroy\n\n respond_to do |format|\n format.html { redirect_to refunds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @refund_request = RefundRequest.find(params[:id])\n @refund_request.destroy\n\n respond_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This will only work for switching languages | def switch_language
language = locale('Español', 'English')
go_to language
end | [
"def language_switching\n translation_options\n\t\tif params[:locale_to_conf] == 'translation_addition'\n\t\t\trender :partial => 'translation_addition', :locals => { :translation_sections => @translation_sections }\n\t\telse\n\t\t\tyaml = YAML.load_file(\"#{RAILS_ROOT}/config/locales/#{params[:locale_to_conf]}.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set up the session context information, so that it gets logged with the job log lines also set up a unique tmpdir, which will get removed at the end of the job. | def configure_for_job(job)
previous_tmpdir = ENV.fetch("TMPDIR", nil)
self.class.running_job(job) do
dir = Dir.mktmpdir("job-#{job.id}-#{name.gsub(/[^\w.]/, ".")}-")
begin
ENV["TMPDIR"] = dir
yield
ensure
FileUtils.remove_entry(dir, true)
end
... | [
"def set_session_context\n @session_context = @app.build_session_context\n end",
"def temp_dir\n @temp_dir ||= Dir.mktmpdir\n end",
"def set_context_session\n if @object.project\n session[:current_project] = @object.project.id\n end\n if @object.context\n session[:current_context]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private: Used by insert to add new node in specified position. | def insert_at(data, position)
node, head, tail = set_insert_vars(data, position)
# before: head -> position
# after: head -> node -> position
head.tail = node
node.tail = position
position.head = node
node.head = head
@size += 1
end | [
"def insert_at(pos, node) end",
"def insert(idx, node)\n end",
"def add position, data\n node = Node.new position, data\n @insertion_order << position\n\n if @root.nil?\n @root = node\n @depth[:total] = 1\n @depth[:left] = 1\n @depth[:right] = 1\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine if there is a chapter after the current page | def next_chapter_path
return false unless current_page.is_a? Book::Chapter
current_page.next_chapter
end | [
"def whole_chapter?\n starting_bibleverse.verse.zero?\n end",
"def end_of_chapter\n end",
"def chapter?(node)\n attributes = node.attributes\n attributes && attributes['class'] &&\n attributes['class'].value =~ /chapter/\n end",
"def is_only_chapter?\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Atomically decrement integer value with key This is just syntactic sugar for calling increment with a negative value. This method also accepts negative amounts. | def decrement(key, amount = 1, options = {})
increment(key, -amount, options)
end | [
"def decrement(key, amt: 1)\n counts[key.to_sym] -= amt\n end",
"def decrement_value(key, value = 1)\n fail NotImplementedError\n end",
"def decrement_value(key, value = 1)\n @redis.decrby key, value\n end",
"def decrease key, amount=1\n @lock.write_sync do\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
display ingredients created or updated after the specified date. | def updated_after
update_selector { @ingredients = policy_scope(Ingredient.updated_after(@date)).order(:name) }
render :index
end | [
"def updated_after\n update_selector { @recipes = policy_scope(Recipe.updated_after(@date)).order(:name) }\n render :index\n end",
"def ingredients\n\n # render json of all ingredients in our DB\n render json: Ingredient.all.to_json(except: [:created_at, :updated_at])\n\n end",
"def display_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new label. | def create_label(project, name, color, options = {})
post("/projects/#{url_encode project}/labels", body: options.merge(name: name, color: color))
end | [
"def create_label(node)\n if node.attributes['id'] and @labels[node.attributes['id']]\n label = @labels[node.attributes['id']]\n else\n label = @factory.new_label\n @labels[node.attributes['id']] = label\n end\n \n # Read all defined data fields\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subscribes the user to a label to receive notifications | def subscribe_to_label(project, name)
post("/projects/#{url_encode project}/labels/#{url_encode name}/subscribe")
end | [
"def subscribe_to(username)\n action(username, 'subscribe')\n end",
"def subscribe_notification(student)\n notification = Notification.new(\"#{name} #{surname} subscribe to you\")\n student.notifications << notification\n end",
"def subscribe_to_group_label(group, name)\n post(\"/groups/#{ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /translated_lines GET /translated_lines.json | def index
@translated_lines = TranslatedLine.all
end | [
"def index\n @translation_lines = TranslationLine.all\n end",
"def show\n @translated_line = TranslatedLine.new\n @translated_lines = TranslatedLine.where(translation_code: @translation_line.translation_code)\n end",
"def create\n @translated_line = TranslatedLine.new(translated_line_params)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /translated_lines POST /translated_lines.json | def create
@translated_line = TranslatedLine.new(translated_line_params)
respond_to do |format|
if @translated_line.save
@translated_lines = TranslatedLine.where(translation_code: @translated_line.translation_code)
format.html { redirect_to @translated_line, notice: 'Translated line was s... | [
"def create\n @translation_line = TranslationLine.new(translation_line_params)\n\n respond_to do |format|\n if @translation_line.save\n format.html { redirect_to @translation_line, notice: 'Translation line was successfully created.' }\n format.json { render :show, status: :created, locatio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /translated_lines/1 PATCH/PUT /translated_lines/1.json | def update
respond_to do |format|
if @translated_line.update(translated_line_params)
format.html { redirect_to @translated_line, notice: 'Translated line was successfully updated.' }
format.json { render :show, status: :ok, location: @translated_line }
else
format.html { render :... | [
"def update\n respond_to do |format|\n if @translation_line.update(translation_line_params)\n format.html { redirect_to @translation_line, notice: 'Translation line was successfully updated.' }\n format.json { render :show, status: :ok, location: @translation_line }\n else\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /translated_lines/1 DELETE /translated_lines/1.json | def destroy
@translated_line.destroy
respond_to do |format|
format.html { redirect_to translated_lines_url, notice: 'Translated line was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @translation_line.destroy\n respond_to do |format|\n format.html { redirect_to translation_lines_url, notice: 'Translation line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /mx_assessments POST /mx_assessments.json | def create
@mx_assessment = MxAssessment.new(mx_assessment_params)
# byebug
respond_to do |format|
if @mx_assessment.save
# format.html { redirect_to @mx_assessment, notice: 'Mx assessment was successfully created.' }
# format.json { render action: 'show', status: :created, location: ... | [
"def create_assessment() \n new_assessment = assessment(\n \"rand1\", \n [assessment_identification_code(\"Other\",\"Some Identification\")],\n 1\n )\n \n url = REST_URL + 'assessments'\n response = RestClient.post url, new_assessment.to_json, headers\n location = response.headers[:l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /mx_assessments/1 PATCH/PUT /mx_assessments/1.json | def update
respond_to do |format|
if @mx_assessment.update(mx_assessment_params)
format.html { redirect_to @mx_assessment, notice: 'Mx assessment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render ... | [
"def update\n @assessment = Assessment.find(params[:id])\n\n respond_to do |format|\n if @assessment.update_attributes(params[:assessment])\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /mx_assessments/1 DELETE /mx_assessments/1.json | def destroy
@mx_assessment.destroy
respond_to do |format|
format.html { redirect_to mx_assessments_url }
format.json { head :no_content }
end
end | [
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to assessments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment = Assessment.find(params[:id])\n @assessment.destroy\n\n respond_to do |format|\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new plane to the game by adding it to list of planes | def add_plane()
planes << Plane.new(
gen_location,
0,
width,
height,
gen_speed(),
true
)
end | [
"def add_plane(aPlane, recache = true)\n self.clip_planes << aPlane\n recache_visible_atoms if recache\n aPlane\n end",
"def add_section_plane(plane)\n end",
"def add new_planet\n @planets << new_planet\n end",
"def add_planet (planet)\n @planets << planet\n end",
"def setup_add_plane\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a random speed for a plane | def gen_speed
rand + 15.0
end | [
"def random_turn deg\n rand(deg) - (deg/2)\n end",
"def change_speed\n @statistics[:speed_changes] += 1\n # pick a coordination to change speed for\n @changed_coord = @coordinations.rand\n @previous_speed = @current_speed[@changed_coord]\n @current_speed[@changed_coord] = @previous_speed + SPEE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see if you can place a plane so that this x coordinate does not collide horizontally with any plane | def can_place(position)
planes.none? do |plane|
plane.wings.in_horizontal_range(BoundingBox.new(position, position + width, 0, 0))
end
end | [
"def intersect_plane?(plane)\n not parallel_to_plane? plane\n end",
"def point_is_on_plane?(point)\n (@x_coefficient * point.x + @y_coefficient * point.y + @z_coefficient * point.z + @free_coefficient).equal?(0)\n end",
"def is_on_plane?(plane)\n plane.substitute(self) == 0\n end",
"def in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether the given line type was parsed from the log file for this request | def has_line_type?(line_type)
return true if @lines.length == 1 && @lines[0][:line_type] == line_type.to_sym
@lines.detect { |l| l[:line_type] == line_type.to_sym }
end | [
"def has_line_type?(line_type)\n return true if @lines.length == 1 && @lines[0][:line_type] == line_type.to_sym\n @lines.detect { |l| l[:line_type] == line_type.to_sym }\n end",
"def known_line_type?(line)\n line_key = segment_peek(line)\n @segment_keys.include?(line_key)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this request does not yet contain any parsed lines. This should only occur during parsing. An empty request should never be sent to the aggregators | def empty?
@lines.length == 0
end | [
"def is_empty()\n @requests.empty?\n end",
"def empty?\n @source_lines.empty?\n end",
"def empty?\n line.empty?\n end",
"def valid?\n !@requests.empty?\n end",
"def has_lines?\n !@lines.empty?\n end",
"def empty?\n load # make sure we have det... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether this request is completed. A completed request contains both a parsed header line and a parsed footer line. Not that calling this function in single line mode will always return false. | def completed?
header_found, footer_found = false, false
@lines.each do |line|
line_def = file_format.line_definitions[line[:line_type]]
header_found = true if line_def.header
footer_found = true if line_def.footer
end
header_found && footer_found
end | [
"def completed?\n header_found, footer_found = false, false\n @lines.each do |line|\n line_def = file_format.line_definitions[line[:line_type]]\n header_found = true if line_def.header\n footer_found = true if line_def.footer\n end\n header_found && footer_found\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the first timestamp encountered in a request. | def timestamp
first(:timestamp)
end | [
"def timestamp\n @request.timestamp\n end",
"def request_time\n @params[:request_timestamp]\n end",
"def get_request_timestamp\n\t\treturn @transport.get_path(\"meta\",\"datetime\")\n\tend",
"def earliest\n solr_response = @controller.repository.search({:fl => @timestamp_field, :sort => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get 5 random queries, across the given object types | def get_random_quick_queries(types)
allTypes = types.collect {|type| type.get_quick_queries}.flatten
prng = Random.new
random_qq = allTypes.sort {|item1, item2| prng.rand(-1 .. 1) }.slice(0, 5)
random_qq.collect {|qq| render_quick_query(qq)}
end | [
"def random_query\n # Use a fake query\n # TODO: better random queries\n 'query ' + (rand*5000).to_i.to_s\nend",
"def find_mru_entity_types(entity_type, login, amount = 10, already_chosen_ids=[])\n klass = Inflector.constantize(entity_type.entity_type.to_s.camelize)\n \n #This is the case where we ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bags or /bags.json | def index
@bags = Bag.all
end | [
"def tagList()\n http, req = initReq(\"tags/\")\n JSON.parse(http.request(req).body)\nend",
"def all_tags\n request(:get,\"/tags\")\n end",
"def index\n @dags = Dag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dags }\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /bags/1 or /bags/1.json | def update
respond_to do |format|
if @bag.update(bag_params)
format.html { redirect_to @bag, notice: "Bag was successfully updated." }
format.json { render :show, status: :ok, location: @bag }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { ... | [
"def update\n @bag = Bag.find(params[:id])\n\n respond_to do |format|\n if @bag.update_attributes(params[:bag])\n format.html { redirect_to bags_path, notice: 'Bag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /bags/1 or /bags/1.json | def destroy
@bag.destroy
respond_to do |format|
format.html { redirect_to bags_url, notice: "Bag was successfully destroyed." }
format.json { head :no_content }
end
end | [
"def destroy\n @bag = Bag.find(params[:id])\n @bag.destroy\n\n respond_to do |format|\n format.html { redirect_to bags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bag = Bag.find(params[:id])\n @bag.destroy\n\n respond_to do |format|\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the `sinatra.commonlogger` variable to `true` in the Rack environment before passing the request to lowwer middlewares and the app. This ensures that any `::Rack::CommonLogger` instances (as well as all `::Sinatra::CommonLogger` instances) in the same middleware stack will become silent and not log anything. This i... | def on_request(env)
env['sinatra.commonlogger'] = true
super
end | [
"def log(env, *args)\n unless env['sinatra.commonlogger'.freeze] &&\n env['rackstash.logger'.freeze].is_a?(::Rackstash::Logger)\n super\n end\n end",
"def shush_rack\n ::Rack::CommonLogger.class_eval do\n def call_with_shushed_logs(env)\n if LogShusher.shus... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Partially order the fixed nodes in a graph, so that each has a sequence number which can be compared. If one node must come before another then it will have a lower sequence number. | def partially_order(graph)
# Create a work list of the fixed nodes.
to_sequence = graph.all_nodes.select(&:fixed?)
# Keep going until the work list is empty.
until to_sequence.empty?
node = to_sequence.shift
# We're only interested in the control inputs to the node.
... | [
"def order!\n hai \"realizing pass DAG into a concrete order\"\n\n graph = build_graph!\n ordered = []\n node_set = []\n\n # Our initial node set consists of only nodes that don't have a predecessor.\n graph.nodes.each do |node|\n next if graph.edges.any? { |e| e[1] == node }\n\n node_se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Globally schedule a graph, meaning to anchor all floating nodes to a fixed node. All fixed nodes are part of a basic block, so globally scheduling also puts all floating nodes into a basic block. | def global_schedule(graph)
# Create a work list of the floating nodes.
to_schedule = graph.all_nodes.select {|n| n.floating? && n.op != :immediate }
# Keep going until the work list is empty.
until to_schedule.empty?
node = to_schedule.shift
# Are we ready to schedule this no... | [
"def local_schedule(graph)\n # Find all basic blocks and locally schedule them.\n\n graph.all_nodes.each do |node|\n if node.begins_block?\n locally_schedule_block node\n end\n end\n end",
"def schedule_every (freq, schedulable=nil, params=nil, &block)\n\n ssche... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A node is ready to be globally scheduled if all outputs have themselves been globally scheduled. | def ready_to_schedule?(node)
# Ready to globally schedule
node.outputs.to_nodes.all? do |i|
globally_scheduled?(i)
end
end | [
"def globally_scheduled?(node)\n node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:global_schedule)\n end",
"def locally_scheduled?(node)\n node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:local_schedule)\n end",
"def ready(bot, scheduler)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A node is globally scheduled if it was fixed anyway or we've scheduled it. | def globally_scheduled?(node)
node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:global_schedule)
end | [
"def ready_to_schedule?(node)\n # Ready to globally schedule\n\n node.outputs.to_nodes.all? do |i|\n globally_scheduled?(i)\n end\n end",
"def locally_scheduled?(node)\n node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:local_schedule)\n end",
"def glob... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sort a list of candidates in decreasing sequence number. | def sort_candidates(candidates)
candidates.sort_by { |candidate|
anchor = fixed_anchor(candidate)
sequence = anchor.props[:sequence]
raise unless sequence
sequence
}.reverse
end | [
"def sort_by_rank\n\t\tsorted = @candidates.sort{ |x,y| y.votes <=> x.votes }\n\t\t@candidates\n\tend",
"def stable_sort_by(list); end",
"def sort_candidates(candidates)\n candidates.sort_by do |candidate|\n [candidate[:years_of_experience], candidate[:github_points]]\n end.reverse\nend",
"def sort_quest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Locally schedule a graph, which means within each basic block decide a single order to run the nodes, which no ambiguity left. | def local_schedule(graph)
# Find all basic blocks and locally schedule them.
graph.all_nodes.each do |node|
if node.begins_block?
locally_schedule_block node
end
end
end | [
"def global_schedule(graph)\n # Create a work list of the floating nodes.\n\n to_schedule = graph.all_nodes.select {|n| n.floating? && n.op != :immediate }\n\n # Keep going until the work list is empty.\n\n until to_schedule.empty?\n node = to_schedule.shift\n\n # Are we ready to s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all the nodes in a basic block, given the first node. | def nodes_in_block(first_node)
# We're going to do a depth-first search of the graph from the first
# node, following control flow edges out, and global schedule edges in,
# and stopping when we find a node that ends a basic block such as a
# branch.
worklist = [first_node]
block = ... | [
"def select_nodes(&block); end",
"def select_nodes!(&block); end",
"def find_all_blocks(node, block_name)\n return if node.nil?\n\n blocks = node.each_descendant(:block).select { |block_node| block_name == block_node.method_name }\n return blocks unless block_given?\n\n blocks.each d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A node is locally scheduled if it's fixed or we have locally scheduled it. | def locally_scheduled?(node)
node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:local_schedule)
end | [
"def globally_scheduled?(node)\n node.fixed? || node.op == :immediate || node.outputs.output_names.include?(:global_schedule)\n end",
"def ready_to_schedule?(node)\n # Ready to globally schedule\n\n node.outputs.to_nodes.all? do |i|\n globally_scheduled?(i)\n end\n end",
"def sc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Linearize a graph into a single linear sequence of operations with jumps and branches. | def linearize(graph)
# The basic blocks.
blocks = []
# Details of the basic block that contain the finish operation which
# won't be added to the list of basic blocks until the end.
first_node_last_block = nil
last_block = nil
# Two maps that help us map between n... | [
"def sequence_nodes(graph)\n # Note that this algorithm is very wasteful! It allocates two sides of a branch\n # the same sequence numbers. This means that to the linear scan values on both\n # sides of the branch and internal to those branches appear to be live at the\n # same time and they won... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Publish a document object to the web. If content is a StructuredArticle stored as json, and publisDate is note set, then publishDate will be set to current time. Publishes a object by performing a PUT request to object.url with object.content and then performing a PROPPATCH request to object.url with object.properties ... | def publish(object)
write(object)
uri = @uri.merge(object.url)
if(object.is_a? StructuredArticle) then
if(object.publishDate == nil)then
time = Time.now.httpdate.to_s
prop = '<v:publish-date xmlns:v="vrtx">' + time + '</v:publish-date>'
self.proppatch(uri, prop)
... | [
"def publish!\n publish\n save!\n end",
"def publish!\r\n publish\r\n save!\r\n end",
"def publish!\n publish\n save!\n end",
"def publish_impl(publish_target, digital_object)\n digital_object_pid = digital_object_pids(digital_object).first\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Utilities Convert norwegian date to Time object with a forgiven regexp TODO: Move this somewhere. Examples: t = norwegian_date('1.1.2010') t = norwegian_date('22.01.2010') t = norwegian_date('22.01.2010 12:15') t = norwegian_date('22.01.2010 12:15:20') | def norwegian_date(date)
if /\A\s*
(\d\d?).(\d\d?).(-?\d+)
\s?
(\d\d?)?:?(\d\d?)?:?(\d\d?)?
\s*\z/ix =~ date
year = $3.to_i
mon = $2.to_i
day = $1.to_i
hour = $4.to_i
min = $5.to_i
sec = $6.to_i
# puts "Debug: #{year} #{mon} ... | [
"def convertTime(time)\n time.gsub!(\"P\", \"\")\n\n if (time.match(\"0DT\"))\n time.gsub!(\"0DT\", \"\")\n else\n time.gsub!(\"DT\", \" Days \")\n end\n\n if (time.match(\"0H\"))\n time.gsub!(\"0H\", \"\")\n else\n time.gsub!(\"H\", \"h \")\n end\n\n time.gsub!(\"M\", \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When changing the response_reset_date, we must go through and update the status_cache for all members of the committee. | def update_member_status_caches!
if response_reset_date_changed?
members.find_in_batches do |member_group|
member_group.each {|member| member.update_status_cache! }
end
end
end | [
"def pending_account_reset_visited\n track_event('Pending account reset visited')\n end",
"def response_lifetime_date\n response_reset_date || CommitteeMember::DEFAULT_RESPONSE_LIFETIME.ago\n end",
"def reset_events_cache\n Event.where(target_id: self.id, target_type: 'Issue').\n order('id DESC'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If this Committee has the response_reset_date set, return that. Otherwise, calculate this based on the DEFAULT_LIFETIME_RESPONSE. | def response_lifetime_date
response_reset_date || CommitteeMember::DEFAULT_RESPONSE_LIFETIME.ago
end | [
"def responded_recently?(response_lifetime = DEFAULT_RESPONSE_LIFETIME)\n if committee && committee.response_reset_date\n last_user_response_at > committee.response_reset_date rescue false\n else\n Time.now - last_user_response_at < response_lifetime rescue false\n end\n end",
"def renewed_dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /success_cases GET /success_cases.xml | def index
@success_cases = SuccessCase.all.paginate(:page => params[:page], :per_page => 10)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @success_cases }
end
end | [
"def index\n @cases = Case.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cases }\n end\n end",
"def show\n @success_case = SuccessCase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /success_cases/1 GET /success_cases/1.xml | def show
@success_case = SuccessCase.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @success_case }
end
end | [
"def index\n @success_cases = SuccessCase.all.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @success_cases }\n end\n end",
"def index\n @cases = Case.all\n\n respond_to do |format|\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /success_cases/new GET /success_cases/new.xml | def new
@success_case = SuccessCase.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @success_case }
end
end | [
"def new\n @test_case = TestCase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_case }\n end\n end",
"def new\n @case = Case.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @case }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /success_cases POST /success_cases.xml | def create
@success_case = SuccessCase.new(params[:success_case])
respond_to do |format|
if @success_case.save
format.html { redirect_to(@success_case, :notice => 'Success case was successfully created.') }
format.xml { render :xml => @success_case, :status => :created, :location => @suc... | [
"def create\n @testcase = Testcase.new(params[:testcase])\n\n respond_to do |format|\n if @testcase.save\n flash[:notice] = 'Testcase was successfully created.'\n format.html { redirect_to(testcases_url) }\n format.xml { render :xml => \"testcases\", :status => :created, :location =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /success_cases/1 PUT /success_cases/1.xml | def update
@success_case = SuccessCase.find(params[:id])
respond_to do |format|
if @success_case.update_attributes(params[:success_case])
format.html { redirect_to(@success_case, :notice => 'Success case was successfully updated.') }
format.xml { head :ok }
else
format.html... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @test... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /success_cases/1 DELETE /success_cases/1.xml | def destroy
@success_case = SuccessCase.find(params[:id])
@success_case.destroy
respond_to do |format|
format.html { redirect_to(success_cases_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @test_case = TestCase.find(params[:id])\n @test_case.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_cases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to(te... | {
"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.