query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Vault supports multiple instances of the 'approle' backend mounted concurrently. The mapreducey method repo_files gets the list of approle mounts, calls role_files() once for each of the mounts, then concatenates all those filenames into one big flat array | def repo_files
@vault.sys.auths.select { |_,v| v.type == 'approle' }
.keys
.inject([]) { |acc, elem| acc + role_files(elem) }
end | [
"def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end",
"def create_file_accessors(specs, platform)\n name = specs.first.name\n pod_root = sandbox.pod_dir(name)\n path_list = @path_lists.f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check the rows of the grid If the row has 2 of one mark (X or Y), and one nil value, retun the index of the nil value | def row_winning_move
@board.grid.each_with_index do |row, r|
other_nil_index = contains_two_marks(row)
if(other_nil_index)
return [r, other_nil_index]
end
end
return false
end | [
"def find_empty_cell()\n\t$value_grid.each_with_index do |row, index_r|\n\t\trow.each_with_index do |col, index_c|\n\t\t\tif col.to_i == 0\n\t\t\t\treturn [index_r,index_c]\n\t\t\tend\n\t\tend\n\tend\n\treturn [$N,$N]\nend",
"def two_marks_in_a_row(hash)\n if hash[:mark_count] == 2 && hash[:nil_count] == 1\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets all the comments of a place ordered by date | def comments_of_place(place_id)
where(:place_id => place_id).sort_by(&:date)
end | [
"def comments\n @comments ||= Comment.filter(:post_id => id, :deleted => false).order(:created_at)\n end",
"def get_comments\n return Comment.where(design_problem_id: self.id).sort_by! { |x| x.created_at }.sort! { |a,b| b.created_at <=> a.created_at }\n end",
"def comments\n if @comment_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns false if the comment is an empty string or contains only whitespace characters | def validate_comment(comment)
/^\s*$/.match(comment).nil? ? true : false
end | [
"def validate_comment\n return true if self.comment == nil\n self.comment = self.comment.strip\n if self.comment == \"\"\n errors.add(:comment, 'must not be blank')\n return false\n end\n true\n end",
"def is_commented?(string)\n !!(string =~ /\\s*\\/\\//)\n end",
"def è_un_com... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes the service with the parameters needed and the micro services Params: therm:: therm used for the search location:: location for the search | def initialize(therms, location)
@github = Github::Service.new(therms, location)
@stackoverflow = Stackoverflow::Service.new(therms, location)
@acuk = AcUk::Service.new('')
end | [
"def init_search\n @kat ||= Kat.search\n @kat.query = @args.join(' ')\n @kat.options = @options\n end",
"def initialize\n load_references\n load_services\n end",
"def initialize(_params,_offset,_main_url,_logger)\n\t\tself.params = _params\n\t\tself.offset = _offset\n\t\tsel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ftypes GET /ftypes.json | def index
@ftypes = Ftype.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @ftypes }
end
end | [
"def index\n @type_fs = TypeF.all\n end",
"def types\n types = JSON.parse(connection.get(\"/Contact/Types\").body )\n end",
"def fee_types\n @client.make_request :get, settings_path('fee-types')\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ftypes/1 GET /ftypes/1.json | def show
@ftype = Ftype.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @ftype }
end
end | [
"def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end",
"def index\n @type_fs = TypeF.all\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ftypes/new GET /ftypes/new.json | def new
@ftype = Ftype.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @ftype }
end
end | [
"def new\n @type = Type.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end",
"def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /ftypes POST /ftypes.json | def create
@ftype = Ftype.create_ftype(params[:ftype], @user)
if @ftype.save
render json: {:code => 0}
else
render json: {:code => -1, :msg => "params invalid"}
end
end | [
"def create\n @type_f = TypeF.new(type_f_params)\n\n respond_to do |format|\n if @type_f.save\n format.html { redirect_to @type_f, notice: 'Type f was successfully created.' }\n format.json { render :show, status: :created, location: @type_f }\n else\n format.html { render :new ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /ftypes/1 PUT /ftypes/1.json | def update
@ftype = Ftype.find(params[:id])
respond_to do |format|
if @ftype.update_attributes(params[:ftype])
format.html { redirect_to @ftype, notice: 'Ftype was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
fo... | [
"def update_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end",
"def update\n json_update(factType,factType_params, FactType)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ftypes/1 DELETE /ftypes/1.json | def destroy
@ftype = Ftype.find(params[:id])
@ftype.destroy
respond_to do |format|
format.html { redirect_to ftypes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @type_f.destroy\n respond_to do |format|\n format.html { redirect_to type_fs_url, notice: 'Type f was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_type(id)\n delete(\"/types/#{id}\")\n end",
"def destroy\n @fish_type = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Listing of all volunteering positions. | def index
flash[:notice] = 'Due to an overwhelming response, we are running out of positions to fill. You may still apply, but doing so will add you to our waiting list. You will only be contacted if a position opens up and you are its next candidate.'
if @user and @user.is_elevated?
@volunteer_positions ... | [
"def index\n @valve_positions = ValvePosition.all\n end",
"def index\n @committee_positions = CommitteePosition.all\n end",
"def index\n @entried_positions = EntriedPosition.all\n end",
"def index\n @officer_positions = OfficerPosition.all\n end",
"def point_list\n @teams = Team.find_team... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show a specific volunteer position. | def show
authorize @volunteer_position
respond_with(@volunteer_position)
end | [
"def show\n @volunteer = Volunteer.find(params[:id])\n end",
"def show_position(position, wearer = \"You\")\n\n if wearer == \"You\"\n eq = @equipment[position]\n eq = eq.compact if eq\n if eq and not eq.empty?\n eq = eq.collect {|o| @inventory[o].name }.simple_list\n \"\\t#{eq... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Open page to create a new volunteer position. | def new
@volunteer_position = VolunteerPosition.new
authorize @volunteer_position
respond_with(@volunteer_position)
end | [
"def create\n @volunteer_position = VolunteerPosition.new(volunteer_position_params)\n authorize @volunteer_position\n @volunteer_position.save\n respond_with(@volunteer_position)\n end",
"def create\n @offertposition = Offertposition.new(offertposition_params)\n\n # write offertposition to dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Open page to edit a volunteer position. | def edit
authorize @volunteer_position
end | [
"def show\n authorize @volunteer_position\n respond_with(@volunteer_position)\n end",
"def proposeedit(id, name, address, city, state, zip, ll, options = {})\n post(\"venues/#{id}/proposeedit\", {\n :name => name,\n :address => address,\n :city => city,\n :state =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create the volunteer position and insert it into the database. | def create
@volunteer_position = VolunteerPosition.new(volunteer_position_params)
authorize @volunteer_position
@volunteer_position.save
respond_with(@volunteer_position)
end | [
"def assign_volunteer\n @volunteer_position = VolUserShift.find_by_id(params[:id])\n if params[:name] == 'None'\n @volunteer_position.update_attribute(:user_id, 1)\n else\n name = params[:name].split(\" \")\n @user = User.where(:first => name[0], :last => name[1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update an existing volunteer position record in the database. | def update
authorize @volunteer_position
@volunteer_position.update(volunteer_position_params)
respond_with(@volunteer_position)
end | [
"def update_position\n begin\n department = Department.find(params[:id])\n department.insert_at(params[:position].to_i)\n render :json => {:title => 'Success', :message => 'The department order was updated successfuly.'}\n rescue\n render :json => {:title => 'Error', :message => 'We ran in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroy an existing volunteer position record in the database. | def destroy
authorize @volunteer_position
@volunteer_position.destroy
respond_with(@volunteer_position)
end | [
"def destroy\r\n \r\n @position = Position.find(params[:id])\r\n\r\n @position.destroy\r\n \r\n respond_to do |format|\r\n format.html { redirect_to positions_url }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @position = Position.find(params[:id])\n @position.d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When a user is not authorized to do something in the context of volunteer positions, redirect them to the index & notify them why they're being redirected to the index. | def not_authorized
redirect_to volunteer_positions_url, alert: "You are not authorized to perform the requested action!"
end | [
"def action_not_authorized\n flash[:alert] = 'You are not authorized to perform this action.'\n redirect_to(request.referrer || root_path)\n end",
"def index\n flash[:notice] = 'Due to an overwhelming response, we are running out of positions to fill. You may still apply, but doing so will add you to ou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin rdoc Create all cache files =end | def create_cache_files
@cache_path_names = {}
each_file_set(:create_cache_file)
write_cache_path_file
end | [
"def cache_dir; end",
"def initialize_file_based_cache\n Dir.mkdir(\"cache\")\n @document_cache = ActiveSupport::Cache::FileStore.new(\"cache\")\n @file_based_cache = true\n end",
"def create_cache_files(index, width, height)\n larger = [width,height].max\n if larger < tile_size or tile_size =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Extracts the name of the asset type from the classname E.g. CachedAssetPackager::JavascriptAssetSet.new(files).asset_type => :javascript =end | def asset_type
return self.class.to_s.gsub(/^.*::/,'').gsub(/AssetSet/,'').gsub(/([^^])([A-Z])/,'$1_$2').downcase.to_sym
end | [
"def asset_type(path)\n file_extention = File.extname(path)\n case file_extention\n when \".js\" then \"script\"\n when \".css\" then \"style\"\n else return\n end\n end",
"def name\n return \"#{asset_subtype.name} - #{asset_tag}\"\n end",
"def type_label\n ::RDF::UR... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin rdoc Normalize a controller/action combination so that we do not need to store separate info for each controller/action combination, just for ones that have a unique file set =end | def normalize_request_params(controller_name,action_name)
return :_all, :_all unless @files[controller_name.to_sym]
return controller_name.to_sym, :_all unless @files[controller_name.to_sym][action_name.to_sym]
return controller_name.to_sym, action_name.to_sym
end | [
"def fill_controller_action_attributes\n return if controller_action.blank?\n route = controller_action.split('#')\n self.controller, self.action = route.first, route.last\n end",
"def normalize_controller!; end",
"def action_in_bem_format\n # split the full class name of the controller\n tokens... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expires the description fragment in the show method | def expire_desc
@place = Place.find(params[:id])
expire_fragment(:action => "show", :part => "description_#{@place.id}")
expire_fragment(:action => :show, :part => "nearby_places_#{@place.id}")
respond_to do |format|
format.html { redirect_to(@place, :notice => 'Place description was cleared.') }
... | [
"def expire_desc\n @route = Route.find(params[:id])\n expire_fragment(:action => \"show\", :part => \"description_#{@route.id}\")\n respond_to do |format|\n format.html { redirect_to(@route, :notice => 'Route cache was cleared.') }\n format.xml { head :ok }\n end\n end",
"def expire_desc\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search for places within this place if it has an area | def place_search
@places = []
area = params[:area_id].blank? ? nil : Place.find(params[:area_id])
if area.present? && area.area > 0
search_text = Riddle::Query.escape(help.strip_links(params[:search]))
results = Place.search(search_text, :field_weights => { :name => 10 })
results.each do ... | [
"def places\n Atlas::Place.find_from_search(*(query[:places] || []))\n end",
"def areas_within(areas)\n areas.select { |area| related?(area) }\n end",
"def contains\n json_response([inside: custom_pip?(@area, geo_jsonify(@location))])\n end",
"def containing(place_id, start... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
s:: string Unescape URL string | def url_unescape(s)
#Added this to make cadaver work
s = s.gsub("%28", "(").gsub("%29", ")")
URI.unescape(s)
end | [
"def url_unescape(s)\n URI.unescape(s)\n end",
"def unescape_uri(uri); end",
"def url_safe\n URI.parse(url).to_s\n rescue URI::InvalidURIError\n URI.escape url\n end",
"def unescape(value)\n value.gsub(UNESCAPE_RE) { |m| URI.decode_www_form_component(m) }\n end",
"def url_saf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return response to POST | def post
resource.post(request, response)
end | [
"def POST; end",
"def response\n @response ||= connection.post(query)\n end",
"def post\n status 404\n nil\n end",
"def cl_post\n response = send(POST_URL)\n # TODO: Verify response and mark vehicle as posted\n Success\n end",
"def post\n request_method('POST'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return response to MKCOL | def mkcol
resource.lock_check if resource.supports_locking?
status = resource.make_collection
gen_url = "#{scheme}://#{host}:#{port}#{url_format(resource)}" if status == Created
if(resource.use_compat_mkcol_response?)
multistatus do |xml|
xml.response do
xml.href ge... | [
"def http_mkcol(request, response)\n request_body = request.body_as_string\n path = request.path\n\n if !request_body.blank?\n content_type = request.header('Content-Type') || ''\n if content_type.index('application/xml') != 0 && content_type.index('text/xml') != 0\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
args:: Only argument used: :copy Move Resource to new location. If :copy is provided, Resource will be copied (implementation ease) | def move(*args)
unless(resource.exist?)
NotFound
else
resource.lock_check if resource.supports_locking? && !args.include?(:copy)
destination = url_unescape(env['HTTP_DESTINATION'].sub(%r{https?://([^/]+)}, ''))
dest_host = $1
if(dest_host && dest_host.gsub(/:\d{2,5}$/... | [
"def move(*args)\n unless(resource.exist?)\n NotFound\n else\n resource.lock_check if resource.supports_locking? && !args.include(:copy)\n destination = url_unescape(env['HTTP_DESTINATION'].sub(%r{https?://([^/]+)}, ''))\n dest_host = $1\n if(dest_host && dest_host.gsub(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Perform authentication NOTE: Authentication will only be performed if the Resource has defined an authenticate method | def authenticate
authed = true
if(resource.respond_to?(:authenticate, true))
authed = false
uname = nil
password = nil
if(request.env['HTTP_AUTHORIZATION'])
auth = Rack::Auth::Basic::Request.new(request.env)
if(auth.basic? && auth.credentials)
... | [
"def authenticate\n auth.call(:authenticate)\n end",
"def authenticate!\n @@authenticator.authenticate!\n end",
"def authenticate!\n raise AuthenticationFailed if authentication.failed?\n raise AuthenticationRequired unless authentication.authenticated?\n end",
"def authenticate\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Current request scheme (http/https) | def scheme
request.scheme
end | [
"def scheme\n\t\treturn self.headers.url_scheme || 'http'\n\tend",
"def scheme\n @scheme ||= headers[SCHEME_KEY]\n end",
"def scheme\n @url.scheme\n end",
"def scheme\n 'http'\n end",
"def get_protocol\n # from cloudflare\n if request.headers['Cf-Visitor']\n cf_scheme ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Root URI path for the resource | def root_uri_path
@options[:root_uri_path]
end | [
"def root; resource :path => '/'; end",
"def root\n @options[:root_uri_path]\n end",
"def root\n get URI(api_endpoint).path.sub(/\\/$/,'')\n end",
"def resource_uri\n path = datastore['URIPATH'] || random_uri\n path = '/' + path if path !~ /^\\//\n return path\n end",
"def resource... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
x:: request path Unescapes path and removes root URI if applicable | def clean_path(x)
ip = url_unescape(x)
ip.gsub!(/^#{Regexp.escape(root_uri_path)}/, '') if root_uri_path
ip
end | [
"def normalized_request_path(path)\n if path == \"/\"\n path\n else\n path.chomp(\"/\")\n end\n end",
"def normalized_request_path(request)\n path = request.path.gsub(%r{/+}, '/').sub(%r{/$}, '')\n path.empty? ? '/' : path\n end",
"def extract_path\n path = @req... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lock token if provided by client | def lock_token
env['HTTP_LOCK_TOKEN'] || nil
end | [
"def lock_token\n get_header 'HTTP_LOCK_TOKEN'\n end",
"def lock_token\n return nil if object[:lock_version].blank?\n @lock_token ||=\n Valkyrie::Persistence::OptimisticLockToken.new(\n adapter_id: resource_factory.adapter_id,\n token: object[:lock_version]\n )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Current HTTP version being used | def http_version
env['HTTP_VERSION'] || env['SERVER_PROTOCOL'] || 'HTTP/1.0'
end | [
"def http_version\n end",
"def http_version\n @http_version\n end",
"def http_version\n \"%d.%d\" % [self[:http_major], self[:http_minor]]\n end",
"def http_major; end",
"def http_version\n @parser.http_version\n end",
"def http_version\n @http_header.http_versi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find resources at depth requested | def find_resources(with_current_resource=true)
ary = nil
case depth
when 0
ary = []
when 1
ary = resource.children
else
ary = resource.descendants
end
with_current_resource ? [resource] + ary : ary
end | [
"def find_resources(path, node = raml)\n node.children.flat_map do |child|\n if child.kind_of?(::Raml::Resource) && child.resource_path == path\n child\n elsif child.respond_to?(:children)\n find_resources(path, child)\n else\n []\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
root_type:: Root tag name Render XML and set Rack::Responsebody= to final XML | def render_xml(root_type)
raise ArgumentError.new 'Expecting block' unless block_given?
doc = Nokogiri::XML::Builder.new do |xml_base|
xml_base.send(root_type.to_s, {'xmlns:D' => 'DAV:'}.merge(resource.root_xml_attributes)) do
xml_base.parent.namespace = xml_base.parent.namespace_definitio... | [
"def render_xml(root_type)\n raise ArgumentError.new 'Expecting block' unless block_given?\n doc = Nokogiri::XML::Builder.new do |xml_base|\n xml_base.send(root_type.to_s, {'xmlns:D' => 'DAV:'}.merge(resource.root_xml_attributes)) do\n xml_base.parent.namespace = xml_base.parent.namespace_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
block:: block Creates a multistatus response using render_xml and returns the correct status | def multistatus(&block)
render_xml(:multistatus, &block)
MultiStatus
end | [
"def multistatus\n\t\t\t\t\t_xml_render do |xml|\n\t\t\t\t\t\txml.multistatus 'xmlns' => 'DAV:' do\n\t\t\t\t\t\t\tyield xml\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tresponse.status = ::Rack::HTTP::Status::MultiStatus\n\t\t\t\tend",
"def setup_status_and_body\n @status, @body = @api_response['status']... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
xml:: Nokogiri::XML::Builder errors:: Array of errors Crafts responses for errors | def response_errors(xml, errors)
for path, status in errors
xml.response do
xml.href "#{scheme}://#{host}:#{port}#{URI.escape(path)}"
xml.status "#{http_version} #{status.status_line}"
end
end
end | [
"def to_xml(*args)\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?><errors>' <<\n @messages.map { |m| \"<error>#{m}</error>\" }.join('') <<\n '</errors>'\n end",
"def error(doc)\n begin\n xml_content xpath(doc,'//error').first\n rescue\n xml_content xpath(doc,'//errors').first... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
resource:: Resource elements:: Property hashes (name, namespace, children) Removes the given properties from a resource | def rm_properties(resource, elements)
for element, value in elements
resource.remove_property(element)
end
end | [
"def remove_resource!(resource)\n resource_id = resource!(resource).id\n resources_removed = [resource_id]\n\n if resource_parent = @_resources[resource_id][:parent]\n @_resources[resource_parent.id][:children].delete(resource_id)\n end\n\n @_resources[resource_id][:children].e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
resource:: Resource elements:: Property hashes (name, namespace, children) Sets the given properties | def set_properties(resource, elements)
stats = Hash.new { |h, k| h[k] = [] }
for element, value in elements
begin
stats[OK] << [element, resource.set_property(element, value)]
rescue Unauthorized => u
raise u
rescue Status
stats[$!.class] << element
... | [
"def create_resource(properties)\n resource = {}\n properties.each do |prop, value|\n ref = resource\n prop_array = prop.to_s.split(\".\")\n for p in 0..(prop_array.size - 1)\n is_array = false\n key = prop_array[p]\n # For properties that have array values, convert a name ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
xml:: Nokogiri::XML::Builder stats:: Array of stats Build propstats response | def propstats(xml, stats)
return if stats.empty?
for status, props in stats
xml.propstat do
xml.prop do
for element, value in props
defn = xml.doc.root.namespace_definitions.find{|ns_def| ns_def.href == element[:ns_href]}
if defn.nil?
... | [
"def propstats(response, stats)\n return if stats.empty?\n stats.each do |status, props|\n propstat = Ox::Element.new(D_PROPSTAT)\n prop = Ox::Element.new(D_PROP)\n\n props.each do |element, value|\n\n name = element[:name]\n if prefix = prefix_for(element[:ns_href])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Yields a list of `Resolv::IPv4` and `Resolv::IPv6` addresses for the given `name` and `resource_class`. | def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, &block)
query(name, resource_class) do |response|
# Resolv::DNS::Name doesn't retain the trailing dot.
name = name.sub(/\.$/, '')
case response
when Message
yield response.answer.select{|record| record[0].to_s == name}.c... | [
"def from_each_address(froms = @attributes[:from])\n from_each(froms) do |host_or_address, remote_interface_tag|\n case host_or_address\n when Host # specific host, specific remote interface\n host_or_address.interfaces[remote_interface_tag].each do |remote_interface|\n yield ho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets all contacts for the specified Team. NOTE: Does not return contacts which have not been assigned to an agent, ie. contacts that are still in the queue, or which have been missed. | def get_team_contacts(team_name, start_date, end_date)
get_agent_contacts(service_group_id: -1,
service_id: -1,
team_name: team_name,
agent_id: -1,
start_date: start_date,
end_date: end_date,
... | [
"def contacts\n contact_ids = @redis.smembers(\"contacts_for:#{entity.id}:#{check}\")\n\n if @logger\n @logger.debug(\"#{contact_ids.length} contact(s) for #{entity.id}:#{check}: \" +\n contact_ids.inspect)\n end\n\n entity.contacts + contact_ids.collect {|c_id|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets all contacts for the specified service, including those that are still in the queue or which have been missed. | def get_service_contacts(service_id, start_date, end_date)
get_agent_contacts(service_group_id: -1,
service_id: service_id,
team_name: '',
agent_id: -1,
start_date: start_date,
end_date: end_date,
... | [
"def queue_contacts\n @contacts.where(contact_type: 'PBX', direction: 'I', forwarded_to_agent: nil, call_ended: nil).where.not(service_id: 120)\n end",
"def contacts\n contact_ids = @redis.smembers(\"contacts_for:#{entity.id}:#{check}\")\n\n if @logger\n @logger.debug(\"#{contact_ids.le... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method for getting agent contacts | def get_agent_contacts(params)
message = {
serviceGroupID: params[:service_group_id],
serviceID: params[:service_id],
teamID: params[:team_name],
agentID: params[:agent_id],
startDate: params[:start_date],
endDate: params[:end_date],
contactTypes: params[:contact_type],
... | [
"def contacts\n # TODO: commercial has 2\n contacts = [primary_agent];\n end",
"def get_account_contacts\n acontacts = self.contact.accounts[0].present? ? (self.contact.accounts[0].contacts - [self.contact]) : []\n clientcontacts = self.matter_peoples.client_contacts\n acontacts - clientcontacts.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finally! a random pair generator written in ruby! | def generate_pairs
students.shuffle.each_slice(2).to_a
end | [
"def generate_key_pair\n\tg = 2\n\tp = generate_safe_prime(g)\n\td = rand(p)\n\te2 = ModMath.pow(g, d, p)\n\n\tpublic_key = [p, g, e2]\n\tprivate_key = [p, g, d]\n\n\treturn public_key, private_key\nend",
"def generate_pairs\n @pairs = []\n 3.times do\n @a = @students_id.sample(2)\n @pairs << @a\n #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Valida que la instancia prolog este activa ( que el archivo se haya abierto ) true: si esta activa false: si no esta activa | def validaInstancia
if @prolog == nil then
@textArea.setText("El archivo main debe abrirse\n")
return false
else
return true
end
end | [
"def ready_to_create?\n valid? && @processed && import_level_ok?\n end",
"def original_file_valid?\n\t\t\tFile.exists? @original_file\n\t\tend",
"def require_activation?\n !self.enabled? and !self.activation_code.blank?\n end",
"def file_valid?\n record.present? && record.file_attacher.file.pre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempt to detect the vcs for specified directory and add mapping as appropriate | def detect_vcs(directory)
if File.exist?("#{directory}/.git")
add_git(directory)
elsif File.exist?("#{directory}/.svn")
add_svn(directory)
end
end | [
"def get_vld_files_info(vld_dir, log_messages = true)\n vld_info = []\n all_dirs = Dir.glob(File.join(vld_dir, '*')) rescue []\n all_dirs.sort_by { |f| f.upcase }.each do |dd|\n dd_base = File.basename(dd)\n unless ChapmanCode.values.include?(dd_base)\n log_message(\"***WARNING... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def displayNetwork network_controller = NetworkController.new network_controller.profile = profile self.navigationController.pushViewController(network_controller, animated: true) end | def displayWalletActions
manage_wallet_controller = ManageWalletController.new
manage_wallet_controller.profile = profile
self.navigationController.pushViewController(manage_wallet_controller, animated: true)
end | [
"def discountClub\n c = SettingsDiscountClubController.new\n c.profile = self.profile\n self.navigationController.pushViewController(c, animated: true)\n end",
"def reports\n controller = ReportsController.new\n controller.profile = profile\n self.navigationController.pushViewController(control... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /furdos GET /furdos.json | def index
@furdos = Furdo.all
end | [
"def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end",
"def index\n @feriados = Feriado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feriados }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /furdos POST /furdos.json | def create
@furdo = Furdo.new(furdo_params)
respond_to do |format|
if @furdo.save
format.html { redirect_to @furdo, notice: 'Furdo was successfully created.' }
format.json { render :show, status: :created, location: @furdo }
else
format.html { render :new }
format.js... | [
"def create\n @foul = Foul.new(params[:foul])\n\n respond_to do |format|\n if @foul.save\n format.html { redirect_to @foul, :notice => 'Foul was successfully created.' }\n format.json { render :json => @foul, :status => :created, :location => @foul }\n else\n format.html { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert it to [a1, b1, c1, a2, b2, c2, ..., aN, bN, cN] Returns the index of where the element should actually be placed. i = current_index n = number of elements each series (a1..aN).length | def get_new_idx(i, n)
# I use the number 4 here but it correlates to the number of series.
# For example, I only have "a", "b", "c", and "d" series so I use 4.
(i % 4) * n + (i / 4)
end | [
"def insert_at_indices(c,a)\n new_string = self.clone\n a.each do |x|\n new_string[x] = c\n end\n return new_string\n end",
"def create_target_array(nums, index)\n res = []\n index.each_with_index { |ind, i| res.insert(ind, nums[i])} \n res\nend",
"def shift_elements(index)\n (index.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if there are no more jobs queued and there is just one working job in the queue (which is this job) | def all_jobs_hve_been_processed?(queue)
(job_count(queue) == 0) && (working_job_count(queue) <= 1)
end | [
"def more_work?\n get_queue_message_count(:job_requests) > 0\n end",
"def ready?\n return @jobs.length < 1\n end",
"def completed?\n return self.shift_jobs.count > 0\n end",
"def has_job_progress?\n !job_progress_queue.empty?\n end",
"def running?\n\t\t\treturn @job... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Limit should reset every 30 days, starting on day of account creation | def set_upload_limit_reset_date
now = DateTime.now
reset_date = now + 30
self.upload_limit_resets_at = reset_date
self.save
end | [
"def init_limit_reset_for(account)\n @task_manager.in '1d' do\n account.reset_limit\n end\n end",
"def reset_limit\n @daily_limit = LIMIT\n end",
"def renew\n \tupdate_attibute :end_date, Date.today + 1.month\n end",
"def renew_days\n @config[:renew_days]\n end",
"def renew_account_unt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called to check if user exceeds monthly upload limit, with option to pass in an extra byte count | def exceeds_upload_limit?(attempted_bytes=0)
self.upload_size_this_month + attempted_bytes >= Rails.application.secrets.monthly_upload_byte_limit
end | [
"def upload_limit_exceeded?(medium)\n upload_limit = 734_003_200\n newsize = current_user.size_of_uploads + medium.size\n return true if newsize > upload_limit\n false\n end",
"def post_attachment_count_within_limit\n if self.posting.enterprise == 1\n if self.posting.post_at... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
adds post metadata as yaml metadata | def yaml_metadata
if single_post?
# if we were to merge config to data, the default options would
# take precedence
data = Jekyll::Utils.deep_merge_hashes @config, single_post.data
single_post.merge_data! data
# we extract the excerpt because it serializes as an object a... | [
"def add_metadata(post, options)\n post['DatabaseId'] = options[:database_id]\n post['Source'] = truncate(options[:source], 50)\n (1..20).each do |index|\n k = \"other#{index}\".to_sym\n post[\"Other#{index}\"] = options[k] if options.key?(k)\n end\n end",
"def r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a PDF cover | def pdf_cover
cover.gsub(/\.[^\.]+\Z/, '.pdf')
end | [
"def show\n @cover = Cover.find(params[:id])\n\n respond_to do |format|\n format.html { send_file(@cover.build_pdf, :type => 'application/pdf', :page => '1') }\n\n ### returns pdf for the client\n format.json { send_file(@cover.build_pdf, :type => 'application/pdf', :page => '1') }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Returns the class_hierachy To fetch all Vertices: class_hieararchy(base_class: 'V').flatten To fetch all Edges: class_hierarchy(base_class: 'E').flatten notice: To retrieve the class hierarchy from Objects avoid calling `ORD.classname (obj)`, because it depends on class_hierarchy. =end | def class_hierarchy base_class: '', system_classes: nil
# @actual_class_hash = get_classes('name', 'superClass') #if requery || @all_classes.blank?
fv = ->( s ) { @actual_class_hash.find_all{|x| x['superClass']== s}.map{|v| v['name']} }
fx = ->( v ) { fv[v.strip].map{|x| ar = fx[x]; ar.empty? ? x : [x, ar]} }
... | [
"def descendents\n Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendents)}.flatten\n end",
"def get_class_hierarchy base_class: '', requery: false\n @all_classes = get_classes('name', 'superClass')# if requery || @all_classes.blank?\n def fv s # :nodoc:\n \t @all_classes.f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Returns an array with all names of the classes of the database. | def database_classes system_classes: nil
@actual_class_hash = get_classes('name', 'superClass')
all_classes = get_classes('name').map(&:values).sort.flatten
all_user_classes = all_classes - system_classes()
all_user_classes.each{|x| ActiveOrient.database_classes[x] = "unset" unless ActiveOrient.databas... | [
"def get_database_classes include_system_classes: false, requery: false\n requery = true if @classes.nil? || @classes.empty?\n if requery\n \t get_class_hierarchy requery: true\n \t system_classes = [\"OFunction\", \"OIdentity\", \"ORIDs\", \"ORestricted\", \"ORole\", \"OSchedule\", \"OTriggered\", \"OUse... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /planpagos/1 GET /planpagos/1.xml | def show
@planpago = Planpago.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @planpago }
end
end | [
"def show\n @planodepagamento = Planodepagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @planodepagamento }\n end\n end",
"def index\n @pagos = Pago.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /planpagos/new GET /planpagos/new.xml | def new
@planpago = Planpago.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @planpago }
end
end | [
"def new\n @plano = Plano.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plano }\n end\n end",
"def new\n @planodepagamento = Planodepagamento.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"
]
]
}
} |
POST /planpagos POST /planpagos.xml | def create
@planpago = Planpago.new(params[:planpago])
respond_to do |format|
if @planpago.save
flash[:notice] = 'Planpago was successfully created.'
format.html { redirect_to(@planpago) }
format.xml { render :xml => @planpago, :status => :created, :location => @planpago }
... | [
"def create\n @planodepagamento = Planodepagamento.new(params[:planodepagamento])\n\n respond_to do |format|\n if @planodepagamento.save\n flash[:notice] = 'Planodepagamento was successfully created.'\n format.html { redirect_to(@planodepagamento) }\n format.xml { render :xml => @pl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /planpagos/1 PUT /planpagos/1.xml | def update
@planpago = Planpago.find(params[:id])
respond_to do |format|
if @planpago.update_attributes(params[:planpago])
flash[:notice] = 'Planpago was successfully updated.'
format.html { redirect_to(@planpago) }
format.xml { head :ok }
else
format.html { render ... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @plan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /planpagos/1 DELETE /planpagos/1.xml | def destroy
@planpago = Planpago.find(params[:id])
@planpago.destroy
respond_to do |format|
format.html { redirect_to(planpagos_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @planodepagamento = Planodepagamento.find(params[:id])\n @planodepagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(planosdepagamento_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_pago = TipoPago.find(params[:id])\n @tipo_pag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /egc_server_types GET /egc_server_types.json | def index
@egc_server_types = EgcServerType.all
end | [
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def types\n get(\"/project/types\")[\"types\"]\n end",
"def types\n types = JSON.parse(connection.get(\"/Contact/Types\").body )\n end",
"def index\n @egc_serve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /egc_server_types POST /egc_server_types.json | def create
@egc_server_type = EgcServerType.new(egc_server_type_params)
respond_to do |format|
if @egc_server_type.save
format.html { redirect_to @egc_server_type, notice: 'Egc server type was successfully created.' }
format.json { render :show, status: :created, location: @egc_server_typ... | [
"def index\n @egc_server_types = EgcServerType.all\n end",
"def set_server_type(opts)\n opts = check_params(opts,[:types])\n super(opts)\n end",
"def getServiceTypes( )\n\n # parameter TypeCheck\n\n # BIMserver request\n request( { } )\n end",
"def create_types\n\t\t[]\n\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /egc_server_types/1 PATCH/PUT /egc_server_types/1.json | def update
respond_to do |format|
if @egc_server_type.update(egc_server_type_params)
format.html { redirect_to @egc_server_type, notice: 'Egc server type was successfully updated.' }
format.json { render :show, status: :ok, location: @egc_server_type }
else
format.html { render :... | [
"def patch_entity_type(entity_type_id, request)\n start.uri('/api/entity/type')\n .url_segment(entity_type_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end",
"def update\n respond_to do |format|\n if @egc_server_cluster_type... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /egc_server_types/1 DELETE /egc_server_types/1.json | def destroy
@egc_server_type.destroy
respond_to do |format|
format.html { redirect_to egc_server_types_url, notice: 'Egc server type was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @egc_server_cluster_type.destroy\n respond_to do |format|\n format.html { redirect_to egc_server_cluster_types_url, notice: 'Egc server cluster type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server = Server.find(params[:id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Completes SCA authentication successfully | def complete_stripe_sca
find_sca_frame do
click_on "Complete authentication"
end
end | [
"def after_aaf_rc_authentication\n end",
"def complete_stripe_sca\n find_frame(\"body > div > iframe\") do\n # This helps find the inner iframe in the SCA modal's challenge frame which doesn't load immediately\n sleep 1\n\n find_frame(\"#challengeFrame\") do\n find_frame(\".Fullscree... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve ARV pill count for patient on a given visit NOTE: The visit object seems to always have pill count not set although the actual pill counts are available as observations. | def number_of_arvs_given(patient_id, visit_date)
obs = EmastercardDb.find_all_observations_by_encounter(patient_id,
Emastercard::Concepts::ARVS_DISPENSED,
Emastercard::Encounters::... | [
"def patient_count\n patients.count\n end",
"def getPatientCount\n return @patientList.size\n end",
"def total_visit\n pet_histories.count\n end",
"def show_remaining_visits(patient)\n @pat_auth = PatientAuthorization.find_by_patient_id(patient, :conditions => {:active => true})\n if @pat_au... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates the expected remaining number of ARVs prescribed on initial_visit as of current_visit. | def expected_remaining_arvs(drug_daily_dose, arvs_given_on_initial_visit,
previous_visit_date, current_visit_date)
number_of_days_elapsed = days_between(previous_visit_date, current_visit_date)
arvs_given_on_initial_visit - (drug_daily_dose * number_of_days_elapse... | [
"def approx_inference samples\n samples.count { |s| s == @goal } / samples.size.to_f\n end",
"def remaining_same_calls\n return 0 if remaining <= 0\n\n usage = compute_usage\n usage > 0 ? remaining/usage : -1\n end",
"def new_visitors\n if (c = self.count) ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Display the type of mission in underscore | def mission_type
type.underscore
end | [
"def missionName \n \"missionName\" \n end",
"def mission_type(mission)\n case mission[\"type\"]\n when /\\A(neighbor|our|empty)_provinces\\z/, /\\A(threat|rival|neighbor|elector)_countries\\z/, /\\A(rivals|threats)_rivals\\z/\n \"FROM\"\n when \"country\"\n \"ROOT\"\n else\n ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /application_exprs/1 GET /application_exprs/1.xml | def show
@application_expr = ApplicationExpr.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @application_expr }
end
end | [
"def index\n @expressions = Expression.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expressions }\n end\n end",
"def new\n @application_expr = ApplicationExpr.new\n\n respond_to do |format|\n format.html # new.html.erb\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /application_exprs/new GET /application_exprs/new.xml | def new
@application_expr = ApplicationExpr.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @application_expr }
end
end | [
"def create\n @application_expr = ApplicationExpr.new(params[:application_expr])\n\n respond_to do |format|\n if @application_expr.save\n flash[:notice] = 'ApplicationExpr was successfully created.'\n format.html { redirect_to(@application_expr) }\n format.xml { render :xml => @appl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /application_exprs POST /application_exprs.xml | def create
@application_expr = ApplicationExpr.new(params[:application_expr])
respond_to do |format|
if @application_expr.save
flash[:notice] = 'ApplicationExpr was successfully created.'
format.html { redirect_to(@application_expr) }
format.xml { render :xml => @application_expr... | [
"def new\n @application_expr = ApplicationExpr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @application_expr }\n end\n end",
"def update\n @application_expr = ApplicationExpr.find(params[:id])\n\n respond_to do |format|\n if @applicatio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /application_exprs/1 PUT /application_exprs/1.xml | def update
@application_expr = ApplicationExpr.find(params[:id])
respond_to do |format|
if @application_expr.update_attributes(params[:application_expr])
flash[:notice] = 'ApplicationExpr was successfully updated.'
format.html { redirect_to(@application_expr) }
format.xml { head ... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n if @expression.update_attributes(params[:expression])\n flash[:notice] = 'Ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /application_exprs/1 DELETE /application_exprs/1.xml | def destroy
@application_expr = ApplicationExpr.find(params[:id])
@application_expr.destroy
respond_to do |format|
format.html { redirect_to(application_exprs_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @primary_expr = PrimaryExpr.find(params[:id])\n @primary_expr.destroy\n\n respond_to do |format|\n format.html { redirect_to(primary_exprs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test the redaction of an old version of a way, while not being authorised. | def test_redact_way_unauthorised
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
do_redact_way(way_v3, create(:redaction))
assert_response :unauthorized, "should need to be authenticated to redact."
end | [
"def test_redact_way_current_version\n basic_authorization create(:moderator_user).email, \"test\"\n way = create(:way, :with_history, :version => 4)\n way_latest = way.old_ways.last\n\n do_redact_way(way_latest, create(:redaction))\n assert_response :bad_request, \"shouldn't be OK to redact current ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test the redaction of an old version of a way, while being authorised as a normal user. | def test_redact_way_normal_user
basic_authorization create(:user).email, "test"
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
do_redact_way(way_v3, create(:redaction))
assert_response :forbidden, "should need to be moderator to redact."
end | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_redact_way_current_versio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test that, even as moderator, the current version of a way can't be redacted. | def test_redact_way_current_version
basic_authorization create(:moderator_user).email, "test"
way = create(:way, :with_history, :version => 4)
way_latest = way.old_ways.last
do_redact_way(way_latest, create(:redaction))
assert_response :bad_request, "shouldn't be OK to redact current version as mod... | [
"def test_unredact_way_normal_user\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization create(:user).email, \"test\"\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.versi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test that redacted ways aren't visible in the history | def test_history_redacted
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
get :history, :params => { :id => way_v1.way_id }
assert_response :success, "Redaction shouldn't have stopped history working."
assert_selec... | [
"def test_history_redacted\n relation = create(:relation, :with_history, :version => 2)\n relation_v1 = relation.old_relations.find_by(:version => 1)\n relation_v1.redact!(create(:redaction))\n\n get :history, :params => { :id => relation_v1.relation_id }\n assert_response :success, \"Redaction shoul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test the unredaction of an old version of a way, while not being authorised. | def test_unredact_way_unauthorised
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }
assert_response :unauthorized, "should need to be authent... | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_unredact_way_normal_user\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test the unredaction of an old version of a way, while being authorised as a normal user. | def test_unredact_way_normal_user
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
basic_authorization create(:user).email, "test"
post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }
asser... | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_unredact_way_unauthorised... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:doc: This helper returns exclusively if the request's user_aget is from a mobile device or not. | def is_mobile_request?
request.user_agent.to_s.downcase =~ Regexp.union(MOBILE_USER_AGENTS)
end | [
"def is_mobile_request?\n request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/\n end",
"def is_mobile_request?\n (not user_agent_excluded?) && !(request.user_agent.to_s.downcase =~ @@mobylette_options[:mobile_user_agents].call).nil?\n end",
"def mobile?\n @device == :mobile\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this request should be treated as a mobile request | def respond_as_mobile?
processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or allow_mobile_response? or (params[:format] == 'mobile'))
end | [
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))\n end",
"def is_mobile_request?\n request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/\n end",
"def is_mobile... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true when ?skip_mobile=true is not passed to the request | def skip_mobile_param_not_present?
params[:skip_mobile] != 'true'
end | [
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))\n end",
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true only if treating XHR requests (when skip_xhr_requests are set to false) or or when this is a non xhr request | def processing_xhr_requests?
not self.mobylette_options[:skip_xhr_requests] && request.xhr?
end | [
"def xhr_request_check\n request.xhr?\n end",
"def xhr?\n type?(\"xhr\")\n end",
"def stop_processing_because_xhr?\n if request.xhr? && self.mobylette_options[:skip_xhr_requests]\n true\n else\n false\n end\n end",
"def xml_http_request?\n not /XMLHttpRequest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds the payload to create an ingestion workflow | def create_ingestion_workflow_payload(params={})
params[:uuid] ||= Config::Constants::ASSET_UUID
params[:path] ||= Config::Constants::ASSET_PATH
params[:title] ||= Config::Constants::ASSET_TITLE
params[:url] ||= Config::Constants::ASSET_URL + params[:uuid] + '/'
{
'definitionId': Config::... | [
"def perform\n @params = {\n item_id: payloads.first[:output][:item_id],\n item_name: payloads.first[:output][:item_name],\n source_dir: payloads.first[:output][:source_dir],\n number_of_works: payloads.first[:output][:number_of_works]\n }\n IngestWorkflowManager.new(params: params)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE t FROM ( SELECT ticket_types.id FROM ticket_types GROUP BY type_uuid HAVING COUNT() > 1 ) t2 JOIN ticket_types t on t.id = t2.id; | def down
execute <<-SQL
ALTER TABLE ticket_types
DROP INDEX ticket_types_type_uuid;
SQL
end | [
"def delete_duplicated_records\n dup_notification_ids = Notification.group(:appeals_id, :appeals_type).having('COUNT(*) > 1').pluck(:appeals_id)\n dup_notification_ids.each_slice(400) do |dupe_ids|\n not_remove_order_ids = Notification.where(appeals_id: dupe_ids).group(:appeals_id, :appeals_type).having(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns 'completed', 'completed with errors', 'in progress', 'queued' depending on status of the child import jobs. In progress if there are any jobs in progress. Queued if all the jobs are queued. Completed if all the jobs have been completed successfully. Completed with errors if at least one job failed. | def status
return nil if digital_object_imports.empty?
if digital_object_imports.all?(&:successful?)
COMPLETED
elsif imports_finished_with_failures?
COMPLETED_WITH_ERRORS
elsif digital_object_imports.all?(&:queued?)
QUEUED
else
IN_PROGRESS
end
end | [
"def status\n statuses = jobs_active_record_relation.to_a.map(&:status)\n statuses.empty? ? OSC::Machete::Status.not_submitted : statuses.reduce(&:+)\n end",
"def status\n job = delayed_job\n return 'queued' if job_queued?(job)\n return 'working' if job_working?(job)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine if the related DO Imports are all complete (_not_ in progress or queued) and has at least one failed | def imports_finished_with_failures?
digital_object_imports.where(status: DigitalObjectImport::FAILED).exists? &&
digital_object_imports.where(
status: [DigitalObjectImport::QUEUED, DigitalObjectImport::IN_PROGRESS]
).blank?
end | [
"def ensure_imports_are_complete!\n imports_pending = import_count('pending').positive?\n imports_in_progress = import_count('in_progress').positive?\n\n if cancelled && imports_in_progress\n errors.add(:base, 'Cannot destroy cancelled batch import while imports are in_progress')\n thro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if crew is not missing methods | def test( crew )
[ 'board', 'step', 'event', 'identifier' ].each do | method |
if not crew.respond_to?( method )
raise "Crew should respond to #{method}"
end
end
end | [
"def should_exist\n $tracer.trace(format_method(__method__))\n @name_links.should_exist && @remove_buttons.should_exist\n end",
"def should_not_exist\n $tracer.trace(format_method(__method__))\n @name_links.should_not_exist && @remove_buttons.should_not_exist\n end",
"def test_object_respond_to_mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Spawn the player on a node | def spawn( node, data = {} )
ship = build( data )
ship.command_center.travel( node )
ship.command_center.join
Space::Universe.timestamped 0, "Spawned #{ ship.identifier } on #{ ship.interface.position }"
end | [
"def spawn_at(spawn_point_name, entity = nil)\n\tdsl.SpawnAt(spawn_point_name, ee(entity))\nend",
"def spawn\n creature = self.clone\n # by default all creatures start inactive...\n creature.sleep\n game.add_agent(creature)\n creature\n end",
"def spawn_npc(hash)\n raise 'A name (or... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tlcp_rueba_lists GET /tlcp_rueba_lists.json | def index
@tlcp_rueba_lists = TlcpRuebaList.all
end | [
"def get_list(list_id:)\n JSON.parse(api_request(method: :get, path: \"lists/#{list_id}\"))\n end",
"def get_list(list)\n api_get(:list, {:list => list})\n end",
"def get_lists(user)\n get(\"/#{user}/lists.json\")\n end",
"def lists\n\t\tlistable = Listable.find_by_id(params['lista... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tlcp_rueba_lists POST /tlcp_rueba_lists.json | def create
@tlcp_rueba_list = TlcpRuebaList.new(tlcp_rueba_list_params)
respond_to do |format|
if @tlcp_rueba_list.save
format.html { redirect_to @tlcp_rueba_list, notice: 'Tlcp rueba list was successfully created.' }
format.json { render :show, status: :created, location: @tlcp_rueba_lis... | [
"def create_list(name:)\n JSON.parse(api_request(method: :post, path: \"lists\", params: list_params(name)))\n end",
"def create\n @task_list = current_user.task_lists.new(tl_params)\n\n if @task_list.save\n render json: @task_list, status: :created\n else\n render json: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /tlcp_rueba_lists/1 PATCH/PUT /tlcp_rueba_lists/1.json | def update
respond_to do |format|
if @tlcp_rueba_list.update(tlcp_rueba_list_params)
format.html { redirect_to @tlcp_rueba_list, notice: 'Tlcp rueba list was successfully updated.' }
format.json { render :show, status: :ok, location: @tlcp_rueba_list }
else
format.html { render :... | [
"def update\n @task_list = current_user.task_lists.find(params[:id])\n\n if @task_list.update(tl_params)\n head :no_content\n else\n render json: @task_list.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @rest_list.update(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tlcp_rueba_lists/1 DELETE /tlcp_rueba_lists/1.json | def destroy
@tlcp_rueba_list.destroy
respond_to do |format|
format.html { redirect_to tlcp_rueba_lists_url, notice: 'Tlcp rueba list was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_list(list)\n api_delete(:list, {:list => list})\n end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def delete_list(id)\n query(\"DELETE FROM todos WHERE list_id = $1\", id)\n query(\"DELETE FROM lists WHERE id = $1\", id)\n end",
"def des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /corps GET /corps.json | def index
@corps = Corp.all
end | [
"def index\n @corals = Coral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corals }\n end\n end",
"def index\n @ss_corals = SsCoral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ss_coral... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /corps/1 DELETE /corps/1.json | def destroy
@corp.destroy
respond_to do |format|
format.html { redirect_to corps_url }
format.json { head :no_content }
end
end | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @cor = Cor.find(params[:id])\n @cor.destroy\n\n respond_to do |format|\n format.html { redirect_to(cors_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Join a branch context table to the current dataset the context will apply to. | def join_context(context_data, options = {})
join_column = options[:join_column] || :branch_id
versioned_table = opts[:last_joined_table] || opts[:from].first
ds = join(context_data, { :branch_id => join_column }, options) do |j, lj|
Sequel.expr(Sequel.qualify(j, :version) =>... | [
"def add_join(dataset)\n # FIXME: doesn't take any care to pick a unique alias for the table when joining to it\n # FIXME: doesn't use mapping to determine id_column\n dataset.join(target_repo.table_name, foreign_key_mapper.column_name => @repository.identity_mapper.column_name)\n end",
"def joi... | {
"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.