query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
GET /api/v1/user_to_progresses GET /api/v1/user_to_progresses.json | def index
@api_v1_user_to_progresses = Api::V1::UserToProgress.all
end | [
"def index\n @progresses = @task.progresses\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @progresses }\n end\n end",
"def index\n @api_v1_progresses = Api::V1::Progress.all\n end",
"def index\n @progresses = Progress.all\n end",
"def index\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /api/v1/user_to_progresses/1 DELETE /api/v1/user_to_progresses/1.json | def destroy
@api_v1_user_to_progress.destroy
respond_to do |format|
format.html { redirect_to api_v1_user_to_progresses_url, notice: 'User to progress was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @ipaddr.destroy\n respond_to do |format|\n format.html { redirect_to ipaddrs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @progress = @task.progresses.find(params[:id])\n @progress.destroy\n\n respond_to do |format|\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /supports GET /supports.json | def index
@supports = Support.all
end | [
"def index \n @supports = Support.all\n end",
"def index\n @functionalsupports = FunctionalSupport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @functionalsupports }\n end\n end",
"def supports_json?; end",
"def supports_json?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wait for a request, process it, publish the response and exit | def process_request!
job = Thread.current[:redis_blocking].brpop(Scales::Storage::REQUEST_QUEUE, 0).last
id, response = nil, nil
Thread.current[:post_process_queue] = []
id, response = process!(job)
post_process!(job)
@status.put_response_in_queue!(response)
... | [
"def process!\n @start = Time.now\n http = EventMachine::HttpRequest.new(url,\n connect_timeout: timeout,\n inactivity_timeout: timeout,\n )\n\n @request = http.public_send(method,\n request_options\n )\n\n @request.callback { @completed = true; @runtime = Time.now... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows adding a new message to the Flash hash in controllers by providing a single type argument which will use translations to build the message. There are 2 ways of storing flash messages in translations : The first is to place translations under : flash... Ex: flash.tasks.create.success The second is to use a shared... | def flash_message(type, options = {})
controller_path = "flash.#{ params[:controller] }.#{ params[:action] }.#{ type }"
shared_path = "flash.shared.#{ params[:action] }.#{ type }"
options[:model] = options[:model].class.model_name.human if options[:model]
options[:default] = I18n.t(shared_path, options... | [
"def flash_message(type, text)\n flash[type.to_sym] ||= []\n flash[type.to_sym] << text\n end",
"def flash_message(type, message)\n flash[type] ||= []\n flash[type] << message\n end",
"def add_flash_message(type, msg)\n if flash[type].nil?\n flash[type] = msg\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Defines the conditions for a document to be Lazyable. doc the Jekyll::Document or Jekyll::Page Returns true if the doc is written & is HTML. | def Lazyable?(doc)
(doc.is_a?(Jekyll::Page) || doc.write?) &&
doc.output_ext == ".html" || (doc.permalink && doc.permalink.end_with?("/"))
end | [
"def processable?(doc)\n\t\t\t\t(doc.is_a?(Jekyll::Page) || doc.write?) &&\n\t\t\t\t\tdoc.output_ext == \".html\" || (doc.permalink&.end_with?(\"/\"))\n\t\t\tend",
"def tagable?(doc)\n (doc.is_a?(Jekyll::Page) || doc.write?) &&\n doc.output_ext == \".html\" || (doc.permalink&.end_with?(\"/\"))\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /admin/shirt_colors/new GET /admin/shirt_colors/new.json | def new
@shirt_color = ShirtColor.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @shirt_color }
end
end | [
"def create\n @shirt_color = ShirtColor.new(params[:shirt_color])\n\n respond_to do |format|\n if @shirt_color.save\n format.html { redirect_to admins_shirt_colors_url, notice: 'Shirt color was successfully created.' }\n format.json { render json: @shirt_color, status: :created, location: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/shirt_colors POST /admin/shirt_colors.json | def create
@shirt_color = ShirtColor.new(params[:shirt_color])
respond_to do |format|
if @shirt_color.save
format.html { redirect_to admins_shirt_colors_url, notice: 'Shirt color was successfully created.' }
format.json { render json: @shirt_color, status: :created, location: @shirt_color... | [
"def create\n respond_to do |format|\n require 'rest-client'\n response = RestClient.post('localhost:3001/colores/', color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n format.html { redirect_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /admin/shirt_colors/1 PUT /admin/shirt_colors/1.json | def update
@shirt_color = ShirtColor.find(params[:id])
respond_to do |format|
if @shirt_color.update_attributes(params[:shirt_color])
format.html { redirect_to admins_shirt_colors_url, notice: 'Shirt color was successfully updated.' }
format.json { head :no_content }
else
fo... | [
"def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'+@color.id.to_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/shirt_colors/1 DELETE /admin/shirt_colors/1.json | def destroy
@shirt_color = ShirtColor.find(params[:id])
@shirt_color.destroy
respond_to do |format|
format.html { redirect_to admins_shirt_colors_url }
format.json { head :no_content }
end
end | [
"def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'+@color.id.to_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
before_action :new, :check_if_student GET /books GET /books.json | def index
check_if_student
@books = Book.all
end | [
"def create\n @student = Student.find(params[:student_id])\n @student_book = @student.student_books.new(student_book_params)\n authorize! :create, @student_book\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to student_student_books_path(@student), notice: 'Student bo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the next HttpUrl that is neither invalid nor already fetched. If there are no more URLs, it returns +nil+. | def get_next_url
while true
unless url = @node_manager.dequeue_url
# there are currently no further URLs in the queue
return nil
end
unless http_url = HttpUrl.parse(url)
@node_manager.log_error :invalid_url, url.inspect
next
end
if @node_manager.has_f... | [
"def get_next_url\n while true\n unless url = dequeue_url()\n # there are currently no further URLs in the queue\n return nil\n end\n\n unless http_url = HttpUrl.parse(url)\n log_error :invalid_url, url.inspect \n next\n end\n\n if has_file?(http_url.to_filena... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the group with the most actions and return an int h where: h = (max_actions + pad) factor the pad represents the top two header lines in the rendered post it the factor represents the line height of the action list | def compute_height(pad = 2, factor = 13)
(max_actions + pad) * factor
end | [
"def divide_into_equal_groups(controller_actions, num_groups)\n total_lines = controller_actions.values.sum\n lines_per_group = total_lines / num_groups\n\n action_pile = controller_actions.dup\n\n grouping = num_groups.times.each_with_object({}) do |group_num, hash|\n line_count_in_group = 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to find edge from 2 vertices | def findEdge(vertex1, vertex2)
visualedges = @visualGraph.visual_edges
visualedges.each do |edge|
if edge.v1.id == vertex1 && edge.v2.id == vertex2
# edge from vertex1 to vertex2
return edge
elsif edge.v2.id == vertex1 && edge.v1.id == vertex2
# edge from vertex2 to vertex1
... | [
"def get_edge vertex_a, vertex_b\n @edges.select{ |e| (e.vertices.include? vertex_a) && (e.vertices.include? vertex_b) }.first\n end",
"def edge a, b\n # works for both digraph and undirected graph\n @edges[a].each{|e| return e if e.connects? a, b}\n end",
"def edge a, b\n @edges[a] and @edges[a][... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stretch the children layouts to fill the gaps, remove redundant spaces inside the parent layout | def stretch_children_layouts(parent_template, parent_width, parent_height, lines)
total_height = 0
lines.each_with_index do |line, line_index|
desired_height =
if line_index == lines.length - 1
parent_height - total_height
else
line.map { |_child_template,... | [
"def layout\n # This assumes that the container overlaps all the children.\n\n # Move all children if we have moved.\n @children.each.with_index do |child, index|\n child.x = padding_left + x\n child.y = padding_top + y\n end\n\n # Make us as wrap around the largest child.\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /sections or /sections.json | def create
@section = Section.new(section_params)
if @section.save
render json: SectionSerializer.new(@section)
else
render json: @section.errors, status: :unprocessable_entity
end
end | [
"def create\n @section = Section.new(section_params)\n\n if @section.save\n render :show, status: :created, location: @section\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end",
"def create\n @section = Section.new(section_params) \n if @section.save\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /commodities GET /commodities.json | def index
@commodities = Commodity.all
if params[:search].present?
@commodities = @commodities.query(params[:search].to_s)
end
@commodities = @commodities.page(params[:page])
respond_to do |format|
format.html
format.js {}
format.json {
render json: {:commodities =... | [
"def index\n @commodities = PlanetaryCommodity.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commodities }\n end\n end",
"def index\n @commodities = Commodity.all\n end",
"def index\n @categories = Category.all\n @commodities = curr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert compressed range proof using inner product. | def to_compress
a = lx.dup
b = rx.dup
ts = transcript.dup
w = ts.challenge_scalar("w")
q = GENERATOR_BJ * w
a_sum = a.dup
b_sum = b.dup
g_sum = vec_g.dup
h_sum = vec_h2.dup
terms = []
until a_sum.length == 1
a_lo = []
... | [
"def transform_bin\n @productions.each do |p|\n next unless p.length > 2\n\n next_sym = nil\n count = p.rhs.length - 2\n p.rhs[1..].reverse.each do |x|\n if next_sym.nil?\n next_sym = x\n else\n name = \"#{x}_#{next_sym}\"\n name = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /shipping_options/1 GET /shipping_options/1.json | def show
@shipping_option = ShippingOption.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @shipping_option }
end
end | [
"def shipping_options\n Hash.new\n end",
"def invoice_get_all_shipping_options\n response = xmlrpc('Invoice.getAllShippingOptions')\n end",
"def new\n @shipping_option = ShippingOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /shipping_options/new GET /shipping_options/new.json | def new
@shipping_option = ShippingOption.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @shipping_option }
end
end | [
"def new\n @shipping_method = @shop.shipping_methods.build\n\n respond_to do |format|\n format.html \n format.json { render json: @shipping_method }\n end\n end",
"def create\n @shipping_option = ShippingOption.new(params[:shipping_option])\n\n respond_to do |format|\n if @shipp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /shipping_options POST /shipping_options.json | def create
@shipping_option = ShippingOption.new(params[:shipping_option])
respond_to do |format|
if @shipping_option.save
format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully created.' }
format.json { render json: @shipping_option, status: :created, locat... | [
"def shipping_options\n Hash.new\n end",
"def create\n @ebay_shipping_service_option = Ebay::ShippingServiceOption.new(ebay_shipping_service_option_params)\n\n respond_to do |format|\n if @ebay_shipping_service_option.save\n format.html { redirect_to @ebay_shipping_service_option, notice... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /shipping_options/1 PUT /shipping_options/1.json | def update
@shipping_option = ShippingOption.find(params[:id])
respond_to do |format|
if @shipping_option.update_attributes(params[:shipping_option])
format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully updated.' }
format.json { head :no_content }
el... | [
"def update\n @shipping_option = ShippingOption.find(params[:id])\n\n respond_to do |format|\n if @shipping_option.update_attributes(params[:shipping_option])\n flash[:notice] = 'ShippingOption was successfully updated.'\n format.html { redirect_to :controller => 'shipping_options' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /shipping_options/1 DELETE /shipping_options/1.json | def destroy
@shipping_option = ShippingOption.find(params[:id])
@shipping_option.destroy
respond_to do |format|
format.html { redirect_to shipping_options_url }
format.json { head :no_content }
end
end | [
"def destroy\n @shipping_option = ShippingOption.find(params[:id])\n @shipping_option.destroy\n\n respond_to do |format|\n format.html { redirect_to :controller => 'shipping_options' }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ebay_shipping_service_option.destroy\n resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
order the rectangles as per assumptions | def order_rectangles(rec1, rec2)
r1 = Rectangle.new(rec1)
r2 = Rectangle.new(rec2)
r1 = order_coord_of_rectangles(r1)
r2 = order_coord_of_rectangles(r2)
if r2.A.X < r1.A.X
temp = r1
r1 = r2
r2 = temp
end
ret = [r1, r2]
return ret
end | [
"def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,80,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[1] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get a script session id | def get_session_id
@agent.get( @root_url + '/dwr/engine.js') do |page|
@session_id = extract_session_id(page.body)
end
end | [
"def sessionid\n command[:sessionid]\n end",
"def session_id\n session[:uid] rescue nil\n end",
"def get_id\n @sessionid\n end",
"def get_session_pid\n cmd_exec(\"echo $PPID\").to_s\n end",
"def id\n @id ||= scgi.session_id\n end",
"def get_SessionID()\n \t return @ou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find the ID of the top headlines element, which is in a script element that looks like this: DM.has("r0c1p15", "headlines"); | def get_headline_div_id(page)
script = page.parser.css('script').select { |script| script.text =~ /DM\.has\(\".*\"\,\ \"headlines\"\)/ }
/DM\.has\(\"(.*)\"\,\ \"headlines\"\)/.match(script[0].to_s)[1]
end | [
"def read_head_id\n File.read(head_path).strip if File.exists?(head_path)\n end",
"def status_dom_id\n 'topHeaderSmallNavi'\n end",
"def test_heading_top()\n gen1 = XhtmlReportGenerator::Generator.new\n gen1.create_layout(\"\")\n el = gen1.heading_top() {\"test\"}\n assert(el != nil, \"headi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
extract article id from the uri | def get_article_id(urn)
/\/(.*)\/article\-(.*)\/.*/.match(urn)[2].to_i
end | [
"def id_from_uri(uri)\n id = URI.parse(uri)\n # /notes/abc\n if id.path[0,1] == \"/\"\n id.path.split(\"/\")[2]\n else\n id.to_s\n end\n end",
"def find_id(uri)\n Addressable::URI.parse(uri).basename\n end",
"def mapzen_id(uri)\n uri.split(\"/\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
extract a meta tag value from the page | def get_metatag(page, tag)
page.parser.css("meta[name='#{tag}']").first['content']
end | [
"def content_for_meta_tag(attribute_selector, html)\n html.xpath(\"//head/meta[@#{attribute_selector}]/@content\").first.try(:content)\n end",
"def extract_meta\n meta = {}\n @page.xpath('//head/meta').each do |field|\n key = field.keys.find { |f| f != 'content' }.first\n meta[field[ke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /ad_domains/1 PATCH/PUT /ad_domains/1.json | def update
authorize! :update, @ad_domain
respond_to do |format|
if @ad_domain.update(ad_domain_params)
format.html { redirect_to @ad_domain, notice: 'Active Directory domain was successfully updated.' }
format.json { render :show, status: :ok, location: @ad_domain }
else
for... | [
"def update\n @domain = Domain.find(params[:id])\n\n if @domain.update(domain_params)\n head :no_content\n else\n render json: @domain.errors, status: :unprocessable_entity\n end\n end",
"def update\n update_and_respond(@domain, domain_params)\n end",
"def update\n @dns_domain = Dn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If key is absent, save the result of calling the block. If key is present, block is never called. Ex: rt_store.set(url) do fetcher.get url will only be called if url isn't in rt_store end | def set key, force=nil, &block
return if (!force) && cache.include?(key)
cache_val, store_val = block.call()
return unless cache_val
cache.set_nr key, cache_val # update cache
store << store_val # save value
self.misses += 1 # track the cache miss
... | [
"def fetch(key, options = {})\n @store.fetch(key) { @store[key] = yield }\n end",
"def do_cached( key, &block )\n \n # have a look in the cache\n value = fetch( key )\n\n # Cache HIT?\n return value unless value.nil?\n\n # Cache MISS : execute the block\n value = block.call( key )\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
================== sending invoices ============================= | def send_invoices
change_date
@options = session[:invoice_options] || {}
[
:s_username, :s_first_name, :s_last_name, :s_number, :s_period_start, :s_period_end,
:s_issue_date, :s_sent_email, :s_sent_manually, :s_paid, :s_invoice_type
].each do |key|
@options[key] = params[key].try(:to_... | [
"def send_invoice(params = {})\n commit(Ebay::Requests::SendInvoice, params)\n end",
"def send_freshbooks_invoice!\n raise SignalCloud::ClientInvoiceNotCreatedError.new unless self.has_invoice?\n \n response = FreshBooks.account.invoice.sendByEmail( invoice_id: self.freshbooks_invoice_id )\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Based on what params user selected or if they were not passed based on params saved in session return user_id, that should be filtered for financial statements. if user passed clear as param return nil Params +session_options+ hash including :user_id, might be nil Return +user_id+ integer or nil | def financial_statements_user_id(session_options)
not_params_clear = !params[:clear]
params_user_id, session_user_id = [params[:s_user_id], session_options.try(:[], :s_user_id)]
if current_user.usertype == 'user'
user_id = current_user_id
elsif params_user_id && not_params_clear
user_id = p... | [
"def financial_statements_user_id(session_options)\n if current_user.usertype == 'user'\n user_id = current_user.id\n elsif params[:user_id] and not params[:clear]\n user_id = params[:user_id]\n elsif session_options and session_options[:user_id] and not params[:clear]\n user_id = session_op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Based on what params user selected or if they were not passed based params saved in session return status, that should be filtered for financial statements. Params +session_options+ hash including :status, might be nil Returns +status+ string, one of valid_status_values, by default 'all' =end | def financial_statements_status(session_options)
not_params_clear = !params[:clear]
params_status, session_options_status = [params[:status], session_options.try(:[], [:status])]
if (@valid_status_values.include? params_status) && not_params_clear
params_status
elsif session_options && (@valid_st... | [
"def financial_statements_status(session_options)\n if @valid_status_values.include? params[:status] and not params[:clear]\n status = params[:status]\n elsif session_options and @valid_status_values.include? session_options[:status] and not params[:clear]\n status = session_options[:status]\n el... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin convert prices in statements from default system currency to currency that is set in session Params +statement+ iterable of financial stement data(they rices should be in system currency) Returns +statement+ same object that was passed only it's prices recalculated in user selected currency =end | def convert_to_user_currency(statements)
exchange_rate = Currency.count_exchange_rate(session[:default_currency], session[:show_currency])
statements.each { |statement|
statement.price = statement.price.to_d * exchange_rate
statement.price_with_vat = statement.price_with_vat.to_d * exchange_rate
... | [
"def convert_to_user_currency(statements)\n exchange_rate = Currency.count_exchange_rate(session[:default_currency], session[:show_currency])\n statements.each { |statement|\n statement.price = statement.price.to_d * exchange_rate\n statement.price_with_vat = statement.price_with_vat.to_d * exchange... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin financial data returned by invoice, credit notes or payments may lack some information, this method's purpose is to retrieve information from part of financial statement(let's say financial stetement is devided in three parts: credit note, invoice and payments) about paid/unpaid financial data. if there is no su... | def get_financial_statement(statements, status)
statements.each { |statement|
if statement.status == status
return statement
end
}
#Return default financial data if required stetement was not found
Struct.new('We', :count, :price, :price_with_vat, :status)
return Struct::We.new(0... | [
"def financial_statements_get\n @doc.page {\n if @current_user and not (@current_user.is_accountant? and (not @current_user.accountant_allow_read('can_see_finances') or not @current_user.allow_read('payments_manage') or not @current_user.accountant_allow_read('invoices_manage')))\n if @values[:date_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Only one who may not have permissions to view financial statements is accountant. If he does not have 'can see finances', 'invoices manage' and 'manage payments' permissions to read he cannot view financial statements. In any other case everyone can view treyr user's invoices, credit notes and payments. =end | def can_view_financial_statements?
if accountant? and (not current_user.accountant_allow_read('can_see_finances') or not current_user.accountant_allow_read('payments_manage') or not current_user.acoutnant_alllow_read('invoices_manage'))
return false
else
return true
end
end | [
"def can_view_financial_statements?\n if current_user.is_accountant? and (not current_user.accountant_allow_read('can_see_finances') or not current_user.accountant_allow_read('payments_manage') or not current_user.acoutnant_alllow_read('invoices_manage'))\n return false\n else\n return true\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Argument: integer, num Side effects: None Return: String. Alterating 1's and 0's. A total of num 1's and 0's Edge cases: i/p: 0 Algorithm: str = '' Do the folllowing num times to index = 1, 2, 3, ..., num if index is odd str << '1' otherwise str << '0' Return str | def stringy(num)
str = ''
1.upto(num) do |index|
if index.odd?
str << '1'
else
str << '0'
end
end
str
end | [
"def stringy(num)\n res = ''\n (1..num).each { |current| current.odd? ? res << '1' : res << '0' }\n res\nend",
"def stringy(int)\n string = []\n count = int\n\n count.times do\n if \n string.size.odd? \n string.push(0)\n else \n string.push(1)\n end\n end\n string.join\ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns htmls of kiwix answer searches | def kiwixAnswerSearch(aA, aB, aC, aD)
htmls = []
begin
address1 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(aA) + '.html'
rescue
puts "address1 not encoded"
end
begin
address2 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(aB) + '.html'
rescue
puts "... | [
"def answer_html\n return '' if answer.nil? || answer.strip.empty?\n \n doc = Document.new(answer)\n question_form_answers = doc.root\n \n html = ''\n question_form_answers.each_element { |answer| html += as_answer(answer) }\n return html\n end",
"def search\n @uurl = params[:uurl]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns list of uris from a google search | def googleSearch(q, n = 5)
search = Google::Search::Web.new do |search|
search.query = q
search.size = :small
end
begin
uris = search.first(n).map(&:uri)
rescue
"uri fault"
end
return uris
end | [
"def get_urls(search_results)\n # A Google search_result looks like:\n # <a href=\"/url?q=https://www.scienceexchange.com/\">Science Exchange<b>...</b></a>\n # To get the actual page URL, use the 'href' and get the query param 'q' term.\n urls = []\n search_results.each do |result|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
iterably counts number of hits of each answer in a list of uris | def hitCount(uris, aA, aB, aC, aD)
hitCountStart = Time.now
aAll = []
aAll << aA << aB << aC << aD
countA = 0
countB = 0
countC = 0
countD = 0
aA = aA.downcase
aB = aB.downcase
aC = aC.downcase
aD = aD.downcase
aTotal = []
bTotal = []
cTotal = []
dTotal = []
plaintexts=[]
n = uris.size
n.... | [
"def answers_with_count\n count=Hash.new(0)\n self.list_answers.each {|a| count[a]+=1 }\n count\n end",
"def popular_links\n result = {}\n urls[0...5].each do |url|\n result[url] = url.num_clicks\n end\n result\n end",
"def count_replies(html)\n reply_count = { :rep => Hash.new(0)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
verifica se ha um medico na equipe | def is_medico_membro(equipe)
membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]
val_is_medico = false
for i in 0..3
if Pessoa.find(membros[i]).rank.downcase == 'medico'
val_is_medico = true
end
end
val_is_medico
end | [
"def is_medico_equipe(equipe)\n membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]\n count_medicos = 0\n\n for i in 0..3\n if Pessoa.find(membros[i]).rank.downcase == 'medico'\n count_medicos += 1\n elsif Pessoa.find(membros[i]).rank.downcase != 'chuunin' and\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
verifica se a equipe e uma equipe com 3 medicos e um Chunnin ou Jounin | def is_medico_equipe(equipe)
membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]
count_medicos = 0
for i in 0..3
if Pessoa.find(membros[i]).rank.downcase == 'medico'
count_medicos += 1
elsif Pessoa.find(membros[i]).rank.downcase != 'chuunin' and
Pessoa.f... | [
"def multi?\n return number_of(\"MSH\")>1\n end",
"def es_mayor c\n\t\t# Para comparar enteros primero hay que convertir los valores de las cartas que tienen letras p.e. \"j\" o \"as\"\n\t\ta_valor_i= 0\n\t\tcase (@carta.split \"+\")[0]\n\t\twhen Constantes::J\n\t\t\ta_valor_i = 11\n\t\twhen Constantes::Q... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verifica se a equipe e formada por anbus | def is_anbu_equipe(equipe)
membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]
val_is_anbu = true
for i in 0..3
val_is_anbu = (val_is_anbu and (Pessoa.find(membros[i]).rank.downcase == 'anbu'))
end
end | [
"def puedoTomarInsumos?\n super && @cantidadPAActual == cantidadPAMax\n end",
"def valida_viajes_completos(cliente)\n if cliente.reservacions.find_all_by_estadotipo_id(3).count==0 \n return false\n end\n end",
"def bus_code?\n (code[1] == '1')\n end",
"def baclava_input?\n @ba... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
verifica se o raikage e um membro da equipe | def is_raikage_membro(equipe)
membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]
val_is_raikage = false
for i in 0..3
if Pessoa.find(membros[i]).rank.downcase == 'raikage'
val_is_raikage = true
end
end
val_is_raikage
end | [
"def is_medico_membro(equipe)\n membros = [equipe.mb_1_id, equipe.mb_2_id, equipe.mb_3_id, equipe.mb_S_id]\n val_is_medico = false\n\n for i in 0..3\n if Pessoa.find(membros[i]).rank.downcase == 'medico'\n val_is_medico = true\n end\n end\n\n val_is_medico\n end",
"def is_anbu_equ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /outsides GET /outsides.json | def index
@outsides = Outside.all
end | [
"def index\n @outside_requests = OutsideRequest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @outside_requests }\n end\n end",
"def show\n @outside_request = OutsideRequest.find(params[:id])\n\n respond_to do |format|\n format.html # sho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /outsides POST /outsides.json | def create
@outside = Outside.new(outside_params)
respond_to do |format|
if @outside.save
format.html { redirect_to @outside, notice: 'Outside was successfully created.' }
format.json { render :show, status: :created, location: @outside }
else
format.html { render :new }
... | [
"def create\n @outside_request = OutsideRequest.new(params[:outside_request])\n\n respond_to do |format|\n if @outside_request.save\n format.html { redirect_to @outside_request, notice: 'Outside request was successfully created.' }\n format.json { render json: @outside_request, status: :cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /outsides/1 PATCH/PUT /outsides/1.json | def update
respond_to do |format|
if @outside.update(outside_params)
format.html { redirect_to @outside, notice: 'Outside was successfully updated.' }
format.json { render :show, status: :ok, location: @outside }
else
format.html { render :edit }
format.json { render json... | [
"def update\n @outside_request = OutsideRequest.find(params[:id])\n\n respond_to do |format|\n if @outside_request.update_attributes(params[:outside_request])\n format.html { redirect_to @outside_request, notice: 'Outside request was successfully updated.' }\n format.json { head :no_content... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /outsides/1 DELETE /outsides/1.json | def destroy
@outside.destroy
respond_to do |format|
format.html { redirect_to outsides_url, notice: 'Outside was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @outside_request = OutsideRequest.find(params[:id])\n @outside_request.destroy\n\n respond_to do |format|\n format.html { redirect_to outside_requests_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a uri with prefix and hash of the address | def uri
uri_prefix + Digest::MD5.hexdigest(self.address)
end | [
"def build_url(prefix='x', suffix='')\n id = SecureRandom.uuid\n \"/#{prefix}/#{id}/#{suffix}\"\n end",
"def construct_url(uri)\n \"#{uri.scheme}://#{uri.host}#{uri.path}\"\n end",
"def build_url(prefix='x', suffix='')\n id = SecureRandom.uuid\n \"/#{prefix}/#{id}/#{suffix}\"\nend",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns prefixes split on the namespace pattern. | def prefixes
prefix.split(NAMESPACE_PATTERN)
end | [
"def namespaces\n namespace.split(NAMESPACE_PATTERN)\n end",
"def split_prefix\n [$1, $2, $3] if @prefix =~ PREFIX_PAT\n end",
"def split_names\n @adapter.find_strings_by_prefix(namespace_key('.split.'))\n .map { |split| split.gsub(namespace_key('.split.'), '') }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns namespaces split on the namespace pattern. | def namespaces
namespace.split(NAMESPACE_PATTERN)
end | [
"def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end",
"def namespaces\n @namespaces ||= self.class.name.split('::').slice(0...-1).map(&:underscore).map(&:to_sym)\n end",
"def split_names\n @adapter.find_strings_by_prefix(namespace_key('.split.'))\n .map { |split| sp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns targets split on the namespace pattern. | def targets
target.split(NAMESPACE_PATTERN)
end | [
"def namespaces\n namespace.split(NAMESPACE_PATTERN)\n end",
"def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end",
"def inferred_targets\n target_group = group\n targets = []\n while targets.empty? && target_group.respond_to?(:sibling_targets)\n targets += target_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Note that we always have a cascaded event join for the model that the event actually belongs to, even if it's not cascadable. I know this is bad terminology, but it seems better to do this way so that we can get all events for an object directly from the cascaded events join table. | def maybe_cascade
CascadedEventJoin.find_or_create_by(cascaded_eventable: self.eventable, event_id: self.id)
if self.cascadable and self.eventable.respond_to?(:cascade_event)
self.eventable.cascade_event(self)
end
end | [
"def related_events\n find_related_frbr_objects( :is_related_to, :which_events?) \n end",
"def model_events\n @model_events ||= Hash.new do |cache, id|\n event = source_result_event(id)\n\n model_event = Calculations::V3::Models::Event.new(\n calculated: calculated?(event),\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convenience for getting element blueprints | def element_blueprints(composite_object = nil)
adapter.element_blueprints(composite_object)
end | [
"def element_blueprints(composite_object = nil)\n composite_object ||= self\n\n # Traverse!\n return composite_object.elements[element_name] if composite_object.hash[:elements].is_a?(Hash)\n\n return element_blueprints(composite_object.parent) if composite_object.parent\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the mode from the data and calls the API. Returns the response from the API. | def checkModes(data)
mode = data['mode']
call_features=Array.new(1) { Hash.new }
if mode=="labels"
call_features<<{
type:"LABEL_DETECTION",
maxResults:1
}
end
return apiRequest(data['image'],call_features)
end | [
"def api_mode\n if config.mode and API_MODES.include? config.mode.to_sym\n config.mode.to_sym\n else\n DEFAULT_API_MODE\n end\n end",
"def get_mode\n @situation[:mode]\n end",
"def modes\n @client.get('/Journey/Meta/Modes')\n end",
"def mode=(newmode... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Starts the webserver that takes images and sends them to the API. html server runs on | def start_webserver()
server = TCPServer.new('localhost', DEFAULT_PORT)
puts "Vision server running on http://localhost:#{DEFAULT_PORT}/"
while session = server.accept
time = Time.new
puts "New connection #{time.inspect}"
if File.exist?(DEFAULT_HTML_PATH) && !File.directory?(DEFAULT_HTML_PATH)
F... | [
"def serve\n @server.start\n end",
"def run\n check_for_web_build\n build_development\n listener = Listen.to(File.join(absolute_path, 'web')) do |_mod, _add, _rem|\n build_development\n end\n listener.start\n # @todo Get the public folder fr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is called once an outputter has been created. It sets the default formatter and level, if these have been already set. | def created_outputter(outputter)
#
# Set the formatter and level for any newly created outputters
#
if @default_formatter
outputter.formatter = @default_formatter if outputter.formatter.is_a?(Log4r::DefaultFormatter)
end
if @default_level
outputter.le... | [
"def initialize\n @formatter = method(:default_formatter)\n end",
"def configure\n yield self\n\n # Ensure every appender has a formatter and a level configuration.\n #\n appenders.each do |appender|\n appender.formatter ||= @formatter if appender.respond_to? 'formatter='\n a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines a Hash where the settings shall be stored. | def initialize
@settings = Hash.new
end | [
"def initialize(*args)\n super\n storage[:settings] ||= {}\n end",
"def settings\n @settings ||= {}\n end",
"def setGlobalSettingsHash(hash)\n @@settingsMetainfo.each do |k,v|\n set(k, hash[k.to_s]) if hash.has_key?(k.to_s)\n end\n end",
"def hash\n { hash: @hash, hashType: @ha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /massive_loads/1 GET /massive_loads/1.json | def show
@massive_load = MassiveLoad.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @massive_load }
end
end | [
"def new\n @massive_load = MassiveLoad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @massive_load }\n end\n end",
"def index\n @loads = Load.all\n end",
"def index\n @cpu_loads = CpuLoad.all\n end",
"def show\n respond_to do |format|\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /massive_loads/new GET /massive_loads/new.json | def new
@massive_load = MassiveLoad.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @massive_load }
end
end | [
"def new\n @load_test = LoadTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @load_test }\n end\n end",
"def new\n @loadcall = Loadcall.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loadcal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /massive_loads POST /massive_loads.json | def create
@massive_load = MassiveLoad.new(params[:massive_load])
respond_to do |format|
if @massive_load.save
read_excel
format.html { redirect_to @massive_load, notice: t(:successfully_created) }
format.json { render json: @massive_load, status: :created, location: @massive_load... | [
"def create\n @massive_load = MassiveLoad.new(params[:massive_load])\n\n respond_to do |format|\n if @massive_load.save\n @has_error = false\n read_excel\n if @has_error\n flash[:error] = t(\"massive_load.format_error\")\n MassiveLoad.destroy(@massive_load)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /massive_loads/1 DELETE /massive_loads/1.json | def destroy
@massive_load = MassiveLoad.find(params[:id])
@massive_load.destroy
respond_to do |format|
format.html { redirect_to massive_loads_url }
format.json { head :no_content }
end
end | [
"def destroy\n @load.destroy\n respond_to do |format|\n format.html { redirect_to loads_url, notice: 'Load was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def delete_json(path)\n url = [base_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /audit_trails or /audit_trails.json | def index
@audit_trails = AuditTrail.all
end | [
"def index\n\t\taudit_trail\n\t\trender :action => 'audit_trail'\n\tend",
"def list_audit_logs_for_date_range_for_tenant(args = {}) \n get(\"/tenants.json/#{args[:tenantId]}/auditlog\", args)\nend",
"def audit_account(id, options={}) path = \"/api/v2/accounts/#{id}/audit\"\n get(path, options, Ava... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /audit_trails or /audit_trails.json | def create
@audit_trail = AuditTrail.new(audit_trail_params)
respond_to do |format|
if @audit_trail.save
format.html { redirect_to @audit_trail, notice: "Audit trail was successfully created." }
format.json { render :show, status: :created, location: @audit_trail }
else
form... | [
"def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moto_registration_numbers/1 GET /moto_registration_numbers/1.xml | def show
@moto_registration_number = MotoRegistrationNumber.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @moto_registration_number }
end
end | [
"def show\n @registration_number = RegistrationNumber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @registration_number }\n end\n end",
"def new\n @moto_registration_number = MotoRegistrationNumber.new\n\n respond_to do |format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moto_registration_numbers/new GET /moto_registration_numbers/new.xml | def new
@moto_registration_number = MotoRegistrationNumber.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @moto_registration_number }
end
end | [
"def new\n @registration_number = RegistrationNumber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registration_number }\n end\n end",
"def create\n @moto_registration_number = MotoRegistrationNumber.new(params[:moto_registration_number])\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /moto_registration_numbers POST /moto_registration_numbers.xml | def create
@moto_registration_number = MotoRegistrationNumber.new(params[:moto_registration_number])
respond_to do |format|
if @moto_registration_number.save
format.html { redirect_to(@moto_registration_number, :notice => 'Moto registration number was successfully created.') }
format.xml ... | [
"def create\n @registration_number = RegistrationNumber.new(params[:registration_number])\n\n respond_to do |format|\n if @registration_number.save\n format.html { redirect_to(@registration_number, :notice => 'Registration number was successfully created.') }\n format.xml { render :xml => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /moto_registration_numbers/1 PUT /moto_registration_numbers/1.xml | def update
@moto_registration_number = MotoRegistrationNumber.find(params[:id])
respond_to do |format|
if @moto_registration_number.update_attributes(params[:moto_registration_number])
format.html { redirect_to(@moto_registration_number, :notice => 'Moto registration number was successfully updat... | [
"def update\n @registration_number = RegistrationNumber.find(params[:id])\n\n respond_to do |format|\n if @registration_number.update_attributes(params[:registration_number])\n format.html { redirect_to(@registration_number, :notice => 'Registration number was successfully updated.') }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /moto_registration_numbers/1 DELETE /moto_registration_numbers/1.xml | def destroy
@moto_registration_number = MotoRegistrationNumber.find(params[:id])
@moto_registration_number.destroy
respond_to do |format|
format.html { redirect_to(moto_registration_numbers_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @registration_number = RegistrationNumber.find(params[:id])\n @registration_number.destroy\n\n respond_to do |format|\n format.html { redirect_to(registration_numbers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node_registration = NodeRegistration.find(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the last because clause | def __last_because
__stack.last || @scenario.name
end | [
"def last_statement\n return @statements[-1]\n end",
"def last_saved_quire\n quires.includes(:leaves).where.not(id: nil).last\n end",
"def multi_clause_last_redis_op(result_set)\n raise \"AbstractMethod\"\n end",
"def is_last?\n max_date = self.class.where(strategy_id: strateg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
About browser Returns the current browser instance | def browser
@browser
end | [
"def browser\n @_browser ||= Browser.new\n end",
"def browser\n @web_browser\n end",
"def browser\r\n @web_browser\r\n end",
"def browser\n @options[:browser] ||= self.class.create_browser\n end",
"def browser\n BrowserFactory.build(session: session, url_options: url_optio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns current browser contents (used by HTMLAnalysis) | def browser_contents
browser.contents
end | [
"def get_page_source\n @browser.html\n end",
"def get_page_text\n @browser.text\n end",
"def print_html_contents\r\n\r\n browser_html = LynxAutoHelper.get_browser_instance.html\r\n puts \"\\n\\n****** HTML contents of the current page follow \\n #{browser_html}\"\r\n\r\n end",
"def page... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the URL of the index page (the web_base actually) This method returns nil unless the Waw application has been loaded | def index_page
config && config.web_base
end | [
"def web_url\n return @web_url\n end",
"def site_web_url\n return @site_web_url\n end",
"def web_root\n @attributes[:web_root]\n end",
"def web_site_url\n return @web_site_url\n end",
"def url\n begin\n URI.join(se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
About reaching pages Asserts that a page can be reached, leading to a Net::HTTPSuccess result | def i_reach(which_page)
result = go(which_page)
assert Net::HTTPSuccess===result, __last_because + " (cannot actually reach #{which_page}: #{result})"
end | [
"def assert_on_page(page)\n raise \"page must begin with '/': #{page}\" unless page[0] == ?\\/\n assert \"http://example.org#{page}\" == last_request.url,\n \"Expected to be on page http://example.org#{page} but was on #{last_request.url}\"\n end",
"def page_ok?(config, url)\n uri = URI.parse(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Asserts that a page cannot be reached, leading to a Net::HTTPNotFound or a Net::HTTPForbidden (403) result | def i_dont_reach(which_page)
result = go(which_page)
assert (Net::HTTPNotFound===result or Net::HTTPForbidden===result), __last_because + " (can reach #{which_page}: #{result})"
end | [
"def i_may_not_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPForbidden===result or Net::HTTPBadRequest===result), __last_because + \" (may actually reach #{which_page}: #{result})\"\n end",
"def test_invalid_route\n # Requesting an invalid page.\n request = @requester.get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Asserts that a page may not be reached, leading to a Net::HTTPForbidden (403) result. | def i_may_not_reach(which_page)
result = go(which_page)
assert (Net::HTTPForbidden===result or Net::HTTPBadRequest===result), __last_because + " (may actually reach #{which_page}: #{result})"
end | [
"def i_dont_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPNotFound===result or Net::HTTPForbidden===result), __last_because + \" (can reach #{which_page}: #{result})\"\n end",
"def expect_forbidden_status\n is_expected.to respond_with 403\n end",
"def skipped_test_raises_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /classifieds/new GET /classifieds/new.json | def new
@classified = Classified.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @classified }
end
end | [
"def new\n @classifier = Classifier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classifier }\n end\n end",
"def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /classifieds/1 PUT /classifieds/1.json | def update
@classified = @user.classifieds.find(params[:id])
respond_to do |format|
if @classified.update_attributes(params[:classified])
format.html { redirect_to @classified, notice: 'Classified was successfully updated.' }
format.json { head :no_content }
else
format.html... | [
"def update\n @classified = Classified.find(params[:id])\n\n respond_to do |format|\n if @classified.update_attributes(params[:classified])\n format.html { redirect_to @classified, notice: 'Classified was successfully updated.' }\n format.json { head :no_content }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /classifieds/1 DELETE /classifieds/1.json | def destroy
@classified = @user.classifieds.find(params[:id])
@classified.destroy
respond_to do |format|
format.html { redirect_to classifieds_url }
format.json { head :no_content }
end
end | [
"def destroy\n @classified = Classified.find(params[:id])\n @classified.destroy\n\n respond_to do |format|\n format.html { redirect_to classifieds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @classified.destroy\n respond_to do |format|\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
FIXME: (cmhobbs) this is pretty heavy handed. User shouldn't know this much about related objects. Public: Aggregate all users in associated groups Examples User.first.related_groups_users => [ , ] Returns an Array representing the related User objects. | def related_groups_users
[].tap do |related_users|
all_groups.each do |group|
related_users << group.all_users.reject { |group_user| group_user == self }
end
end.flatten.uniq
end | [
"def users\n users = []\n members.each do |member|\n if member.is_a? User\n users << member\n elsif member.is_a? UserGroup\n users + member.users\n else\n raise UserGroupException.new(\"While retrieving users from a user group (#{self}), found a member that was not a User o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
NOTE: (cmhobbs) we don't check to see if a BadgeType is awardable. this may prove troublesome in the future. FIXME (cmhobbs) we're passing badge_type_id around quite a bit... this may require a separate class at some point. | def award_badge(badge_type_id)
if badges.where(badge_type_id: badge_type_id).exists?
false
else
badge = badges.create(badge_type_id: badge_type_id, year: Time.now.year)
Notifier.delay.new_badge_email(self, badge)
# NOTE: (cmhobbs) spam all the users! \o/
# BadgeWorker.perform_async... | [
"def award_badges\n Badge.all.each do |the_badge|\n [challenger, challenged].each do |the_player|\n the_player.award!(the_badge) if the_badge.qualifies?(the_player)\n end\n end\n end",
"def award_badge(participant_id, badge_name)\n badge_id = Badge.get_id_from_name(badge_name: badge_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Configure the connection instance in a generic manner. Each client can modify the connection in a specific way, when the application requires special handling. Just overwrite the +configure+ method, and call +super(con)+. Here is a full example: def configure(con) super(con) con.request :url_encoded con.response :logge... | def configure(con)
con.use :instrumentation
# The definition order is execution order
con.request :ph_data_sanitization
con.request :ph_default_headers
con.request :json
con.request :multipart
con.request :url_encoded
# The definition order is reverse to... | [
"def configure_connection\n super\n end",
"def configure_connection\n if @config[:encoding]\n @connection.set_client_encoding(@config[:encoding])\n end\n self.client_min_messages = @config[:min_messages] if @config[:min_messages]\n self.schema_search_path... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /paperitems/1 PATCH/PUT /paperitems/1.json | def update
respond_to do |format|
if @paperitem.update(paperitem_params)
format.html { redirect_to @paperitem, notice: 'Paperitem was successfully updated.' }
format.json { render :show, status: :ok, location: @paperitem }
else
format.html { render :edit }
format.json { r... | [
"def update\n respond_to do |format|\n if @paper_item.update(paper_item_params)\n format.html { redirect_to @paper_item, notice: 'Paper item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /paperitems/1 DELETE /paperitems/1.json | def destroy
@paperitem.destroy
respond_to do |format|
format.html { redirect_to paperitems_url, notice: 'Paperitem was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @paper_item.destroy\n respond_to do |format|\n format.html { redirect_to paper_items_url }\n format.json { head :no_content }\n end\n end",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if ite... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
give me a block that describes how to display a potential value for the named field. If you call me without a block, I will return either the last block you sent me, or the default display_proc. Block should take 1 arg (being the value to format) and return the value, formatted. default proc just runs to_s on the value... | def display_proc(&block)
#defined by default_for_proc_type in initialize!
end | [
"def format!\n if block\n captured_value\n else\n to_s\n end\n end",
"def format_submission_field(field, value, &block)\n FormSubmissionFieldDisplay.new(self, field, value, &block)\n end",
"def format_submission_field(field, value, &block)\n FormSubmissionFieldDisplay.ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convenience method for chaining FieldDefs::Field.display_proc and FieldDefs::Field.reader_proc as intended i.e. instead of: field = field_defs.field_called(:name) field.display_proc.call(field.reader_proc.call(user)) you can do: field_defs.display_for(user, :name) | def display_for(object, field_name)
fdef = field_called(field_name)
fdef.display_proc.call(fdef.reader_proc.call(object))
end | [
"def edit_and_show_as(arg = nil, &proc) # :yields: field_def or nil\n edit_as(arg, &proc)\n show_as(arg, &proc)\n end",
"def display_proc(&block)\n #defined by default_for_proc_type in initialize!\n end",
"def document_show_field_label(document, field)\n lookup_display_name(document, field) ||... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a hash of all fields of the form: field name => human name Include only those fields that have the given label | def all_attributes_labeled(label_name)
to_return = {}
@fields.each do |key, field|
if field.has_label?(label_name.to_sym)
to_return[key] = field.human_name
end
end
to_return
end | [
"def all_fields_labeled(label_name)\n @fields.values.reject do |field|\n !field.has_label?(label_name.to_sym)\n end\n end",
"def fields\n @field_labels.collect { |k, v| { sym: k, name: v } }\n end",
"def label_fields\n @label_fields ||= LabelFields.new do |lf|\n labels.each { |label| lf.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get an array of all fields thate have the given label | def all_fields_labeled(label_name)
@fields.values.reject do |field|
!field.has_label?(label_name.to_sym)
end
end | [
"def label_fields\n @label_fields ||= LabelFields.new do |lf|\n labels.each { |label| lf.add(label) }\n end\n end",
"def all_attributes_labeled(label_name)\n to_return = {}\n @fields.each do |key, field|\n if field.has_label?(label_name.to_sym)\n to_return[key] = field.human_name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts the data to uri resource and caches it in local. | def put(src, uri)
# prepare cache path
path = prepare_cache_path
# move the file from the working directory to cache
FileUtils.mv(src, path)
# make a symbolic link from original location to the cache
FileUtils.symlink(path, src)
# copy from cache ... | [
"def update (uri, data)\n return nil unless @enabled\n\n cache_name = translate_uri(uri)\n mkdir # FIXME include cache_name to build all necessary directories \n\n File.open(File.join(@directory, cache_name), 'w') do |f|\n f << data\n end\n end",
"def process_data(uri, ip)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
common cache : load_notetags_bubs_dismantle | def load_notetags_bubs_dismantle
@dismantle_items = []
@dismantle_gold_fee = Bubs::Dismantle::DEFAULT_DISMANTLE_FEE
@dismantle_reagents = {}
@dismantle_counter = 0
dismantle_tag = false
self.note.split(/[\r\n]+/).each { |line|
case line
when /<dismantle>/i
dismantle... | [
"def load_notetags_bubs_tocrafting\n @recipe_list = []\n @ingredient_list = []\n @tocrafting_tools = []\n @tocrafting_actors = []\n @tocrafting_skills = []\n @tocrafting_gold_fee = self.price\n @tocrafting_bookcover = \"\"\n @tocrafting_se = []\n @tocrafting_category = :none\n @tocraft... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
new method : set_dismantle_mask_flags | def set_dismantle_mask_flags(flag = true)
return unless self.is_a?(RPG::Item) || self.is_a?(RPG::EquipItem)
@dismantle_items.each do |obj| obj.mask = flag end
end | [
"def remove_dismantle_mask(key, id)\n case key\n when :item\n $data_items[id].set_dismantle_mask_flags(true)\n when :armor\n $data_armors[id].set_dismantle_mask_flags(true)\n when :weapon\n $data_weapons[id].set_dismantle_mask_flags(true)\n end\n end",
"def masking?; end",
"def un... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
status_window= Set Status Window | def status_window=(status_window)
@status_window = status_window
call_update_help
end | [
"def status_window aconfig={}, &block\n return StatusWindow.new aconfig\n end",
"def status_window aconfig={}, &block\n sw = StatusWindow.new aconfig\n sw.win.name = \"WINDOW::status_window\"\n return sw unless block_given?\n begin\n yield sw\n ensure\n sw.destroy if sw\n end\nend",
"def main_st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
new method : remove_dismantle_mask | def remove_dismantle_mask(key, id)
case key
when :item
$data_items[id].set_dismantle_mask_flags(true)
when :armor
$data_armors[id].set_dismantle_mask_flags(true)
when :weapon
$data_weapons[id].set_dismantle_mask_flags(true)
end
end | [
"def unset_mask; end",
"def unset_mask\n @masking_key = nil\n end",
"def masking?; end",
"def masked; end",
"def remove_all_dismantle_masks\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n obj.set_dismant... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
new method : remove_all_dismantle_masks | def remove_all_dismantle_masks
groups = [$data_items, $data_armors, $data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.set_dismantle_mask_flags(true)
end # for
end # for
end | [
"def unset_mask; end",
"def clear!\n\t\t@mask = []\n\tend",
"def unset_mask\n @masking_key = nil\n end",
"def remove_all_of controllable\n @controls.reject! { |control| control.controllable == controllable }\n end",
"def remove_dismantle_mask(key, id)\n case key\n when :item\n $da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def new method : get_dismantle_count | def get_dismantle_count(key, id)
case key
when :item
$data_items[id].dismantle_counter
when :armor
$data_armors[id].dismantle_counter
when :weapon
$data_weapons[id].dismantle_counter
end # case
end | [
"def disperse_count\n @disperse_count\n end",
"def count\n dps.count\nend",
"def get_all_dismantle_count\n count = 0\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n count += obj.dismantle_counter\n end ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def new method : get_all_dismantle_count | def get_all_dismantle_count
count = 0
groups = [$data_items, $data_armors, $data_weapons]
for group in groups
for obj in group
next if obj.nil?
count += obj.dismantle_counter
end # for
end # for
return count
end | [
"def offense_counts; end",
"def count\n dps.count\nend",
"def get_dismantle_count(key, id)\n case key\n when :item\n $data_items[id].dismantle_counter\n when :armor\n $data_armors[id].dismantle_counter\n when :weapon\n $data_weapons[id].dismantle_counter\n end # case\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /accession_location_entries/1 GET /accession_location_entries/1.json | def show
@accession_location_entry = AccessionLocationEntry.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @accession_location_entry }
end
end | [
"def show\n @collection_location_entry = CollectionLocationEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collection_location_entry }\n end\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
"def new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /accession_location_entries/new GET /accession_location_entries/new.json | def new
@accession_location_entry = AccessionLocationEntry.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @accession_location_entry }
end
end | [
"def new\n @collection_location_entry = CollectionLocationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_location_entry }\n end\n end",
"def create\n @accession_location_entry = AccessionLocationEntry.new(params[:accession_location... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /accession_location_entries POST /accession_location_entries.json | def create
@accession_location_entry = AccessionLocationEntry.new(params[:accession_location_entry])
respond_to do |format|
if @accession_location_entry.save
format.html { redirect_to @accession_location_entry, notice: 'Accession location entry was successfully created.' }
format.json { r... | [
"def create\n @collection_location_entry = CollectionLocationEntry.new(params[:collection_location_entry])\n\n respond_to do |format|\n if @collection_location_entry.save\n format.html { redirect_to @collection_location_entry, notice: 'Collection location entry was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /accession_location_entries/1 PUT /accession_location_entries/1.json | def update
@accession_location_entry = AccessionLocationEntry.find(params[:id])
respond_to do |format|
if @accession_location_entry.update_attributes(params[:accession_location_entry])
format.html { redirect_to @accession_location_entry, notice: 'Accession location entry was successfully updated.... | [
"def update\n @collection_location_entry = CollectionLocationEntry.find(params[:id])\n\n respond_to do |format|\n if @collection_location_entry.update_attributes(params[:collection_location_entry])\n format.html { redirect_to @collection_location_entry, notice: 'Collection location entry was succe... | {
"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.