query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
PUT /notify_observers/1 PUT /notify_observers/1.json | def update
@notify_observer = NotifyObserver.find(params[:id])
respond_to do |format|
if @notify_observer.update_attributes(params[:notify_observer])
format.html { redirect_to @notify_observer, notice: 'Notify observer was successfully updated.' }
format.json { head :no_content }
el... | [
"def update\n @observer = Observer.find(params[:id])\n\n if @observer.update(observer_params)\n head :no_content\n else\n render json: @observer.errors, status: :unprocessable_entity\n end\n end",
"def update_notification(id, model) path = \"/api/v2/notifications/#{id}\"\n put... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /notify_observers/1 DELETE /notify_observers/1.json | def destroy
@notify_observer = NotifyObserver.find(params[:id])
@notify_observer.destroy
respond_to do |format|
format.html { redirect_to notify_observers_url }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_notification.destroy\n \n head :no_content\n end",
"def destroy\n @notify_observer_property = NotifyObserverProperty.find(params[:id])\n @notify_observer_property.destroy\n\n respond_to do |format|\n format.html { redirect_to notify_observer_properties_url }\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start a named child process and execute the provided block in it. | def start(name, &block)
Process.fork(name: name, &block)
end | [
"def fork_child(block)\n child = Verneuil::Process.new(@program, nil)\n child.run_block(block)\n \n @children << child\n \n return child\n end",
"def exec(procName, cmdName, args, env, &block)\n @execs[procName] = block\n end",
"def start_new_child(child_spec)\n @child_specs[ch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stores an Association for the given server url and OpenID::Association. | def store_association(server_url, assoc)
remove_association(server_url, assoc.handle)
Association.create(:server_url => server_url,
:handle => assoc.handle,
:secret => Moped::BSON::Binary.new(:generic, assoc.secret),
:issued... | [
"def store_association(server_url, association)\n if document = Association.load(server_url, association.handle)\n document.association = association\n document.save\n else\n Association.create(server_url, association)\n end\n end",
"def store_association(serve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moto_town_type_sections/1 GET /moto_town_type_sections/1.xml | def show
@moto_town_type_section = MotoTownTypeSection.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @moto_town_type_section }
end
end | [
"def show\n @machine_town_type_section = MachineTownTypeSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_town_type_section }\n end\n end",
"def show\n @moto_town_type = MotoTownType.find(params[:id])\n\n respond_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moto_town_type_sections/new GET /moto_town_type_sections/new.xml | def new
@moto_town_type_section = MotoTownTypeSection.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @moto_town_type_section }
end
end | [
"def new\n @machine_town_type_section = MachineTownTypeSection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_town_type_section }\n end\n end",
"def new\n @town_type = TownType.new\n\n respond_to do |format|\n format.html # new.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /moto_town_type_sections POST /moto_town_type_sections.xml | def create
@moto_town_type_section = MotoTownTypeSection.new(params[:moto_town_type_section])
respond_to do |format|
if @moto_town_type_section.save
format.html { redirect_to(@moto_town_type_section, :notice => 'Moto town type section was successfully created.') }
format.xml { render :xm... | [
"def create\n @machine_town_type_section = MachineTownTypeSection.new(params[:machine_town_type_section])\n\n respond_to do |format|\n if @machine_town_type_section.save\n format.html { redirect_to(@machine_town_type_section, :notice => 'Machine town type section was successfully created.') }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /moto_town_type_sections/1 PUT /moto_town_type_sections/1.xml | def update
@moto_town_type_section = MotoTownTypeSection.find(params[:id])
respond_to do |format|
if @moto_town_type_section.update_attributes(params[:moto_town_type_section])
format.html { redirect_to(@moto_town_type_section, :notice => 'Moto town type section was successfully updated.') }
... | [
"def update\n @machine_town_type_section = MachineTownTypeSection.find(params[:id])\n\n respond_to do |format|\n if @machine_town_type_section.update_attributes(params[:machine_town_type_section])\n format.html { redirect_to(@machine_town_type_section, :notice => 'Machine town type section was suc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /moto_town_type_sections/1 DELETE /moto_town_type_sections/1.xml | def destroy
@moto_town_type_section = MotoTownTypeSection.find(params[:id])
@moto_town_type_section.destroy
respond_to do |format|
format.html { redirect_to(moto_town_type_sections_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @machine_town_type_section = MachineTownTypeSection.find(params[:id])\n @machine_town_type_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(machine_town_type_sections_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @boat_town_type_secti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Constructor type the type of the difference aws the aws resource that's different (defaults to nil) local the local resource that's difference (defaults to nil) changes an object to describe what changed in a MODIFIED diff (defaults to nil) | def initialize(type, aws = nil, local = nil, changes = nil)
@aws = aws
@local = local
@type = type
@changes = changes
@info_only = false
end | [
"def sync_difference(name, diffs)\n aws = Hash[aws_resources.map { |aws| [aws.name, aws] }]\n if diffs.size > 0\n StatusCodes::set_status(StatusCodes::SYNC_DIFFS)\n\n if diffs[0].type == Common::DiffChange::UNMANAGED\n puts diffs[0]\n elsif diffs[0].type == Common... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: A method that produces the string that describes what will be done with unmanaged assets. This can be overriden for the case that the UNMANAGED case does not ignore the asset. Returns the string describing the action that will be taken | def unmanaged_string
"is not managed by Cumulus."
end | [
"def unmanaged\n @unmanaged\n end",
"def textual_unmanaged_vms\n {:label => _(\"Unmanaged VMs\"),\n :icon => \"pficon pficon-virtual-machine\",\n :value => @record.total_unmanaged_vms,\n :title => _(\"Unmanaged VMs are no longer available\")}\n end",
"def action_label\n \"#{output_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the body and headers for a 404 response. Does not modify the body if already set. | def not_found
self.status = 404
return unless body.empty?
self.body = "Not found: #{request.path}"
headers['Content-Type'] = 'text/plain'
headers['X-Cascade'] = 'pass'
headers['Cache-Control'] = 'nocache'
end | [
"def custom_404_body\n filename = File.join(root, \"404.html\")\n\n File.exist?(filename) ? File.binread(filename) : nil\n end",
"def not_found(body = nil)\n error(404, body)\n end",
"def res_404\n create_response('Not Found', 404, {'Content-Type' => 'text/plain'})\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the headers and status code for a redirection to a given URL | def redirect(url)
headers['Location'] = url
self.status = 302
raise FinishRequest
end | [
"def redirect_to(url)\n response.code = 301\n response.headers['Location'] = url\n end",
"def redirect uri, *args\n if @env[HTTP_VERSION] == 'HTTP/1.1' && @env[REQ_METHOD] != 'GET'\n status 303\n else\n status 302\n end\n\n @response[LOCATION] = url_to(uri.to_s)\n halt(*args)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a conservative cache control policy to reduce load on requests served with "?1234567890" style timestamp query strings. | def add_cache_control
return if request.query_string.to_i == 0
headers['Cache-Control'] ||= 'public, max-age=300'
end | [
"def add_cache_control; end",
"def prepare_to_cache\n if headers.key? 'Age'\n cache_control.normalize_max_ages(headers['Age'].to_i)\n headers.delete 'Age'\n headers['Cache-Control'] = cache_control.to_s\n end\n end",
"def cache_unless_new\n published = Time.par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retrieve all accounts, they are needed for the sidebar display | def get_accounts
@accounts = Account.all
end | [
"def accounts\n get_collection 'accounts', :class => Buxfer::Account\n end",
"def accounts\n make_promise(@core.web3.JS[:personal], 'getListAccounts')\n end",
"def accounts\n []\n end",
"def all\n @dealing_platform.gather 'accounts', :accounts, Account\n end",
"def lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: Public: Get any number; one that doesn't matter options options to control what sort of number comes back: :positive make sure that the number is greater than zero :negative make sure that the number is less than zero | def any_number(*options)
number = (rand(2 * MAX_RAND) - MAX_RAND).to_f/100.0
if options.include? :positive
number + MAX_RAND
elsif options.include? :negative
number - MAX_RAND
else
number
end
end | [
"def zero_if_negative the_number\n\t\treturn the_number < 0 ? 0 : the_number\n\tend",
"def negative(number)\n if number > 0\n -number\n else\n return number\n end\nend",
"def number\n digit.as(:digit) | negative.as(:negative) | decimal.as(:decimal)\n end",
"def any_int(*options)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns an integer. options is the same as for any_number | def any_int(*options)
any_number(*options).to_i
end | [
"def extract_count_from_options(options); end",
"def integer(name, options={})\n param(:integer, name, options)\n end",
"def integer\n one_or_more { digit }\n end",
"def option_number(string)\n return string.split('-',5)[3].to_i\n end",
"def any_number(*options)\n number = (rand(2... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get an arbitrary string of any potential positive length options options to control the returned string: :max the max size of the string you want, must be positive and greater than :min :min the minimum size we want to come back, must be positive and less than :max Example any_string :max => 255 => ensure it'll... | def any_string(options = {})
if options[:min] && options[:max]
raise ":min must be less than :max" if options[:min] > options[:max]
end
if options[:min]
raise ":min must be positive" if options[:min] < 1
end
min_size = options[:min]
max_size = options... | [
"def minLength; end",
"def test_gen_strings_with_min_max_length\n length = (10..100)\n RFauxFactory.gen_strings(length).each do |str_type, value|\n min_length = length.min\n max_length = length.max\n if str_type == :html\n # html is an exception as tags added\n min_length += HTM... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get an arbitrary sentence of arbitrary words of any potential length. Currently, this returns a sentence between 10 and 21 words, though you can control that with options options options to control the returned sentence :max the maximum number of words you want returned :min the minimum number of words you want... | def any_sentence(options = {})
min = 11
max = 21
if options[:max]
min = 1
max = options[:max]
elsif options[:min]
min = options[:min]
max = min + 10
end
Faker::Lorem.words(rand(max - min) + min).join(' ')
end | [
"def spit(options = {})\n if @words_table.words.empty?\n raise StandardError, \"The generator hasn't heard anything yet\"\n end\n\n words = options[:words] && Integer(options[:words])\n max_chars = options[:max_chars] && Integer(options[:max_chars])\n\n sentence = []\n\n if words\n w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if the call node can use delegate to avoid violating law of demeter. if the receiver of receiver of the call node matchs any in model names, and the message of receiver of the call node matchs any in association names, then it needs delegate. | def need_delegate?(node)
return unless variable(node)
class_name = variable(node).to_s.sub('@', '').classify
association_name = node.receiver.message.to_s
association = model_associations.get_association(class_name, association_name)
attribute_name = node.message.to_s
as... | [
"def need_delegate?(node)\n @associations.each do |class_name, associations|\n return true if equal?(node.subject.subject, class_name) && associations.find { |association| equal?(association, node.subject.message) }\n end\n false\n end",
"def is_delegated\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
takes a list of points and inserts the distances. return DistResultAlreadyValid if distances are already in place, DistResultValid if distances are not already in place but have been calculated and inserted, and DistResultInvalid if only some points have distances and some don't (this points to a state mismatch issue) | def add_distances(points)
points_dist = points.select { |p| p.key? :distance }
return DistResultAlreadyValid.new(points) \
if points_dist.length == points.length
return DistResultInvalid.new('Only some points with distance') \
unless points_dist.empty?
points.each_index do |idx|
if idx.zero?
... | [
"def compute_point_distances(points)\n if points.size >= 2\n paired_points = points[0...-1].zip(points[1..-1])\n distances = [0]\n distances + paired_points.map { |(p, q)| p.distance(q) }\n else\n []\n end\n end",
"def valid_points(points)\n return PointsResultInvali... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Super lame, but awesome way to get CSS options CSS selector. | def css
options.fetch :css, CSS_SELECTOR
end | [
"def extract_selector_elements\n extract_elements 'single-option'\n end",
"def css_selector; end",
"def selector\n @selector = @outer_has_tag ? @outer_has_tag.selector : ''\n\n @selector << \"//#{@tag}#{id_selector}#{class_selector}\"\n @selector << @attributes.map{|a, v| \"[@#{a}=\\\"#{v}\\\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Registers mime types and renderers for all available rdf formats. Add additional formats by adding the gems to the Gemfile. See for a list of available formats. | def register!
self.rdf_content_types = []
RDF::Format.each do |format|
register_renderer(format.file_extension, format.content_type, format.symbols.first)
end
register_renderer(%i[hndjson], ['application/hex+x-ndjson'], :hndjson)
register_renderer(%i[empjson], ['applic... | [
"def register_mime_types\n\n # Add new mime types for use in respond_to blocks:\n # Mime::Type.register \"text/richtext\", :rtf\n # Mime::Type.register_alias \"text/html\", :iphone\n Mime::Type.register \"application/rdf+xml\", :rdf\n\n # The are used for serving \"static\" widget... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the cookies page will only render with the 'who' parameter right now, like this: /test/cookies?who=peter | def show_cookies
if request.post? || params[:who] == 'peter'
ls = cookies[LIFESIZE_COOKIE]
if ls
@cookie_value = JSON.pretty_generate(JSON.parse(Crypt.decrypt(ls)))
else
@cookie_value = "lifesize cookie not set"
end
@screen_cookie_value = cookies[SCREEN_COOKIE] ? cookie... | [
"def cookies\n # renders static page\n end",
"def cookie\n render 'cookies'\n end",
"def cookie_path; end",
"def show_me_the_cookie(cookie_name)\n puts \"#{cookie_name}: #{get_me_the_cookie(cookie_name).inspect}\"\n end",
"def show_me_the_cookies\n puts \"Cookies: #{get_me_the_cookies.inspect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add item object to guest cart | def add_item_to_guest_cart(item)
post_wrapper("/V1/guest-carts/#{guest_cart_key}/items", item.to_json, default_headers)
end | [
"def add_to_cart(product)\n @items << product\n end",
"def add\n\t\tadd_to_cart(params[:item_obj], params[:qty])\n flash[:notice] = \"Succesfully added to your cart!\"\n\t\tredirect_to :controller => \"items\", :action => \"show\"\n\tend",
"def add_product_to_cart(product)\n items << product\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assert_valid_keys was killing performance. Array.flatten was the culprit, so I rewrote this method, got a 35% performance increase | def fast_assert_valid_keys(valid_keys)
unknown_keys = keys - valid_keys
raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
end | [
"def assert_required_and_valid_keys(*keys)\n assert_valid_keys(keys)\n assert_required_keys(keys)\n end",
"def test_validate_key_not_empty\n assert_nothing_raised do\n validate_key! key\n end\n end",
"def test_keys_when_empty\n\n create_if_nil = true\n model = Sketchup.active_model\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convenience method for Classifier::Bayes.new | def classifier(*args, &block)
Classifier::Bayes.new(*args, &block)
end | [
"def classifier\n return @classifier if @classifier\n\n @classifier = OmniCat::Classifiers::Bayes.new\n\n transaction_categorization_codes.each do |c|\n @classifier.add_category c\n end\n @classifier.train 'other', 'other'\n\n train_data = transaction_categorization_cases.map { |o| { words: o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes entirely the flash from the session if it has stale contents or if empty. | def clear
# FIXME we're just before a release and I can't find a proper way to reproduce
# this bug that I've found via a browser.
#
# It may happen that `#flash` is nil, and those two methods will fail
unless flash.nil?
expire_stale!
remove!
end
... | [
"def _roda_after_40__flash(_)\n if f = @_flash\n f = f.next\n if f.empty?\n session.delete('_flash')\n else\n session['_flash'] = f\n end\n end\n end",
"def flash_clear\n flash.clear\n end",
"def keep_flash\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The flash registry that holds the data only for the current request | def data
flash[@request_id] || {}
end | [
"def values\n @store[:__FLASH__] ||= {}\n end",
"def flash_data\n @need_flash_refresh = true\n @flash_data\n end",
"def values\n @session[:olelo_flash] ||= {}\n end",
"def flash\n return @flash if @flash\n\n session['__flash__'] ||= {}\n @flash = FlashHash.new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expire the stale data from the previous request. | def expire_stale!
flash.each do |request_id, _|
flash.delete(request_id) if @request_id != request_id
end
end | [
"def invalidate\n @cache = {}\n end",
"def invalidate\n @cache = {}\n end",
"def expire!\n headers['Age'] = max_age.to_s if fresh?\n end",
"def expire\n self.expired = true\n self.payload = nil\n self.passphrase = nil\n self.expired_on = Time.now\n save\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
shift :: (shift) :: Int >? Day | def shift(shift)
check_pre((
(shift.int?)
))
day = self
for n in 1 .. shift.abs
if shift.int_pos?
day = day.succ
else
day = day.pred
end
end
return day
end | [
"def day_shift(in_day, in_shift)\n check_pre(((day?(in_day)) and (in_shift.int?)))\n to_day(in_day, DayNum[to_external(day_num_shift(to_internal(to_day_num(in_day).num), in_shift))])\nend",
"def shift() end",
"def using_shift(a)\n a.shift\nend",
"def shift(ndigits)\n #This is a stub, used for indexi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Formbased logout (for integration testing) | def form_logout
post '/goldberg/auth/logout'
end | [
"def logout\n user_name.click\n logout_link.click\n end",
"def logout\n validate_arguments!\n\n Mortar::Auth.logout\n display \"Local credentials cleared.\"\n end",
"def logout\n self.logoutlink.click\n end",
"def logout\n @browser.link(:text, \"Logout\").click\n Login.new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build an instance of DomainConfigInstance | def get_instance(payload)
DomainConfigInstance.new(@version, payload, )
end | [
"def get_instance(payload)\n DomainConfigInstance.new(@version, payload)\n end",
"def build\n @config.validate! if @config.respond_to?(:validate!)\n @config\n end",
"def build(domain_name)\n domain = Domain.new(:name => domain_name,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recibe un vector con los datos de un alimento para los individuos, devuelve un vector con los AIBC de cada individuo | def aibc(g)
# recibe un vector de datos del alimento
# devuelve los aibc del alimento, o glucosa, para cada individuo
g.map{ |gi| gi.each_with_index.map{ |gindex, i| if0(gindex, gi[0], gi[i-1]) if i > 0 } }.map{ |gi| gi.reject{ |gij| gij.class == nil::NilClass } }.map{ |ri| ri.reduce(0, :+) }
end | [
"def listaColectivosIndividuo(c, conjuntoColectivos)\n\n auxArray = Array.new\n #Bucle para mirar si el usuario tiene algun otro conjunto creado\n for col in conjuntoColectivos\n if col.representante.eql?(c)\n auxArray.push(col)\n end\n end\n auxArray\n end",
"def capacidade_vagas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /project_users POST /project_users.json | def create
@project = Project.find(params[:project_id])
@user = User.where("email = ?", params[:email]).first
pu = ProjectUser.where("")
privs = []
privs << "r" if params[:r] == "1"
privs << "w" if params[:w] == "1"
privs << "a" if params[:a] == "1"
@priv = privs.join("")
@project_us... | [
"def add_users\n if @project.user_id == current_user.id\n success = []\n errors = []\n @users.each do |user|\n new_user = create_user(user, @project)\n new_user.valid? ? success << new_user : errors << new_user.errors\n end\n if errors.empty?\n success.each { |user| ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hospitalization_days GET /hospitalization_days.json | def index
@hospitalization_days = HospitalizationDay.all
end | [
"def days\n find_period :days\n end",
"def valid_er_hour_days(date)\n semester = Semester.around_date(date).first\n\n days = []\n semester.starts_at.upto(semester.ends_at) do |idate|\n # This date format is tuned to JQuery Datepicker\n days << idate.strftime(\"%d/%m/%Y\") unless sem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /hospitalization_days POST /hospitalization_days.json | def create
@hospitalization_day = @adverse_event.hospitalization_days.create(hospitalization_day_params)
respond_to do |format|
if @hospitalization_day.save
format.html { redirect_to adverse_event_path(@adverse_event), notice: 'Día de estancia ingresado satisfactoriamente.' }
format.json ... | [
"def create\n @day = @user.days.new(params[:day])\n\n respond_to do |format|\n if @day.save\n format.html { redirect_to user_days_path(@user), notice: 'Day Awrad was successfully saved.' }\n format.json { render json: @day, status: :created, location: @day }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /hospitalization_days/1 PATCH/PUT /hospitalization_days/1.json | def update
respond_to do |format|
if @hospitalization_day.update(hospitalization_day_params)
format.html { redirect_to adverse_event_path(@adverse_event), notice: 'Día de estancia actualizado satisfactoriamente.' }
format.json { render :show, status: :ok, location: @hospitalization_day }
... | [
"def update\n @day = Day.find(params[:id])\n\n if @day.update(params[:day])\n head :no_content\n else\n render json: @day.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @daily_happiness.update(daily_happiness_params)\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /hospitalization_days/1 DELETE /hospitalization_days/1.json | def destroy
@hospitalization_day.destroy
respond_to do |format|
format.html { redirect_to hospitalization_days_url, notice: 'Día de estancia eliminado satisfactoriamente.' }
format.json { head :no_content }
end
end | [
"def destroy\n @hospitalization = Hospitalization.find(params[:id])\n @hospitalization.destroy\n\n respond_to do |format|\n format.html { redirect_to client_hospitalizations_url(@client) }\n format.json { head :ok }\n end\n end",
"def destroy\n @admission = Admission.find(params[:admissi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get metadata proxy status Get metadata proxy status | def read_metadata_proxy_status(metadata_proxy_id, opts = {})
data, _status_code, _headers = read_metadata_proxy_status_with_http_info(metadata_proxy_id, opts)
data
end | [
"def read_metadata_proxy_status_0(metadata_proxy_id, opts = {})\n data, _status_code, _headers = read_metadata_proxy_status_0_with_http_info(metadata_proxy_id, opts)\n data\n end",
"def get_metadata_proxy_status(proxy_id, logical_switch_id, opts = {})\n data, _status_code, _headers = get_metadat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get metadata proxy status Get metadata proxy status | def read_metadata_proxy_status_0(metadata_proxy_id, opts = {})
data, _status_code, _headers = read_metadata_proxy_status_0_with_http_info(metadata_proxy_id, opts)
data
end | [
"def read_metadata_proxy_status(metadata_proxy_id, opts = {})\n data, _status_code, _headers = read_metadata_proxy_status_with_http_info(metadata_proxy_id, opts)\n data\n end",
"def get_metadata_proxy_status(proxy_id, logical_switch_id, opts = {})\n data, _status_code, _headers = get_metadata_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
play the given minefield | def play(minefield)
raise 'Already playing a game!' unless @minefield.nil?
setup(minefield)
DISPLAY.call @minefield
reveal @minefield.cell_at(@minefield.first_click)
won = play_out
DISPLAY.call @minefield
clean_up
won
end | [
"def play_game\n # WarAPI.play_turn()\n end",
"def play\n\t\tgame_loop\n\tend",
"def start_play\n match.save!\n if match.play_match? :start_play\n match.play_match! :start_play\n end\n end",
"def in_play!\n\t\t@in_play = true\n\t\tself\n\tend",
"def perform\n\t\tself.begin_game\n\t\twhile... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
implementations of Player should overwrite the methods below as appropriate setup and clean_up should call super triggered when the minefield successfully reveals a cell, either from a chosen move or cascading reveal | def notify_revealed(cell); end | [
"def on_actor_ok\n \n #\n action = BattleManager.actor.input\n action.effect_area = $game_temp.grid[1]\n #\n \n targs = []\n for i in 0...$game_temp.grid[1].size\n targs.push($game_temp.grid[0][$game_temp.grid[1][i]].get_unit)\n end\n if BattleManager.actor.input.item.for_friend?\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
triggered when the minefield successfully flags a cell | def notify_flagged(cell); end | [
"def flag(cell)\n announce_flag(cell)\n @minefield.flag(cell)\n end",
"def notify_unflagged(_cell); end",
"def notify_revealed(cell); end",
"def unflag(cell)\n announce_unflag(cell)\n @minefield.unflag(cell)\n end",
"def unflag(cell)\n return DISPLAY.call('Attempted to unflag cell not in mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
triggered when the minefield successfully removes a flag from a cell | def notify_unflagged(_cell); end | [
"def unflag(cell)\n announce_unflag(cell)\n @minefield.unflag(cell)\n end",
"def unflag(cell)\n return DISPLAY.call('Attempted to unflag cell not in minefield') && false unless include?(cell)\n return false unless cell.unflag\n\n @num_flagged -= 1\n @player&.notify_flagged(cell)\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the player's first click choice, otherwise random to be implemented by children | def choose_first_click; end | [
"def select_first_player\n # random turn of the players\n @first_player = @players.sample\n if @first_player == @players[0]\n @second_player = @players[1]\n else\n @second_player = @players[0]\n end\n end",
"def choose_first\n num = 1 + rand(2)\n puts \"Player #{num} will start the... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mark a cell as a mine without revealing it | def flag(cell)
announce_flag(cell)
@minefield.flag(cell)
end | [
"def flag_cell!(cell)\n decr_mines unless remove_cell(cell).nil?\n end",
"def assign_mine_to_tile(row, column)\n tile = get_tile(row, column)\n tile.hidden_symbol = \"*\"\n end",
"def contains_mine?(row, col)\n if @grid[row][col].mine == true\n @mines_revealed = true\n return true... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
unmark a cell as a mine so it can be revealed | def unflag(cell)
announce_unflag(cell)
@minefield.unflag(cell)
end | [
"def unflag(cell)\n return DISPLAY.call('Attempted to unflag cell not in minefield') && false unless include?(cell)\n return false unless cell.unflag\n\n @num_flagged -= 1\n @player&.notify_flagged(cell)\n end",
"def flag_cell!(cell)\n decr_mines unless remove_cell(cell).nil?\n end",
"def uncov... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the deleted paragraph is a winner, and if so, removes the winning id from the scene. | def paragraph_cleanup
if self.scene.winner_id == self.id
self.scene.winner_id = nil
self.scene.save
end
end | [
"def unwinner\n @p = Paragraph.find(params[:id])\n if @p.is_winner?\n @p.unset_as_winner\n end\n Version.create!({:item_type => \"Paragraph\",\n :item_id => @p.id,\n :event => \"unwin\",\n :whodunnit => current_user.id,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /unit_names GET /unit_names.json | def index
@unit_names = UnitName.all
end | [
"def foods_units\n get('/foods/units.json')\n end",
"def food_units\n get('foods/units.json')\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /unit_names POST /unit_names.json | def create
@unit_name = UnitName.new(unit_name_params)
respond_to do |format|
if @unit_name.save
format.html { redirect_to @unit_name, notice: 'Unit name was successfully created.' }
format.json { render action: 'show', status: :created, location: @unit_name }
else
format.ht... | [
"def index\n @unit_names = UnitName.all\n end",
"def destroy\n @unit_name.destroy\n respond_to do |format|\n format.html { redirect_to unit_names_url }\n format.json { head :no_content }\n end\n end",
"def create\n post_params = {\n name: params[:name].downcase,\n units: par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /unit_names/1 PATCH/PUT /unit_names/1.json | def update
respond_to do |format|
if @unit_name.update(unit_name_params)
format.html { redirect_to @unit_name, notice: 'Unit name was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @unit_name... | [
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /unit_names/1 DELETE /unit_names/1.json | def destroy
@unit_name.destroy
respond_to do |format|
format.html { redirect_to unit_names_url }
format.json { head :no_content }
end
end | [
"def destroy\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert HTML row into bike trip object | def row_to_trip(row)
trip = BikeTrip.new
trip_attributes = [:id, :start_location, :start_time, :end_location,
:end_time, :duration]
trip_attributes.each_with_index do |name, i|
trip.send("#{name}=", row.at_xpath("td[#{i + 1}]/text()").to_s.strip)
end
trip
end | [
"def parse_trip(data)\n res = CGI.unescapeHTML(data.force_encoding('utf-8'))\n t={}\n t[:trip] = res.scan(/<h2 class=\"u-left\">\\s(.*)\\s*<\\/h2>/).flatten.map{|c| c.strip!}.first.gsub(\"→\", \"->\")\n t[:when] = parse_time(res.scan(/<p class=\"my-trip-elements size16 u-left no-clear my-trip-date\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure PNG sizes are determined correctly | def test_png_size_determined_correctly
assert_equal [120, 175], @page.get_png_size(@test_png)
end | [
"def resize_needed_for?(format, size)\n return false if size == 'raw'\n\n # 加工が指定されているなら必要\n w, h, method = size.scan(/(\\d+)x(\\d+)([a-z]*\\d*)/).shift\n return true if method && !method.empty?\n\n # オリジナルの画像サイズと比較\n w, h = [w, h].map{|i| i.to_i}\n begin\n if w > width && h > height\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure legacy browsers are detected as such | def test_legacy_browser_detected
for browser in LEGACY_BROWSERS
@request.user_agent = browser
assert @page.legacy_browser?
end
end | [
"def legacy_browser?\n request.user_agent =~ /MSIE\\s+(5\\.5|6\\.)/\n end",
"def check_for_modern_browser\n if browser.ie6? || browser.ie7?\n render(:template => \"errors/error_old_browser\", :status => 401)\n end\n end",
"def check_browser\n @bad_browser = false\n agent = request.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure current browsers are detected as such | def test_current_browsers_detected
for browser in CURRENT_BROWSERS
@request.user_agent = browser
assert ! @page.legacy_browser?
end
end | [
"def check_browser\n @bad_browser = false\n agent = request.env['HTTP_USER_AGENT']\n if (agent =~ /windows/i) and (agent =~ /msie/i)\n @bad_browser = true\n if (agent =~ /opera/i)\n @is_opera = true\n end\n end\n end",
"def legacy_browser?\n request.user_agent =~ /MSIE\\s+(5\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A adding history record and save method. It accepts a parameter array which is collected any produced after the test completion. | def add_history_and_save(array = [total_score, correct_count, incorrect_count, type, quiz_name, user_name, mode])
if @history.nil?
creat_empty_history
new_history_Id = 1
elsif @history["Records"].empty?
new_history_Id = 1
else
new_history_Id = @history["Records"].map { |h| h['Id'] }.... | [
"def save_history=(*opts, &b); end",
"def record_history! hash = nil\n if @history\n hash ||= yield\n hash.update(@history_data) if @history_data\n @history.send(@history_append, hash)\n end\n\n self\n end",
"def set_history_array\n if self.history == nil\n self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the count of services in the group creds contained in +hash_array+ | def service_count_for_hashes(hash_array)
hash_array.collect(&:service).collect(&:id).uniq.size
end | [
"def createHashfrom array\n counts = Hash.new 0\n array.each do |user|\n counts[user] += 1\n end\n return counts\n end",
"def get_count(array)\n JavaScriptCore::Lib.JSPropertyNameArrayGetCount(array)\n end",
"def count_each(arr)\n arr.each_with_object(Hash.new(0)) { |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts a partofspeech entity reference string into a symbol | def pos_to_sym(entity)
entity.gsub('-', '_').to_sym
end | [
"def on_dyna_symbol(string_content); end",
"def to_symbol(text)\n text.gsub(/\\:/i, '').to_sym\nend",
"def get_symbol(state)\n symbols[normalize_text(state)]\n end",
"def SymbolLiteral(value); end",
"def extract_symbol_content(ast_node)\n ast_node.source.gsub(/(?:^:|:$)/, '').gsub(/(?:^['\"]|[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a schema class name from the given +statement_name+. | def schema_name_for(statement_name)
unless statement_name =~ STATEMENT_NAME_REGEXP
raise ArgumentError, "statement '#{statement_name}' name must match #{STATEMENT_NAME_REGEXP.inspect}"
end
const_name = statement_name.to_s
if const_name == "schema"
"#{self.name}::Schema"
els... | [
"def statement_name\n self.name.underscore.sub(/^.*\\//, '').sub(/_schema$/, '')\n end",
"def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end",
"def class_name(table_name) # :nodoc:\n # remove any prefix and/or su... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test whether a schema is defined for the given +statement_name+. | def schema_defined_for?(statement_name)
!!schema_for(statement_name)
end | [
"def schema_exists?(name); end",
"def schema_exists?(name)\n select_value(\"SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{name}'\", 'SCHEMA').to_i > 0\n end",
"def schema_exists?(schema_name, db_name)\n psql_cmd([\"-d '#{db_name}'\",\n \"-c 'select schema_name from information_sch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turn the given string (assuming it is a constraint name) into a validator class name string. | def validator_name_for(constraint_name)
"#{self.name}::#{constraint_name.to_s.camelize}Validator"
end | [
"def validator_for(constraint_name)\n validator_name_for(constraint_name).safe_constantize\n end",
"def valid_class_factory_name(klass)\n \"valid_#{class_factory_name(klass)}\"\n end",
"def default_validator_name\n self.to_s.split('::').last.underscore\n end",
"def get_rule_class_by_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turn the given +constraint_name+ into a validator class symbol. Return +nil+ if the validator class does not exist. | def validator_for(constraint_name)
validator_name_for(constraint_name).safe_constantize
end | [
"def validator_name_for(constraint_name)\n \"#{self.name}::#{constraint_name.to_s.camelize}Validator\"\n end",
"def require_validator(short_name)\n str_name = short_name.to_s\n validators.fetch(str_name) do\n Grape::Validations::Validators.const_get(\"#{str_name.camelize}Validator\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test whether a validator is defined for the given +constraint_name+. | def validator_defined_for?(constraint_name)
!!validator_for(constraint_name)
end | [
"def validator_for(constraint_name)\n validator_name_for(constraint_name).safe_constantize\n end",
"def validate_constraint(name)\n @operations << {:op => :validate_constraint, :name => name}\n end",
"def validate_constraint(table_name, constraint_name); end",
"def validator_name_for(const... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tableaus or /tableaus.json | def create
@tableau = Tableau.new(tableau_params)
respond_to do |format|
if @tableau.save
format.html { redirect_to @tableau, notice: "Tableau was successfully created." }
format.json { render :show, status: :created, location: @tableau }
else
format.html { render :new, stat... | [
"def create\n @tableau = Tableau.new(tableau_params)\n\n respond_to do |format|\n if @tableau.save\n format.html { redirect_to @tableau, notice: 'Tableau was successfully created.' }\n format.json { render :show, status: :created, location: @tableau }\n else\n format.html { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a new post POST /videos | def create
vid = Video.create(video_params)
redirect_to "/videos/#{vid.id}"
end | [
"def create\n @video = Video.new(video_params)\n\n if @video.save\n render json: @video, status: :created, location: @video\n else\n render json: @video.errors, status: :unprocessable_entity\n end\n end",
"def create\n @video = Video.new(video_params)\n if @video.save\n rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
edit post form GET /videos/:id/edit | def edit
@video = Video.find(params['id'])
end | [
"def edit\n @video = Video.find(params[:id])\n end",
"def edit\n @movie = Movie.find params[:id]\n end",
"def update\n respond_to do |format|\n if @video.update(video_params)\n format.html { redirect_to [:admin, @video], notice: 'Video was successfully updated.' }\n format.json { h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update an existing post PUT /videos/:id | def update
Video.find(params[:id]).update(video_params)
redirect_to "/videos/#{params[:id]}"
end | [
"def update\n @video.update(video_params)\n render json: @video\n end",
"def update\n @api_v1_video = Api::V1::Video.find(params[:id])\n\n if @api_v1_video.update(api_v1_video_params)\n head :no_content\n else\n render json: @api_v1_video.errors, status: :unprocessable_entity\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /search_pages/1 GET /search_pages/1.json | def show
@search_page = SearchPage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @search_page }
end
end | [
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /search_pages/new GET /search_pages/new.json | def new
@search_page = SearchPage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @search_page }
end
end | [
"def new\n @page = current_site.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /search_pages POST /search_pages.json | def create
@search_page = SearchPage.new(params[:search_page])
respond_to do |format|
if @search_page.save
format.html { redirect_to @search_page, notice: 'Search page was successfully created.' }
format.json { render json: @search_page, status: :created, location: @search_page }
el... | [
"def new\n @search_page = SearchPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @search_page }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /search_pages/1 PUT /search_pages/1.json | def update
@search_page = SearchPage.find(params[:id])
respond_to do |format|
if @search_page.update_attributes(params[:search_page])
format.html { redirect_to @search_page, notice: 'Search page was successfully updated.' }
format.json { head :no_content }
else
format.html {... | [
"def update\n @search_page.attributes = params[:search_page]\n\n respond_to do |format|\n if @search_page.save(:user => current_user)\n format.html { render 'admin/shared/update' }\n format.xml { head :ok }\n else\n format.html { render :template => 'admin/shared/edit', :locals... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /search_pages/1 DELETE /search_pages/1.json | def destroy
@search_page = SearchPage.find(params[:id])
@search_page.destroy
respond_to do |format|
format.html { redirect_to search_pages_url }
format.json { head :no_content }
end
end | [
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def destroy\n @page = Page.get(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Pag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Links package names based on regex. Example: link_regex(/(github:|:github =>)\s['"](?[^'"]+)['"]/) Will link `user/repo` in `github: "user/repo"` or `:github => "user/repo"` | def link_regex(regex, &url_proc)
highlighted_lines.map!.with_index do |rich_line, i|
marker = StringRegexMarker.new(plain_lines[i].chomp, rich_line.html_safe)
marker.mark(regex, group: :name) do |text, left:, right:|
url = yield(text)
url ? link_tag(text, url) : text... | [
"def link_regex(regex)\n highlighted_lines.map!.with_index do |rich_line, i|\n marker = StringRegexMarker.new(plain_lines[i], rich_line.html_safe)\n\n marker.mark(regex, group: :name) do |text, left:, right:|\n url = block_given? ? yield(text) : package_url(text)\n pac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run a sample application or any user application with jruby | def run
return puts("usage example: glimmer run tictactoe") unless @name
# Search for the filename (and add the .rb extension if not provided), and run it
if File.exist?("#{@name}#{'.rb' unless @name =~ /.rb$/}")
command = "#{JRUBY_COMMAND} \"#{@name.gsub(/\\/, '/')}#{'.rb' unless @name =~ /.rb$/}... | [
"def jruby_oop(*args)\n prev_in_process = JRuby.runtime.instance_config.run_ruby_in_process\n JRuby.runtime.instance_config.run_ruby_in_process = false\n if block_given?\n yield args\n else\n `#{RUBY} #{args.join(' ')}`\n end\n ensure\n JRuby.runtime.instance_config.run_ruby_in_process ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Writes method to choose crud type | def write_crud_by_type(menu, crud_type)
column_names = @@selected_table.columns.map(&:name)
crud_by_options = [:all].concat(column_names)
crud_column_menu = CliBuilder::Menu.new(title: "Select Type of CRUD", menu_options: crud_by_options, menu_type: "crud")
menu.define_si... | [
"def desired_type; end",
"def crud_class(classname)\n set_crud_class(classname)\n\n @view_path = File.join(File.dirname(__FILE__), \"..\", \"..\", \"app\", \"views\", \"autocrud\")\n @app_view_path = File.join(Rails.root.join('app','views','autocrud'))\n\n @custom_view_paths = []\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a find on a model with a :select option, add to the :select statement any fields needed to finalize preload_associations and associate the records with their source records | def add_association_keys_to_select(options)
return options[:select] unless options[:include]
select_table_fields = split_table_fields(options[:select])
select_table_fields.concat add_association_keys_to_select_sub(self, options)
reform_select_from_fields(select_table_fields.uniq)... | [
"def find_options\n opt = {:conditions => conditions, :limit => @limit, :order => \"#{@id_clause} #{@order}\"}\n if columns = @options[:select]\n opt[:select] = columns\n end\n opt[:joins] = @joins if @joins\n opt\n end",
"def collect_for_bar_association_select(select=false)\n result = Bar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a class and an association (reflection), add the appropriate primary or foreign keys to the array of fields that must be returned for the association records to be attached to their source classes | def association_keys_for(klass, association_name)
select_table_fields = []
# make sure there is a reflection with this name
if r = klass.reflections[association_name]
if r.macro == :belongs_to
# A :belongs_to B => [a, r.primary_key], [b, b.primary_key]
... | [
"def include_fields_into(dynamic_methods_module, association_name, target_class, options)\n each_field do |field_definition|\n field_definition.add_methods_to_included_class!(dynamic_methods_module, association_name, target_class, options)\n end\n end",
"def include_fields_into(dynamic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return an array of a class's primary key fields eg: [[table, id]] or [[table, id1], [table, id2]] | def class_primary_key_fields(klass)
fields = []
if klass.primary_key.class == Array || klass.primary_key.class == CompositePrimaryKeys::CompositeKeys
klass.primary_key.each do |pk|
fields << [klass.table_name, pk.to_s]
end
else
fields << [k... | [
"def primary_key\n fields.select { |f| f.key }.map(&:name)\n end",
"def primary_keys\n pluck(source.primary_key)\n end",
"def ids\n pluck primary_key\n end",
"def pk_values\n pk_columns.map { |col|\n @row[ col ]\n }\n end",
"def primary_key_columns\n @col... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
EOL: used to grab only the select fields that to pertain to this table given: [['users', 'name'], ['terms', 'definition', ' as term_d'], ['friends', '']] returns: `users`.`name`, `terms`.`definition` as term_d, `friends`. | def reform_select_from_fields(table_fields)
# if we're asking for * then ignore all other individual fields
table_fields.each do |tf|
if tf[1] == '*'
table_fields.delete_if {|k| k[0] == tf[0] && k[1] != '*'}
end
end
# re-form the s... | [
"def reform_select_from_fields(table_fields)\n # if we're asking for * then ignore all other individual fields\n table_fields.each do |tf|\n if tf[1] == '*'\n table_fields.delete_if {|k| k[0] == tf[0] && k[1] != '*'}\n end\n end\n \n # re-form the sele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: autoken(id) autoken(:any) Returns user's token by primary key. Use :any to get random user. | def autoken(id)
ConsoleUtils.auto_token_for(id)
end | [
"def generate_token\n u = User.find(params[:id])\n Token.generate(u)\n redirect_to root_path\n end",
"def user_token\n @user_token ||= (\n if params['token_type'] == 'user'\n self\n elsif params['authed_user']\n self.class.from_hash(client, params... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /api/v1/outcomes GET /api/v1/outcomes.json | def index
@api_v1_outcomes = Api::V1::Outcome.all
end | [
"def index\n @outcomes = Outcome.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outcomes }\n end\n end",
"def index\n @ideal_outcomes = IdealOutcome.all\n end",
"def show\n @outcome = Outcome.find(params[:id])\n\n respond_to do |forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /api/v1/outcomes POST /api/v1/outcomes.json | def create
@api_v1_outcome = Api::V1::Outcome.new(api_v1_outcome_params)
respond_to do |format|
if @api_v1_outcome.save
format.html { redirect_to @api_v1_outcome, notice: 'Outcome was successfully created.' }
format.json { render :show, status: :created, location: @api_v1_outcome }
... | [
"def create\n @outcome = Outcome.new(params[:outcome])\n\n respond_to do |format|\n if @outcome.save\n format.html { redirect_to @outcome, notice: 'Outcome was successfully created.' }\n format.json { render json: @outcome, status: :created, location: @outcome }\n else\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /api/v1/outcomes/1 PATCH/PUT /api/v1/outcomes/1.json | def update
respond_to do |format|
if @api_v1_outcome.update(api_v1_outcome_params)
format.html { redirect_to @api_v1_outcome, notice: 'Outcome was successfully updated.' }
format.json { render :show, status: :ok, location: @api_v1_outcome }
else
format.html { render :edit }
... | [
"def update\n @outcome = Outcome.find(params[:id])\n\n respond_to do |format|\n if @outcome.update_attributes(params[:outcome])\n format.html { redirect_to @outcome, notice: 'Outcome was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /api/v1/outcomes/1 DELETE /api/v1/outcomes/1.json | def destroy
@api_v1_outcome.destroy
respond_to do |format|
format.html { redirect_to api_v1_outcomes_url, notice: 'Outcome was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @outcome = Outcome.find(params[:id])\n @outcome.destroy\n\n respond_to do |format|\n format.html { redirect_to outcomes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @outcome = Outcome.find(params[:id])\n @outcome.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
params["promotion[groupon_codes_file]"] has the upload file with one groupon code per line | def store_groupon_codes
if @promotion.is_groupon_style? && @groupon_codes_file
Rails.logger.warn("Promo is groupon style : #{@promotion.id}")
successful_imports = 0
unsuccessful_imports = 0
data = @groupon_codes_file.read
CSV.parse(data) do |row|
next if row.join.blank?
... | [
"def group_line(line)\n line.strip!\n f = Tempfile.new(\"single_group\")\n f.write(line)\n # wrap around UploadFile class for easier handling\n self.file = ActionDispatch::Http::UploadedFile.new( tempfile: f, filename: 'single_group.in')\n self.preprocess_file\n output = self.group\n File.op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroys the window by sending the SIGINT signal (the window has its own handlers to destroy itself, so it's not our job). Does not wait for anything. | def close
SLogger.debug("[client] interrupting window (#{@window_pid})...")
Process.kill(:INT, @window_pid)
end | [
"def destroy_window (*args)\n destroy_window!(*args).abandon\n end",
"def CloseWindow\n @window.hide\n Gtk.main_quit\n end",
"def destroy\n # Clean up the windows.\n CDK.deleteCursesWindow(@win)\n CDK.deleteCursesWindow(@shadow_win)\n\n # Clean the key bindings\n self.cle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
for the hooks which failed, unlock those records so that thet can be reprocessed later Author: Puneet Date: 11/11/2017 Reviewed By: | def release_lock_and_update_status_for_non_processed_hooks
@hooks_to_be_processed.each do |hook|
failed_hook_to_be_retried = @failed_hook_to_be_retried[hook.id]
hook.mark_failed_to_be_retried(failed_hook_to_be_retried) if failed_hook_to_be_retried.present?
failed_hook_to_be_igno... | [
"def resend_unlock_instructions; end",
"def acquire_lock_on_failed_hooks\n hook_model_klass.lock_failed_hooks(@lock_identifier)\n end",
"def check_to_unlock submission, bypass_archive_check = false\n result = []\n criteria_result = criteria_check\n\n if criteria_result && (!self.passed or b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Acquire lock on Failed Hooks which have to be retired Author: Puneet Date: 11/11/2017 Reviewed By: | def acquire_lock_on_failed_hooks
hook_model_klass.lock_failed_hooks(@lock_identifier)
end | [
"def release_lock_and_update_status_for_non_processed_hooks\n\n @hooks_to_be_processed.each do |hook|\n\n failed_hook_to_be_retried = @failed_hook_to_be_retried[hook.id]\n hook.mark_failed_to_be_retried(failed_hook_to_be_retried) if failed_hook_to_be_retried.present?\n\n failed_hoo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Acquire lock on Fresh Hooks which have to be executed Author: Puneet Date: 11/11/2017 Reviewed By: | def acquire_lock_on_fresh_hooks
hook_model_klass.lock_fresh_hooks(@lock_identifier)
end | [
"def acquire_lock_on_failed_hooks\n hook_model_klass.lock_failed_hooks(@lock_identifier)\n end",
"def update_locked_state() end",
"def exclusive_hook; end",
"def try_lock() end",
"def hook1; end",
"def release_lock_and_update_status_for_non_processed_hooks\n\n @hooks_to_be_processed.eac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUBLIC INSTANCE METHODS Checks to see if its safe to delete the organization. If there are other members in the organization and the current user is the owner then ownership must be changed to another user. This method will just raise a validation error. | def check_org
# Ok to delete if there is no organization related to the current
# user object.
return true unless self.owns?
org = self.owns
# Ok to delete if the organization is owned by the current user
# and the current user is the only member
return true if (org.users.count == 1) &&
... | [
"def destroy?\n organization = contributor.organization\n\n if user.admin_of_organization?(organization)\n if contributor.admin?\n !contributor.only_admin?\n else\n true\n end\n end\n end",
"def destroy\n org = Org.includes(:users, :templates, :guidance_groups).find(par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /developers GET /developers.json | def index
@developers = Developer.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @developers }
end
end | [
"def index\n @developers = Developer.all\n render_json_for_api @developers\n end",
"def developers\n self.sitemap\n self.follow('dtime:dashboard:developers')\n self.get\n self\n end",
"def list_developers\n @list = Developer.order(params[:order]).page(params[:page]).per(20)\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /developers/1 GET /developers/1.json | def show
@developer = Developer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @developer }
end
end | [
"def index\n @developers = Developer.all\n render_json_for_api @developers\n end",
"def index\n @developers = Developer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @developers }\n end\n end",
"def show\n @project_developer = ProjectDev... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /developers/1 DELETE /developers/1.json | def destroy
@developer = Developer.find(params[:id])
@developer.destroy
respond_to do |format|
format.html { redirect_to developers_url }
format.json { head :no_content }
end
end | [
"def destroy\n @developer.destroy\n respond_to do |format|\n format.html { redirect_to developers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_developer = ProjectDeveloper.find(params[:id])\n @project_developer.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /telefono_empresa_clientes/1 GET /telefono_empresa_clientes/1.xml | def show
@telefono_empresa_cliente = TelefonoEmpresaCliente.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @telefono_empresa_cliente }
end
end | [
"def index\n @clienteles = @paramun.clienteles\n\n respond_to do |format|\n if @clienteles.empty?\n format.xml { render request.format.to_sym => \"ccliErreurA\" } ## Aucune Clientele\n else \n format.xml { render xml: @clienteles }\n end\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /telefono_empresa_clientes POST /telefono_empresa_clientes.xml | def create
@telefono_empresa_cliente = TelefonoEmpresaCliente.new(params[:telefono_empresa_cliente])
respond_to do |format|
if @telefono_empresa_cliente.save
format.html { redirect_to(@telefono_empresa_cliente, :notice => 'Telefono empresa cliente was successfully created.') }
format.xml ... | [
"def create\n @telefone_cliente = TelefoneCliente.new(telefone_cliente_params)\n\n respond_to do |format|\n if @telefone_cliente.save\n format.html { redirect_to @telefone_cliente, notice: 'Telefone cliente was successfully created.' }\n format.json { render :show, status: :created, locatio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /telefono_empresa_clientes/1 PUT /telefono_empresa_clientes/1.xml | def update
@telefono_empresa_cliente = TelefonoEmpresaCliente.find(params[:id])
respond_to do |format|
if @telefono_empresa_cliente.update_attributes(params[:telefono_empresa_cliente])
format.html { redirect_to(@telefono_empresa_cliente, :notice => 'Telefono empresa cliente was successfully updat... | [
"def update\n @ventas_cliente = Ventas::Cliente.find(params[:id])\n\n respond_to do |format|\n if @ventas_cliente.update_attributes(params[:ventas_cliente])\n format.html { redirect_to @ventas_cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /telefono_empresa_clientes/1 DELETE /telefono_empresa_clientes/1.xml | def destroy
@telefono_empresa_cliente = TelefonoEmpresaCliente.find(params[:id])
@telefono_empresa_cliente.destroy
respond_to do |format|
format.html { redirect_to(telefono_empresa_clientes_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @tcliente = Tcliente.find(params[:id])\n @tcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(tclientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @telefono = Telefono.find(params[:id])\n @telefono.destroy\n\n respond_to do |fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
queries constructs a case policy | def policy
return Case::Policy.new(user, self.case)
end | [
"def case_expression_sql(ce)\n \"(CASE #{ce.conditions.collect{|c,r| \"WHEN #{literal(c)} THEN #{literal(r)} \"}.join}ELSE #{literal(ce.default)} END)\"\n end",
"def keyword\n 'case'\n end",
"def case_expression_sql(ce)\n sql = '(CASE '\n sql << \"#{literal(ce.expression)} \" if ce... | {
"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.