query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
adds node to end of list, storing given data in node | def ll_append(data)
new_node = Node.new(data)
if @num_nodes == 0
@head = new_node
@tail = new_node
else
end_node = @tail
end_node.set_Next(new_node)
@tail = new_node
end
@num_nodes += 1
end | [
"def add(data)\n new_node = Node.new(data)\n new_node.next = @head\n @head = new_node\n end",
"def add_to_end(node)\n current = @head\n\n while current.next\n current = current.next\n end\n\n current.next = node\n end",
"def append_elem(data)\n\t\tnode = Node.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
removes first node in list THAT MATCHES target returns pointer to the data UNLESS node does not exist (returns nil) | def ll_remove(target)
target_node = find_node(target)
if target_node == nil
return nil
end
# if first node is being removed -> need to reset head to node
if target_node[0] == 0
if @num_nodes == 1
@head = nil
@tail = nil
else
@head = @head.get_Next()
end
... | [
"def remove_target_item(id)\n #p @targets\n @targets.each do |elem|\n #printf(\"id is %d.\\n\", id)\n if elem[0] == id\n #printf(\"elem[0] is %d.\\n\", elem[0]);\n p elem\n end\n @targets.delete_if{|elem| elem[0] == id}\n end\n p @targets\n update_table(@target... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
traverses linked list searching for node that matches target returns pointer to node w/ value unless doesn't exist (returns nil) | def find_node(target)
if @num_nodes == 0
return nil
else
current = 0
current_node = @head
while current < @num_nodes
if current_node.get_Data() == target
return current, current_node
end
current_node = current_node.get_Next()
current += 1
end
re... | [
"def ll_remove(target)\n target_node = find_node(target)\n\n if target_node == nil\n return nil\n end\n\n # if first node is being removed -> need to reset head to node \n if target_node[0] == 0\n if @num_nodes == 1\n @head = nil\n @tail = nil\n else\n @head = @head.get_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
traverses list and applies given function to the data in each node | def ll_map(function)
current = 0
current_node = @head
while current < @num_nodes
current_node.set_Data(function.call(current_node.get_Data()))
current_node = current_node.get_Next()
current += 1
end
end | [
"def apply(tree, &func)\n traverse(tree, func)\n end",
"def apply_to_all(function)\n\treturn lambda{|xs| xs.map {|x| function.call(x)}}\nend",
"def traverse_list(node, arr, idx)\n # set the current element in the array as the value of the node\n node.val = arr[idx]\n\n # increment t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates new LinkedList, initializes, and returns | def ll_create()
return Linked_List.new()
end | [
"def build_iterative_linked_list(len)\n ll = LinkedList.new\n node = Node.new(0, nil)\n\n (1..len).each do |val|\n node = Node.new(val, node)\n ll.add_node(node)\n val += 1\n end\n\n ll.head = node\n ll\nend",
"def create_linked_list(n)\n list = LinkedList.new\n a = Node.new(\"a\")\n n.times do\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds the LtiCredential & Account based on the oauth_consumer_key | def find_lti_credentials
raise OpenAssessments::NoLtiKey unless params["oauth_consumer_key"].present?
if @lti_credential = LtiCredential.enabled.where(lti_key: params["oauth_consumer_key"]).first
@current_account = @lti_credential.account
@lti_credential
else
#todo: next refactor stage: ... | [
"def account_from_oauth(auth)\n extractor = Extractor::Base.load(auth)\n\n accounts.where(extractor.signature).first_or_initialize do |account|\n account.username = extractor.username\n account.oauth_token = extractor.oauth_token\n account.oauth_secret = extractor.oauth_secret\n ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
After saving need to make sure that cached pages for css and js for this layout and its children are gone. Good enough to avoid using cache sweepers. | def clear_cache
FileUtils.rm File.expand_path("cms-css/#{self.slug}.css", Rails.public_path), :force => true
FileUtils.rm File.expand_path("cms-js/#{self.slug}.js", Rails.public_path), :force => true
end | [
"def remove_archive_cache\n expire_action(:controller => '/articles', :action => 'index')\n expire_fragment(%r{/articles/page/*})\n expire_fragment(%r{/categories/*})\n articles_folder = ActionController::Base.page_cache_directory + '/articles/'\n FileUtils.rmtree articles_folder if File.exists? arti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /drivers_licesnses GET /drivers_licesnses.json | def index
@drivers_licesnses = DriversLicesnse.all
end | [
"def index\n @drivers = Driver.all\n render json: @drivers\n end",
"def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end",
"def create\n @drivers_licesnse = DriversLicesnse.new(drivers_licesn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /drivers_licesnses POST /drivers_licesnses.json | def create
@drivers_licesnse = DriversLicesnse.new(drivers_licesnse_params)
respond_to do |format|
if @drivers_licesnse.save
format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully created.' }
format.json { render :show, status: :created, location: @drivers... | [
"def index\n @drivers_licesnses = DriversLicesnse.all\n end",
"def update\n respond_to do |format|\n if @drivers_licesnse.update(drivers_licesnse_params)\n format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully updated.' }\n format.json { render :show, st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /drivers_licesnses/1 PATCH/PUT /drivers_licesnses/1.json | def update
respond_to do |format|
if @drivers_licesnse.update(drivers_licesnse_params)
format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully updated.' }
format.json { render :show, status: :ok, location: @drivers_licesnse }
else
format.html { ren... | [
"def update\n data = driver_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"fleet_id\": @driver.fleet_id,\"phone\": data[:contact_no], \"password\": data[:password], \"username\": data[:username], \"first_name\": data[:driver_name] }\n response = RestClient.post... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /drivers_licesnses/1 DELETE /drivers_licesnses/1.json | def destroy
@drivers_licesnse.destroy
respond_to do |format|
format.html { redirect_to drivers_licesnses_url, notice: 'Drivers licesnse was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n http_api.delete(\"clients/#{@name}\")\n end",
"def destroy\n @driver1.destroy\n respond_to do |format|\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION The display_name method returns a full name of this slice, containing the name of the coordinate system, the sequence region, start and stop positions on that sequence region and the strand. E.g. for a slice of bovine chromosome 4 from position 95000 to 98000 on the reverse strand, the display_name would ... | def display_name
return [self.seq_region.coord_system.name, self.seq_region.coord_system.version, self.seq_region.name, self.start.to_s, self.stop.to_s, self.strand.to_s].join(':')
end | [
"def display_name\n \treturn [self.seq_region.coord_system.name, self.seq_region.coord_system.version, self.seq_region.name, self.start.to_s, self.stop.to_s, self.strand.to_s].join(':')\n end",
"def display_name\n if self.name == \"(region)\"\n # \"Region\"\n \"\"\n elsif self.name == \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION The Sliceoverlaps? method checks if this slice overlaps another one. The other slice has to be on the same coordinate system = USAGE slice_a = Slice.fetch_by_region('chromosome','X',1,1000) slice_b = Slice.fetch_by_region('chromosome','X',900,1500) if slice_a.overlaps?(slice_b) puts "There slices overlap"... | def overlaps?(other_slice)
if ! other_slice.class == Slice
raise RuntimeError, "The Slice#overlaps? method takes a Slice object as its arguments."
end
if self.seq_region.coord_system != other_slice.seq_region.coord_system
raise RuntimeError, "The argument slice of Slice#... | [
"def within?(other_slice)\r\n if ! other_slice.class == Slice\r\n raise RuntimeError, \"The Slice#overlaps? method takes a Slice object as its arguments.\"\r\n end\r\n if self.seq_region.coord_system != other_slice.seq_region.coord_system\r\n raise RuntimeError, \"The argument... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION The Slicewithin? method checks if this slice is contained withing another one. The other slice has to be on the same coordinate system = USAGE slice_a = Slice.fetch_by_region('chromosome','X',1,1000) slice_b = Slice.fetch_by_region('chromosome','X',900,950) if slice_b.overlaps?(slice_a) puts "Slice b is w... | def within?(other_slice)
if ! other_slice.class == Slice
raise RuntimeError, "The Slice#overlaps? method takes a Slice object as its arguments."
end
if self.seq_region.coord_system != other_slice.seq_region.coord_system
raise RuntimeError, "The argument slice of Slice#ov... | [
"def within?(other_slice)\n if ! other_slice.class == Slice\n raise RuntimeError, \"The Slice#overlaps? method takes a Slice object as its arguments.\"\n end\n if self.seq_region.coord_system != other_slice.seq_region.coord_system\n raise RuntimeError, \"The argument slice of ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION The Sliceexcise method removes a bit of a slice and returns the remainder as separate slices. = USAGE original_slice = Slice.fetch_by_region('chromosome','X',1,10000) new_slices = original_slice.excise([500..750, 1050..1075]) new_slices.each do |s| puts s.display_name end result: chromosome:X:1:499:1 chro... | def excise(ranges)
if ranges.class != Array
raise RuntimeError, "Argument should be an array of ranges"
end
ranges.each do |r|
if r.class != Range
raise RuntimeError, "Argument should be an array of ranges"
end
end
answer = Arr... | [
"def delete_subrange(subrange)\n result = []\n\n min_in_range = cover?(subrange.min)\n max_in_range = cover?(subrange.max)\n if min_in_range && max_in_range\n # -20 20\n # -2..2\n result << (self.begin..(subrange.begin - 1))\n result << ((subrange.end + 1)..self.end)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Get the sequence of the Slice as a Bio::Sequence::NA object. If the Slice is on a CoordSystem that is not seq_level, it will try to project it coordinates to the CoordSystem that does. At this moment, this is only done if there is a direct link between the two coordinate systems. (The perl API allows for ... | def seq
# If we already accessed the sequence, we can just
# call the instance variable. Otherwise, we'll have
# to get the sequence first and create a Bio::Sequence::NA
# object.
if @seq.nil?
# First check if the slice is on the seqlevel coordinate
# syste... | [
"def seq\n \t# If we already accessed the sequence, we can just\n \t# call the instance variable. Otherwise, we'll have\n # to get the sequence first and create a Bio::Sequence::NA\n \t# object.\n if @seq.nil?\n # First check if the slice is on the seqlevel coordinate\n \t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Take a sub_slice from an existing one. = USAGE my_sub_slice = my_slice.sub_slice(400,500) Arguments: start: start of subslice relative to slice (default: start of slice) stop: stop of subslice relative to slice (default: stop of slice) Returns:: Ensembl::Core::Slice object | def sub_slice(start = self.start, stop = self.stop)
return self.class.new(self.seq_region, start, stop, self.strand)
end | [
"def sub_slice(start = self.start, stop = self.stop)\n \treturn self.class.new(self.seq_region, start, stop, self.strand)\n end",
"def slice(start, length)\n end",
"def slice( list, start, stop )\n list[ start - 1 .. stop - 1 ]\nend",
"def subsequence(start, stop)\n \treturn self.seq.slice(st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Creates overlapping subslices for a given Slice. = USAGE my_slice.split(50000, 250).each do |sub_slice| puts sub_slice.display_name end Arguments: max_size: maximal size of subslices (default: 100000) overlap: overlap in bp between consecutive subslices (default: 0) Returns:: array of Ensembl::Core::Slice... | def split(max_size = 100000, overlap = 0)
sub_slices = Array.new
i = 0
self.start.step(self.length, max_size - overlap - 1) do |i|
sub_slices.push(self.sub_slice(i, i + max_size - 1))
end
i -= (overlap + 1)
sub_slices.push(self.sub_slice(i + max_size))
... | [
"def slices(num_slices)\n array_of_slices = []\n each_slice(length / num_slices) { |s| array_of_slices << s }\n array_of_slices\n end",
"def sub_slice(start = self.start, stop = self.stop)\r\n \treturn self.class.new(self.seq_region, start, stop, self.strand)\r\n end",
"def sub_slice(start =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Get all MiscFeatures that are located on a Slice for a given MiscSet. Pitfall: just looks at the CoordSystem that the Slice is located on. For example, if a Slice is located on a SeqRegion on the 'chromosome' CoordSystem, but all misc_features are annotated on SeqRegions of the 'scaffold' CoordSystem, thi... | def misc_features(code)
answer = Array.new
if code.nil?
self.seq_region.misc_features.each do |mf|
if mf.seq_region_start > self.start and mf.seq_region_end < self.stop
answer.push(mf)
end
end
else
self.seq_region.misc_f... | [
"def misc_features(code)\n \tanswer = Array.new\n if code.nil?\n self.seq_region.misc_features.each do |mf|\n if mf.seq_region_start > self.start and mf.seq_region_end < self.stop\n answer.push(mf)\n end\n end\n else\n self.seq_region.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Get all DnaAlignFeatures that are located on a Slice for a given Analysis. Pitfall: just looks at the CoordSystem that the Slice is located on. For example, if a Slice is located on a SeqRegion on the 'chromosome' CoordSystem, but all dna_align_features are annotated on SeqRegions of the 'scaffold' CoordS... | def dna_align_features(analysis_name = nil)
if analysis_name.nil?
return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)
else
... | [
"def dna_align_features(analysis_name = nil)\n \tif analysis_name.nil?\n return DnaAlignFeature.find_by_sql('SELECT * FROM dna_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
= DESCRIPTION Get all ProteinAlignFeatures that are located on a Slice for a given Analysis. Pitfall: just looks at the CoordSystem that the Slice is located on. For example, if a Slice is located on a SeqRegion on the 'chromosome' CoordSystem, but all protein_align_features are annotated on SeqRegions of the 'scaffold... | def protein_align_features(analysis_name)
if analysis_name.nil?
return ProteinAlignFeature.find_by_sql('SELECT * FROM protein_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)
else
... | [
"def protein_align_features(analysis_name)\n \tif analysis_name.nil?\n return ProteinAlignFeature.find_by_sql('SELECT * FROM protein_align_feature WHERE seq_region_id = ' + self.seq_region.id.to_s + ' AND seq_region_start >= ' + self.start.to_s + ' AND seq_region_end <= ' + self.stop.to_s)\n el... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /shopcodes GET /shopcodes.json | def index
@shopcodes = Shopcode.all
end | [
"def index\n @codes = Code.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @codes, root: false }\n end\n end",
"def show\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /shopcodes POST /shopcodes.json | def create
@shopcode = Shopcode.new(shopcode_params)
respond_to do |format|
if @shopcode.save
format.html { redirect_to @shopcode, notice: 'Shopcode was successfully created.' }
format.json { render :show, status: :created, location: @shopcode }
else
format.html { render :ne... | [
"def post_billing_codes\n\t\tid = params[:id]\n\t\t#user_token = params[:user_token]\n\t\turl = \"https://sdpm-appointment-service.herokuapp.com/appointment/#{id}/billing_codes\"\n\t\tresponse = RestClient::Request.execute(\n \t\tmethod: :post, \n \t\t\turl: url,\n \t\t\tpayload: {billing_codes: params[:billi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /shopcodes/1 PATCH/PUT /shopcodes/1.json | def update
respond_to do |format|
if @shopcode.update(shopcode_params)
format.html { redirect_to @shopcode, notice: 'Shopcode was successfully updated.' }
format.json { render :show, status: :ok, location: @shopcode }
else
format.html { render :edit }
format.json { render... | [
"def update\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n if @sales_code.update_attributes(params[:sales_code])\n format.html { redirect_to @sales_code, notice: 'Sales code was successfully updated.' }\n format.json { head :no_content }\n else\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /shopcodes/1 DELETE /shopcodes/1.json | def destroy
@shopcode.destroy
respond_to do |format|
format.html { redirect_to shopcodes_url, notice: 'Shopcode was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @sales_code = SalesCode.find(params[:id])\n @sales_code.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_codes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Applies the adapter of given name on SimpleCov.configure | def load(name)
name = name.to_sym
raise "Could not find SimpleCov Adapter called '#{name}'" unless has_key?(name)
SimpleCov.configure(&self[name])
end | [
"def adapter(name)\n # TODO: Stop user from changing the adapter once set.\n @adapter = name.to_s.camelcase(true).to_sym\n end",
"def use(adapter_name, config = nil)\n check_use_mode!(USE_MODE_ONE)\n @adapter_names << adapter_name\n @adapter_config_map[adapter_name] = config if c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Visitorvisit_Text(text, rest) callback method. =end | def visit_Text(text, *rest)
end | [
"def on_slim_text(type, content); end",
"def process_text(node)\n node\n end",
"def visit_string_content(node); end",
"def process_text text\n @filter.process(Blogitr.expand_macros(@filter, text))\n end",
"def process_text(content)\n content\n end",
"def process_text(snip, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Visitorvisit_CDATASection(text, rest) callback method. =end | def visit_CDATASection(text, *rest)
end | [
"def cdataSection(content)\n\t finishStartTag() if @inStartTag\n\t @io << \"<![CDATA[#{content}]]>\"\n\t @io << \"\\n\" if @prettify\n\tend",
"def cdata_section(content)\n splitted = content.to_s.gsub(/\\]\\]\\>/, \"]]]]><![CDATA[>\")\n \"<![CDATA[#{splitted}]]>\"\n end",
"def cdata_sectio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Visitorvisit_Comment(comment, rest) callback method. =end | def visit_Comment(comment, *rest)
end | [
"def visit_comment(node); end",
"def on_comment(value); end",
"def comment=(*) end",
"def handle_comment(node)\n if node.type == :erb && node.children.size == 4 &&\n node.children[0]&.type == :indicator && node.children[0].children[0] == '#' &&\n node.children[2]&.type == :code\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Visitorvisit_ProcessingInstruction(pi, rest) callback method. =end | def visit_ProcessingInstruction(pi, *rest)
end | [
"def on_processing_instruction(target, data)\n end",
"def processing_instruction(name, content); end",
"def process_instruction anElement\r\n msg = 'process_' + anElement.target\r\n if self.respond_to? msg\r\n self.send(msg,anElement)\r\n end\r\n end",
"def processing_instructi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Nodeaccept_name(visitor, rest) call back visit_name_ method. =end | def accept_name(visitor, *rest)
if nodeType == ELEMENT_NODE
name_method = "visit_name_" + nodeName
visitor.send(name_method, self, *rest)
else
self.accept(visitor, *rest)
end
end | [
"def visit_call(node); end",
"def visit_next(node); end",
"def visit_node(n); end",
"def visit_vcall(node); end",
"def accept visitor\n visitor.accept_raw self\n end",
"def visit_for(node); end",
"def visit_yield(node); end",
"def visit(node, *args)\n block = self.class.visitor_for(node)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Nodechildren_accept(visitor, rest) for each children, call back visit_ methods. =end | def children_accept(visitor, *rest)
ret = []
@children && @children.each { |node|
ret.push(node.accept(visitor, *rest))
}
ret
end | [
"def children_accept_name(visitor, *rest)\n ret = []\n @children && @children.each { |node|\n ret.push(node.accept_name(visitor, *rest))\n }\n ret\n end",
"def processed_children node, &block\n # Recursively examine the node, returning an array of valid descendants or, i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Nodechildren_accept_name(visitor, rest) for each children, call back visit_name_ method. =end | def children_accept_name(visitor, *rest)
ret = []
@children && @children.each { |node|
ret.push(node.accept_name(visitor, *rest))
}
ret
end | [
"def accept_name(visitor, *rest)\n if nodeType == ELEMENT_NODE\n name_method = \"visit_name_\" + nodeName\n visitor.send(name_method, self, *rest)\n else\n self.accept(visitor, *rest)\n end\n end",
"def visit(name)\n child = object.public_send(name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
edit the user's basic info | def edit
@title = "Edit basic info"
@user=User.find(session[:user_id])
if param_posted?(:user)
attribute = params[:attribute]
case attribute
when "email"
try_to_update @user, attribute
when "password"
if @user.correct_password?(params)
try_to_updat... | [
"def edit\n logger.debug(\"USER EDIT\")\n @title = \"Edit basic info\"\n @user = User.find(session[:user_id]) \n if param_posted?(:user)\n attribute = params[:attribute]\n case attribute\n when \"email\"\n try_to_update @user, attribute\n when \"password\"\n if @user.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the remember me string | def remember_me_string
cookies[:remember_me]||"0"
end | [
"def remember_me\n true\n end",
"def remember\n @remember\n end",
"def get_remember_token\n\t\t\tActionDispatch::Request.new(@env).cookie_jar[Clearance.configuration.cookie_name]\n\t\tend",
"def generate_remember_token\n self[:remember_token] = User.new_token\n end",
"def generate_remember_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Order node with the given expression and direction | def initialize(expr, direction = 1)
raise ArgumentError, "Direction #{direction} is not valid. Must be -1 or 1." unless [-1,1].include? direction
@expr, @direction = expr, direction
end | [
"def build_expression_tree(tree)\n Expressions::Expression.create(tree)\n end",
"def create_order(currency_pair: \"btcusd\", direction: Bitstamper::Constants::BUY_ORDER, amount:, price:, limit_price: nil, daily_order: nil)\n currency_pair = ::Bitstamper::Utilities.fix_currency_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set this node's direction to ascending | def asc
@direction = 1
self
end | [
"def set_direction dir\n return 'ASC' unless dir\n dir == 'ASC' ? 'DESC' : 'ASC'\n end",
"def ascending=(value)\n @ascending = value\n end",
"def ascending?\n @direction == 1\n end",
"def initialize\n @current_direction = DIRECTION_ASCENDING\n end",
"def asce... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether or not this node represents an ascending order | def ascending?
@direction == 1
end | [
"def ascending?\n direction == :asc\n end",
"def ascending?\n sort_direction == ASC\n end",
"def ordered?\n return true if @_order\n false\n end",
"def ordered?\n @ordered\n end",
"def ascending\n return @ascending\n end",
"def i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether or not this node represents a descending order | def descending?
@direction == -1
end | [
"def is_descending\n return @is_descending\n end",
"def descending?\n !ascending?\n end",
"def is_descending=(value)\n @is_descending = value\n end",
"def direction?\n [SQLTree::Token::ASC, SQLTree::Token::DESC].include?(self.class)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reverse the node's direction | def reverse!
@direction = - @direction
self
end | [
"def reverse_direction node\n case node\n when :up\n :down\n when :down\n :up\n when :left\n :right\n when :right\n :left\n else\n nil\n end\n end",
"def reverse\n rev = OrientedNode.new(@node, @first_side)\n rev.revers... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /timers/new GET /timers/new.json | def new
return false if !userCan :timer
@timer = Timer.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @timer }
end
end | [
"def create\n @timer = Timer.new(timer_params)\n\n if @timer.save\n render json: @timer, status: :created, location: @timer\n else\n render json: @timer.errors, status: :unprocessable_entity\n end\n end",
"def new\n @timing = Timing.new\n\n respond_to do |format|\n format.html # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /manage_glows GET /manage_glows.json | def index
@manage_glows = ManageGlow.all
end | [
"def create\n @manage_glow = ManageGlow.new(manage_glow_params)\n\n respond_to do |format|\n if @manage_glow.save\n format.html { redirect_to @manage_glow, notice: 'Manage glow was successfully created.' }\n format.json { render action: 'show', status: :created, location: @manage_glow }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /manage_glows POST /manage_glows.json | def create
@manage_glow = ManageGlow.new(manage_glow_params)
respond_to do |format|
if @manage_glow.save
format.html { redirect_to @manage_glow, notice: 'Manage glow was successfully created.' }
format.json { render action: 'show', status: :created, location: @manage_glow }
else
... | [
"def index\n @manage_glows = ManageGlow.all\n end",
"def update\n respond_to do |format|\n if @manage_glow.update(manage_glow_params)\n format.html { redirect_to @manage_glow, notice: 'Manage glow was successfully updated.' }\n format.json { head :no_content }\n else\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /manage_glows/1 PATCH/PUT /manage_glows/1.json | def update
respond_to do |format|
if @manage_glow.update(manage_glow_params)
format.html { redirect_to @manage_glow, notice: 'Manage glow was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @m... | [
"def update\n @glass = Glass.find(params[:id])\n\n respond_to do |format|\n if @glass.update_attributes(params[:glass])\n format.html { redirect_to @glass, notice: 'Glass was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /manage_glows/1 DELETE /manage_glows/1.json | def destroy
@manage_glow.destroy
respond_to do |format|
format.html { redirect_to manage_glows_url }
format.json { head :no_content }
end
end | [
"def destroy\n @manage_green.destroy\n respond_to do |format|\n format.html { redirect_to manage_greens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @green = Green.find(params[:id])\n @green.destroy\n\n respond_to do |format|\n format.html { redirect_to s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /edetails/1 GET /edetails/1.json | def show
@edetail = Edetail.find_by(id: params[:id])
end | [
"def show\n @exp_detail = ExpDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exp_detail }\n end\n end",
"def detail(offer_id)\n fetch_json(\"detail/#{offer_id}\")\n end",
"def show\n @event_detail = EventDetail.find(p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /edetails/1 DELETE /edetails/1.json | def destroy
@edetail = Edetail.find_by(id: params[:id])
@edetail.destroy
respond_to do |format|
format.html { redirect_to edetails_url }
format.json { head :no_content }
end
end | [
"def destroy\n @eob_detail = EobDetail.find(params[:id])\n @eob_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_eob_path(params[:eob_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exp_detail = ExpDetail.find(params[:id])\n @exp_detai... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /proffesions/1 GET /proffesions/1.xml | def show
@proffesion = Proffesion.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @proffesion }
end
end | [
"def show\n @profesion = Profesion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profesion }\n end\n end",
"def show\n @pro = Pro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /proffesions/new GET /proffesions/new.xml | def new
@proffesion = Proffesion.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @proffesion }
end
end | [
"def new\n @profesion = Profesion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @profesion }\n end\n end",
"def new\n @pro = Pro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pro }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /proffesions POST /proffesions.xml | def create
@proffesion = Proffesion.new(params[:proffesion])
respond_to do |format|
if @proffesion.save
flash[:notice] = 'Proffesion was successfully created.'
format.html { redirect_to(@proffesion) }
format.xml { render :xml => @proffesion, :status => :created, :location => @pro... | [
"def create\n @profesion = Profesion.new(params[:profesion])\n\n respond_to do |format|\n if @profesion.save\n format.html { redirect_to(@profesion, :notice => 'Profesion was successfully created.') }\n format.xml { render :xml => @profesion, :status => :created, :location => @profesion }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /proffesions/1 PUT /proffesions/1.xml | def update
@proffesion = Proffesion.find(params[:id])
respond_to do |format|
if @proffesion.update_attributes(params[:proffesion])
flash[:notice] = 'Proffesion was successfully updated.'
format.html { redirect_to(@proffesion) }
format.xml { head :ok }
else
format.ht... | [
"def update\n @proposition = Proposition.find(params[:id])\n\n respond_to do |format|\n if @proposition.update_attributes(params[:proposition])\n format.html { redirect_to @proposition, notice: 'Proposition was successfully updated.' }\n format.json { head :no_content }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /proffesions/1 DELETE /proffesions/1.xml | def destroy
@proffesion = Proffesion.find(params[:id])
@proffesion.destroy
respond_to do |format|
format.html { redirect_to(proffesions_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @producent = Producent.find(params[:id])\n @producent.destroy\n\n respond_to do |format|\n format.html { redirect_to(producents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @prop = Prop.find(params[:id])\n @prop.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
number = ["2438894546", "(718)8911313", "234 435 9978", "(800)4261134"] how to iterate over an array => array with Regex .grep or .scan w/ .split Check if each phone number in the array is valid return true or false for each in an array 1. Iterate through phone array 2.Check if element has 10 numbers | def valid_phone_number?(phone)
# phone.each do |number|
# number.
if phone.match(/([0-9] ?){10}/) || phone.match(/(\([0-9]{3}\)([0-9]{3}-[0-9]{4})\b)/) || phone.match(/\b([0-9]{7})\b/)
true
else
false
end
end | [
"def validateNumbers(numbers)\n\t\tvalid_numbers = Array.new\n\t\tj = 0 # Counter variable\n\t\tfor i in 0..numbers.length-1\n\t\t\tif numbers[i].length == 10\n\t\t\t\tvalid_numbers[j] = numbers[i]\n\t\t\t\tj += 1\n\t\t\tend\n\t\tend\n\t\treturn valid_numbers\n\tend",
"def validate_phones(*phones)\n phones... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Inputs id (string, required): the dxid of the app to run name (string, required): the name of the job inputs (hash, required): the inputs instance_type (string, optional): override of the default instance type Outputs id (string): the dxid of the resulting job Run scoring app, create corresponding job and submission re... | def run_job_create_submission(opts, input_info = nil)
# Parameter 'id' should be of type String
# Get challenge
@challenge = Challenge.find_by(id: opts["challenge_id"])
raise "No associated challenge found" unless @challenge
submission = opts["submission"]
raise "No submission info found" unles... | [
"def run_job_create_submission(params)\n # Parameter 'id' should be of type String\n # Get challenge\n challenge = Challenge.find_by(id: params[\"challenge_id\"])\n raise \"No associated challenge found\" unless challenge\n\n submission = params[\"submission\"]\n raise \"No submission info found\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clones user's submission files into challenge space. | def clone_inputs_to_space
files = UserFile.accessible_by(@context).where(uid: @inputs.values)
return if files.empty?
api = DIContainer.resolve("api.user")
api.project_invite(
@context.user.private_files_project,
"user-#{CHALLENGE_BOT_DX_USER}",
DNAnexusAPI::PROJECT_ACCESS_VIEW,
... | [
"def create\n parameters = params[:file_submission]\n assignment = Assignment.find(parameters['assignment_id'])\n definition = AssignmentDefinition.find_by_assignment_id(assignment.id)\n file = parameters['file']\n \n user_id = current_user.id\n unless (not parameters['user_id']) or parameters[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the server count, returns an int. | def servercount
url = "https://discordbots.org/api/bots/#{@id}"
JSON.parse(RestClient.get(url))['server_count'].to_i
end | [
"def server_count\n @obj['server_count'].to_i\n end",
"def server_count\n @obj['server_count']\n end",
"def count\n servers.length\n end",
"def created_count(server=:default)\n server = @servers[server]\n @allocated[server].length + @available_connections[server].length\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the bot's server count. | def updateservercount(count)
url = "https://discordbots.org/api/bots/#{@id}/stats"
json = '{"server_count":' + count.to_s + '}'
RestClient.post(url, json, :Authorization => @api, :'Content-Type' => :json)
"Successfully set the server count to #{count}"
end | [
"def servercount\n url = \"https://discordbots.org/api/bots/#{@id}\"\n JSON.parse(RestClient.get(url))['server_count'].to_i\n end",
"def update_stats\n @request_count += 1\n discover_server_periodically if(time_to_discover? && !@disconnected_connections.empty?)\n end",
"def update_responses_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /payouts GET /payouts.json | def index
@payouts = Payout.all
end | [
"def payouts\n @payouts ||= Services::PayoutsService.new(@api_service)\n end",
"def show\n @payout = Payout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @payout }\n end\n end",
"def get_payout(payout_id:)\n new_api_call_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /payouts/1 PATCH/PUT /payouts/1.json | def update
respond_to do |format|
if @payout.update(payout_params)
format.html { redirect_to @payout, notice: 'Payout was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @payout.errors, status... | [
"def update\n @payout = Payout.find(params[:id])\n\n respond_to do |format|\n if @payout.update_attributes(params[:payout])\n format.html { redirect_to payouts_url, notice: 'Payout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render acti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /payouts/1 DELETE /payouts/1.json | def destroy
@payout.destroy
respond_to do |format|
format.html { redirect_to payouts_url }
format.json { head :no_content }
end
end | [
"def destroy\n @payout = Payout.find(params[:id])\n @payout.destroy\n\n respond_to do |format|\n format.html { redirect_to payouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @payout.destroy\n respond_to do |format|\n format.html { redirect_to payouts_ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes the methods represented in [+ meths +], and generates and returns a hash that has all the data we want (types, source code, documentation, etc.). | def get_yard_meths(meths, files = [])
## TODO: handle YARD options tags
## filter out meths without types
meths.keep_if { |m| (!m.tags(:param).empty? && m.tags(:param).any? { |t| !t.types.nil? }) || (!m.tags(:return).empty? && m.tags(:return).any? { |t| !t.types.nil? }) }
## these methods have types automatic... | [
"def build_method_summary_list(path_prefix = \"\")\n collect_methods unless @methods\n\n @methods.sort.map do |meth|\n {\n :name => CGI.escapeHTML(meth.name),\n :aref => \"##{meth.aref}\"\n }\n end\n end",
"def build_method_summary_list(path_prefix=\"\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure a file exists on Google Drive that has the name GOOGLE_DRIVE_TYPE_FOLDER. | def ensure_google_type_folder(session)
session.folders.each { |f|
return f if f.name == GOOGLE_DRIVE_TYPE_FOLDER
}
return session.create_folder(GOOGLE_DRIVE_TYPE_FOLDER)
end | [
"def checkforGoogleFolder(googlefolder)\n session = GoogleDrive::Session.from_config(\"config.json\")\n folder = session.collection_by_title(googlefolder)\n if folder.nil?\n session.root_collection.create_subcollection(googlefolder)\n end\nend",
"def meta_is_folder?(meta)\n return meta.mime_type =~ %r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compress [+ dirname +], upload it to [+ google_folder +]. | def compress_and_upload(google_folder, dirname)
puts "Compressing and uploading #{dirname} to Google Drive..."
compressed_name = "#{dirname}.tar.gz"
system "tar -czf #{compressed_name} #{dirname}"
google_folder.upload_from_file(compressed_name)
File.delete(compressed_name)
end | [
"def compress(src_path, archive_path)\n src_dir = File.dirname( File.expand_path( src_path ) )\n src_file = File.basename( src_path )\n archive_path = File.expand_path( archive_path )\n dest_dir = File.dirname( archive_path )\n\n puts \"src_dir: #{src_dir}\"\n puts \"src_path: #{src_path}\"\n p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure local dir for storing data exists. | def ensure_data_folder
return if File.directory? DATA_DIR
Dir.mkdir DATA_DIR
end | [
"def ensure_store_directory\n Dir.mkdir( store ) unless File.directory?( store )\n end",
"def ensure_store_directory\n FileUtils.mkpath( store ) unless File.directory?( store )\n end",
"def ensure_directory_exists\r\n dir = File.dirname(full_path_from_current_attributes)\r\n FileUtils.mkdi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure program log file exists. | def ensure_program_log_file
return if File.file? LOG_FILE
CSV.open(LOG_FILE, "wb") { |csv|
csv << LOG_HEADER
}
end | [
"def ensure_log_directory\n FileUtils.mkdir_p File.join(root_path, 'log')\n end",
"def make_log_directory\n ::FileUtils.mkdir(\"log\") unless File.exists?(\"log\")\n end",
"def open_process_log_file()\n if !File.directory?(LOG_DIRECTORY)\n FileUtils.mkdir_p(LOG_DIRECTORY)\n end\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save program called [+ name +]'s data which is stored in [+ meths_hash +]. Also saves [+ prog_log +], which contains the program log data, and [+ file_hashes +], which contains the md5 hashes of the program's files. | def save_app_data(name, meths_hash, prog_log, file_hashes)
Dir.chdir(DATA_DIR)
if !File.directory? name
Dir.mkdir name
Dir.chdir(name)
YARD::Registry.save
File.open(name + "-" + TYPE_DATA_JSON_FILE,"w") do |f|
f.write(JSON.pretty_generate(meths_hash))
end
File.open(name + "-" + FILE_MD... | [
"def persist_hashes(*args)\n db_path = \"flay.db\"\n files = {}\n\n if File.exist? db_path then\n File.open db_path, \"rb\" do |f|\n files = Marshal.load f\n end\n end\n\n args.each do |path|\n next if files[path] unless option[:redo]\n\n initialize self.option\n persi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates program log information for [+ repo_hash +], a hash containing information about the program. The log information has the format shown in LOG_HEADER. | def get_prog_log(repo_hash)
time = Time.now.getutc.to_s
if (repo_hash[:source] == "github")
[repo_hash[:name], repo_hash[:name].hash, repo_hash[:source], repo_hash[:repo][:html_url], repo_hash[:repo][:default_branch], repo_hash[:version], "", time, "", "", ""]
elsif (repo_hash[:source] == "rubygems")
[rep... | [
"def log_info\n begin\n # produces an error if there is nothing there\n @log = @git.log\n @last_commit = @log.first.date\n # TODO: Make status more meaningful. Possibly express how up to date the repo is\n @status << \"initialized\"\n \n rescue\n @log = []\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Downloads program represented by [+ repo_hash +]. | def download_prog(repo_hash)
if (repo_hash[:source] == "github")
clone_repo(repo_hash)
elsif (repo_hash[:source] == "rubygems")
puts "Unpacking gem #{repo_hash[:name]}..."
system "gem unpack #{repo_hash[:name]} --version #{repo_hash[:version]}"
else
raise "Unexpected source of repo #{repo_hash[:na... | [
"def download\n puts repo_get_url\n system(\"curl -o #{app}-repo.tgz '#{repo_get_url}'\")\n end",
"def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
used by ensure property to see if this share already exists on the system since we use prefetching, we have already determined whether we exist ahead of time, so we can just check our ensure value | def exists?
self.ensure == :present
end | [
"def shared?\n sharing != 'none'\n end",
"def shared?\n sharing != 'none'\n end",
"def exists?\n properties[:ensure] != :absent\n end",
"def set_yet?\n !!@resource_lock.synchronize { defined? @resource }\n end",
"def reuse?\n props[:instance][:create] == false || props[:inst... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns most current share name | def existing_share_name
# name is a synonym for path here since that is our namevar. share_name is the actual share_name
self.class.all_shares_attributes[name][:share_name] || File.basename(name)
end | [
"def unique_title\n share_num = 1\n while true\n title = \"Share\" + share_num.to_s\n cals = Calendar.where(user_id: current_user.id, title: title)\n subs = Subscription.where(user_id: current_user.id, title: title)\n if cals.size == 0 and subs.size == 0\n break\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a list of protocols and returns the share/guest access flags These take the form of 100, 101, 001, where each place enables or disables for that protocol As of 10.9, these are the keys and values are the same for setting guest access and for enabling sharing | def flags_for_protocols(protocols)
flag_keys = {:afp => 100, :ftp => 10, :smb => 1 }
# Start with no flags (0) and add each protocol's flag
flags_number = 0
protocols.each {|protocol| flags_number += flag_keys[protocol.downcase.to_sym] }
number_to_flags(flags_number)
end | [
"def get_enabled_protocols(protocols)\n Hash[ protocols.select {|k,v| v[\"shared\"] == \"1\" } ].keys\n end",
"def get_guest_protocols(protocols)\n Hash[ protocols.select {|k,v| v[\"guest access\"] == \"1\" } ].keys\n end",
"def guest_protocols=(desired_protocols)\n @share_edit_args += [ \"-g\", flag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for guest protocols (called automatically when syncing the resource) | def guest_protocols=(desired_protocols)
@share_edit_args += [ "-g", flags_for_protocols(desired_protocols) ]
end | [
"def protocol=(value)\n @protocol = value\n end",
"def protocol=(value)\n @protocol = value\n end",
"def set_Protocol(value)\n set_input(\"Protocol\", value)\n end",
"def app_protocol=(value)\n @app_protocol = value\n end",
"def get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for share_name (called automatically when syncing the resource) | def share_name=(new_name)
@share_edit_args += [ "-n", new_name ]
end | [
"def smb_name=(new_name)\n return if new_name == @resource.should(:share_name)\n @share_edit_args += [ \"-S\", new_name ]\n end",
"def existing_share_name\n # name is a synonym for path here since that is our namevar. share_name is the actual share_name\n self.class.all_shares_attributes[name][:shar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for afp_name (called automatically when syncing the resource) | def afp_name=(new_name)
return if new_name == @resource.should(:share_name)
@share_edit_args += [ "-A", new_name ]
end | [
"def fs_name=(value)\n @fs_name = value\n end",
"def full_name\n set_text('Name:', 205)\n set_text(formatted_name, 205, 'value')\n end",
"def set_name\n self.update(name: \"Xtra-Large Washer ##{self.id}\") unless self.name\n end",
"def ftp_name=(new_name)\n return if ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for smb_name (called automatically when syncing the resource) | def smb_name=(new_name)
return if new_name == @resource.should(:share_name)
@share_edit_args += [ "-S", new_name ]
end | [
"def net_bios_name=(value)\n @net_bios_name = value\n end",
"def on_premises_net_bios_name=(value)\n @on_premises_net_bios_name = value\n end",
"def set_name name\n\t\t\t@name = name.gsub \" (#{@addr})\", ''\n\t\tend",
"def set_name\n self.update(name: \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for ftp_name (called automatically when syncing the resource) | def ftp_name=(new_name)
return if new_name == @resource.should(:share_name)
@share_edit_args += [ "-F", new_name ]
end | [
"def fs_name=(value)\n @fs_name = value\n end",
"def file_name=(value)\n @file_name = value\n end",
"def file_or_folder_name=(value)\n @file_or_folder_name = value\n end",
"def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setter for afp_inherit_perms (called automatically when syncing the resource) | def afp_inherit_perms=(inherit)
@share_edit_args += [ "-i", inherit ? "10" : "00" ]
end | [
"def inherits_permissions_from=(value)\n @inherits_permissions_from = value\n end",
"def retain_inherited_permissions=(value)\n @retain_inherited_permissions = value\n end",
"def effective_permissions\n source = self\n\n w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns list of supported protocols | def supported_protocols
["afp", "smb", "ftp"]
end | [
"def ssl_protocols\n each_ssl_protocol.to_a\n end",
"def tls_protocols\n each_tls_protocol.to_a\n end",
"def ssl_protocols\n each_ssl_protocol.to_a\n end",
"def protocols\n Array.wrap(options[:protocols] || %w{http https})\n end",
"def tls_protocols\n each_tls_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
extracts the value for a protocol key | def protocol_value_for_key_in_string(key, string)
string.split(/#{key}:\t*/)[1].to_s.split("\n").first
end | [
"def extract_value(key, line)\n found = line.match(key.concat(VALUE_SUFFIX_REGEX))\n found[0].split(':').last.gsub('_', ' ') if found != nil\n end",
"def extract_protocol(protocol_string)\n [\"name\", \"shared\", \"guest access\", \"inherit perms\"].inject({}) do |hash, key|\n hash[key] = pro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
takes a protocol string snippet and returns a hash of the protocol keys and values | def extract_protocol(protocol_string)
["name", "shared", "guest access", "inherit perms"].inject({}) do |hash, key|
hash[key] = protocol_value_for_key_in_string(key, protocol_string)
hash
end
end | [
"def parse_hash_packet(data)\n hashes = []\n\n algo = data.read_string\n size = case algo\n when \"md5\" then 128\n when \"sha256\" then 256\n when \"sha384\" then 284\n when \"sha512\" then 512\n else raise NotImplementedError, \"unsupported algorithm: #{algo}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
selects only the enabled protocols from a hash of protocols | def get_enabled_protocols(protocols)
Hash[ protocols.select {|k,v| v["shared"] == "1" } ].keys
end | [
"def get_guest_protocols(protocols)\n Hash[ protocols.select {|k,v| v[\"guest access\"] == \"1\" } ].keys\n end",
"def collection_protocols\n collection_registrations.map { |reg| reg.protocol }.uniq\n end",
"def protocols\n get('shodan/protocols')\n end",
"def ssl_protocols\n each... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
selects only the guest enabled protocols from a hash of protocols | def get_guest_protocols(protocols)
Hash[ protocols.select {|k,v| v["guest access"] == "1" } ].keys
end | [
"def get_enabled_protocols(protocols)\n Hash[ protocols.select {|k,v| v[\"shared\"] == \"1\" } ].keys\n end",
"def guest_protocols=(desired_protocols)\n @share_edit_args += [ \"-g\", flags_for_protocols(desired_protocols) ]\n end",
"def collection_protocols\n collection_registrations.map { |reg| re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For any URL, to_s should return the url passed to Git::URL.parse(url) | def test_to_s
GIT_URLS.each do |url_data|
url = url_data[:url]
to_s = Git::URL.parse(url).to_s
assert_equal(url, to_s, "Parsed URI#to_s does not return the original URL '#{url}' correctly")
end
end | [
"def url_safe\n URI.parse(url).to_s\n rescue URI::InvalidURIError\n URI.escape url\n end",
"def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end",
"def to_s\n url\n end",
"def to_url\n to_uri.to_s\n end",
"def normalize\n Wgit::Url.new(@uri.normalize.to_s)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
modified method to support JNDI connections | def new_connection(config)
username = nil
if config[:jndi]
jndi = config[:jndi].to_s
ctx = javax.naming.InitialContext.new
ds = nil
# tomcat needs first lookup method, oc4j (and maybe other application servers) need second method
begin
... | [
"def get_connection_from_jndi\n jndi_name = JNDI_URI_REGEXP.match(uri)[1]\n JavaxNaming::InitialContext.new.lookup(jndi_name).connection\n end",
"def get_connection_from_jndi\n jndi_name = JNDI_URI_REGEXP.match(uri)[1]\n JavaxNaming::InitialContext.new.lookup(jndi_name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return java.sql.SQLException error code | def error_code(exception)
case exception
when Java::JavaSql::SQLException
exception.getErrorCode
else
nil
end
end | [
"def jdbc_exception; @jdbc_exception end",
"def error_code\n if ( @error_code ||= nil ).nil?\n @error_code = jdbc_exception ? jdbc_exception.getErrorCode : nil\n else\n @error_code\n end\n end",
"def sqlite_error_code(exception)\n exception.resultCode.code if exception.r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This tells declare_parameter to mark all the rest of the parameters as "set" parameters. Useful for separating "get" and "set" parameters in the help message. | def mark_the_rest_as_set_params
@mark_the_rest_as_set_params = true
end | [
"def set_resource_parameters(resource, scope)\n set = {}\n resource.to_hash.each do |param, value|\n param = param.to_sym\n fail Puppet::ParseError, \"#{resource.ref} does not accept attribute #{param}\" unless valid_parameter?(param)\n\n exceptwrap { scope.setvar(param.to_s, value) }\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs percolator on the given files | def run
puts "\n--------------------------------"
puts "Running Percolator...\n\n"
outputs = []
threads = []
tab_files = []
# The format of the following function was chosen to rersult in the fastest processing time.
proteins = load_target(':')
GC.start
# Currently usi... | [
"def run\n puts \"\\n--------------------------------\"\n puts \"Running Percolator...\\n\\n\"\n \n database = extractDatabase(@type).chomp(\"fasta\") + \"yml\"\n revDatabase = extractDatabase(@type + \"-r\").chomp(\"fasta.reverse\") + \"yml\"\n @proteins = Hash.new\n @decoyProteins = Hash.new\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells if the player won by looking at some square id'd by number | def won?(player, square_number)
get_containing(square_number).any? do |array|
array.all? { |element| element.to_s.strip == player.piece }
end
end | [
"def board_won?\n\t\twon = false\n\t\t\n\t\tWINNING_POSITIONS.each do |positions|\n\t\t\tn = 0\n\t\t\tfor i in 0..8\n\t\t\t n += 1 if (positions[i] == @gameplay_positions[i] && positions[i] != 0)\n\t\t\tend\n\t\t\tif n == 3\n\t\t\t\twon = true\n\t\t\tend\n\t\tend\n\n\t\twon ? true : false\n\tend",
"def check_wi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /admin/subscription_plans GET /admin/subscription_plans.json | def index
@admin_subscription_plans = Admin::SubscriptionPlan.all
end | [
"def plans\n @api.get_plans( :project_id => @id )\n end",
"def plans\n subscriptions.map(&:plan)\n end",
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def list_notification_plans\n \trequest_json(\"https://monitoring.api.rackspacecloud.com/v1.0/#{tennan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/subscription_plans POST /admin/subscription_plans.json | def create
@admin_subscription_plan = Admin::SubscriptionPlan.new(admin_subscription_plan_params)
respond_to do |format|
if @admin_subscription_plan.save
format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully created.' }
format.json { ren... | [
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def create\n\t\tif... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/subscription_plans/1 PATCH/PUT /admin/subscription_plans/1.json | def update
respond_to do |format|
if @admin_subscription_plan.update(admin_subscription_plan_params)
format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully updated.' }
format.json { render :show, status: :ok, location: @admin_subscription_plan }... | [
"def update_plan(plan_id, prorate, options = nil)\n request = Request.new(@client)\n path = \"/subscriptions/\" + CGI.escape(@id) + \"\"\n data = {\n 'plan_id'=> plan_id, \n 'prorate'=> prorate\n }\n\n response = Response.new(request.put(path, data, options))\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/subscription_plans/1 DELETE /admin/subscription_plans/1.json | def destroy
if @admin_subscription_plan.destroy
flash[:notice] = 'Subscription plan was successfully destroyed.'
else
flash[:error] = "Sorry your subscription plan couldn't be deleted"
end
respond_to do |format|
format.html { redirect_to admin_subscription_plans_url }
... | [
"def destroy\n @admin_plan.destroy\n respond_to do |format|\n format.html { redirect_to admin_plans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @billing_plan.destroy\n respond_to do |format|\n format.html { redirect_to billing_plans_url }\n format.json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if AST node is an attribute assignment? | def attribute_assignment?
arguments.one? && attribute_assignment_selector?
end | [
"def attribute_assignment?\n arguments.one? && ATTRIBUTE_ASSIGNMENT =~ selector\n end",
"def attribute?\n node_type == ATTRIBUTE_NODE\n end",
"def attribute?\r\n node_type == ATTRIBUTE_NODE\r\n end",
"def attribute_assignment?\n !BINARY_OPERATORS.include?(selec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if AST node is an index assign | def index_assignment?
arguments.length.equal?(2) && index_assignment_selector?
end | [
"def assignment?(node); end",
"def first_assignment?(node); end",
"def should_be_index?(readme); end",
"def match parser, index\r\n report parser.literal?(value, index)\r\n end",
"def check_index(index) # :nodoc:\n unless index.index_attrs == index_attrs\n raise ArgumentError.new(\"incompati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for binary operator implemented as method | def binary_method_operator?
arguments.one? && Types::BINARY_METHOD_OPERATORS.include?(selector)
end | [
"def binary_operator?\n arguments.one? && BINARY_METHOD_OPERATORS.include?(selector)\n end",
"def binary_operator?\n Mutant::BINARY_METHOD_OPERATORS.include?(node.name)\n end",
"def on_binary(left, operator, right); end",
"def binary_operation?; end",
"def argument_with_o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test for attribute assignment selector | def attribute_assignment_selector?
!Types::METHOD_OPERATORS.include?(selector) && selector.to_s.end_with?(ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX)
end | [
"def attribute_assignment?\n arguments.one? && ATTRIBUTE_ASSIGNMENT =~ selector\n end",
"def parse_attr_selector\n return false if not @lexer.get or @lexer.get.type != :left_bracket\n trace = @lexer.trace\n @lexer.next!\n \n ns = :any\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize a new Timecode object with a certain amount of frames and a framerate will be interpreted as the total number of frames | def initialize(total = 0, fps = DEFAULT_FPS)
raise WrongFramerate, "FPS cannot be zero" if fps.zero?
# If total is a string, use parse
raise RangeError, "Timecode cannot be negative" if total.to_i < 0
# Always cast framerate to float, and num of rames to integer
@total, @fps = total.to_i, fps.to_f
... | [
"def initialize\n @frame_count = 0\n set_time(9, 00)\n end",
"def initialize(total = 0, fps = DEFAULT_FPS, drop_frame = false)\n raise WrongFramerate, \"FPS cannot be zero\" if fps.zero?\n self.class.check_framerate!(fps)\n # If total is a string, use parse\n raise RangeError, \"Timecode cannot... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse a timecode with fractional seconds instead of frames. This is how ffmpeg reports a timecode | def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)
fraction_expr = /\.(\d+)$/
fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f
seconds_per_frame = 1.0 / fps.to_f
frame_idx = (fraction_part / seconds_per_frame).floor
tc_with... | [
"def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)\n fraction_expr = /[\\.,](\\d+)$/\n fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f\n\n seconds_per_frame = 1.0 / fps.to_f\n frame_idx = (fraction_part / seconds_per_frame).floor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse a timecode with ticks of a second instead of frames. A 'tick' is defined as 4 msec and has a range of 0 to 249. This format can show up in subtitle files for digital cinema | def parse_with_ticks(tc_with_ticks, fps = DEFAULT_FPS)
ticks_expr = /(\d{3})$/
ticks_part = (tc_with_ticks.scan(ticks_expr)[0][0]).to_i
seconds_per_frame = 1.0 / fps
frame_idx = ((ticks_part * 0.004) / seconds_per_frame ).floor
tc_with_frameno = tc_with_ticks.gsub(ticks_expr, "%02d" % f... | [
"def parse_with_ticks(tc_with_ticks, fps = DEFAULT_FPS)\n ticks_expr = /(\\d{3})$/\n num_ticks = tc_with_ticks.scan(ticks_expr).join.to_i\n\n raise RangeError, \"Invalid tick count #{num_ticks}\" if num_ticks > 249\n\n seconds_per_frame = 1.0 / fps\n frame_idx = ( (num_ticks * 0.004) / seco... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate that framerates are within a small delta deviation considerable for floats | def framerate_in_delta(one, two)
(one.to_f - two.to_f).abs <= ALLOWED_FPS_DELTA
end | [
"def validate_float(v); end",
"def check_float(a, b)\n tolerance = Math::TOLERANCE\n a = a.to_f\n b = b.to_f\n if a.finite? and b.finite?\n (a-b).abs < tolerance\n else\n true\n end\nend",
"def assert_float(exp, act, msg = nil)\n e, a = exp.to_f, act.to_f\n if e.finite? && a.finite? && (n = (e - a... | {
"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.