query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
DELETE /jobs/1 DELETE /jobs/1.xml | def destroy
@job = Job.find(params[:id])
parent = @job.parent
@job.destroy
respond_to do |format|
format.js {render :js => 'done'}
format.html { redirect_to(parent.present? ? supplier_job_path(params[:supplier_id], parent.id) : supplier_jobs_path(params[:supplier_id])) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n node = @job.nodes.find(params[:id])\n @job.nodes.delete(node)\n\n respond_to do |format|\n format.html { redirect_to job_url(@job) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n ... | [
"0.7452005",
"0.7419979",
"0.7241207",
"0.7198782",
"0.7195508",
"0.71373975",
"0.71373975",
"0.71373975",
"0.71373975",
"0.71373975",
"0.71373975",
"0.71373975",
"0.71373975",
"0.7121943",
"0.707634",
"0.70635164",
"0.69475687",
"0.69224626",
"0.68076",
"0.678244",
"0.677547... | 0.0 | -1 |
now we've got sugarcube568_imageNamed and imageNamed_old to load the respective versions | def imageNamed(name)
sugarcube568_imageNamed(name) || imageNamed_old(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imageNamed(name)\n imageNamed568(name) || imageNamed_old(name)\n end",
"def load_previous_version_images\n images = {}\n version = load_previous_version\n return images if ! version\n version.units.all.each do |unit|\n unit.images.all.each do |image|\n images[image.name.to_s] ... | [
"0.68936616",
"0.6532221",
"0.6073566",
"0.59153056",
"0.5793694",
"0.5790865",
"0.57836723",
"0.57596403",
"0.5753062",
"0.5632101",
"0.56092405",
"0.558377",
"0.5563116",
"0.55493844",
"0.55419856",
"0.55281574",
"0.54937285",
"0.5467317",
"0.5459248",
"0.54346603",
"0.5424... | 0.7264912 | 0 |
Insert all documents that have been previously saved into the document's `/inserts` folder in the asset store. | def insert_documents(insert_page_at, document_count, eventual_access=nil)
eventual_access ||= self.access || PRIVATE
self.update_attributes :access => PENDING
self.processing_jobs.new(
:action => 'document_insert_pages',
:account_id => account_id,
:title=>title,
:options => {
:id => id,
:insert_page_at => insert_page_at,
:pdfs_count => document_count,
:access => eventual_access
}
).queue
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_process_batch_insert(docs)\n docs.map do |doc|\n next unless doc\n append(doc)\n if persistable? && !_assigning?\n self.path = doc.atomic_path unless path\n if doc.valid?(:create)\n doc.run_before_callbacks(:save, :create)\n... | [
"0.6468581",
"0.64565676",
"0.6141663",
"0.6056899",
"0.59336126",
"0.5893217",
"0.5812048",
"0.5722167",
"0.5637171",
"0.5619128",
"0.55665207",
"0.55480045",
"0.5512628",
"0.5493801",
"0.54933095",
"0.5415548",
"0.53882885",
"0.5374697",
"0.5373367",
"0.53334683",
"0.532624... | 0.54784405 | 15 |
Ensure that titles are stripped of trailing whitespace. | def title=(title="Untitled Document")
# Clean the stripped title
self[:title] = CGI.unescape_html(self.strip title.strip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_blanks\n self.title = self.title.strip\n end",
"def strip_blanks\n self.title = self.title.strip\n end",
"def strip_whitespace\n self.title = self.title.strip\n end",
"def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end",
"def remove_whitespace\n self.title = sel... | [
"0.7734926",
"0.7734926",
"0.7708592",
"0.73002577",
"0.7275279",
"0.7145224",
"0.7083284",
"0.70476735",
"0.6973481",
"0.68507135",
"0.67134714",
"0.669988",
"0.6695074",
"0.6672396",
"0.6553552",
"0.65170956",
"0.64457536",
"0.6415425",
"0.64105994",
"0.6408349",
"0.6393755... | 0.0 | -1 |
Save all text assets, including the `combined_page_text`, and the text of each page individually, to the asset store. | def upload_text_assets(pages, access)
asset_store.save_full_text(self, access)
pages.each do |page|
asset_store.save_page_text(self, page.page_number, page.text, access)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n apply\n $scripts=[]\n for i in @pages\n next if i.nil?\n $scripts<<[i.stoppoints,i.name,Zlib::Deflate.deflate(i.script)]\n end\n GC.start\n end",
"def save_page page\n return unless page.text?\n\n path = page_file page.full_name\n\n FileUtils.mkdir_p File.dirname(pat... | [
"0.55962205",
"0.55507225",
"0.5429495",
"0.5412409",
"0.5299393",
"0.5299038",
"0.52539974",
"0.5238184",
"0.5228696",
"0.52244806",
"0.5206119",
"0.5179005",
"0.51789945",
"0.5177082",
"0.51638323",
"0.5088538",
"0.50697184",
"0.50645953",
"0.50645953",
"0.5056267",
"0.5039... | 0.77455944 | 0 |
Update a document, with S3 permission fixing, cache expiry, and access control. | def secure_update(attrs, account)
if !account.allowed_to_edit?(self)
self.errors.add(:base, "You don't have permission to update the document." )
return false
end
access = attrs.delete :access
access &&= access.to_i
published_url = attrs.delete :published_url
attrs[:remote_url] ||= published_url
data = attrs.delete :data
update_attributes attrs
self.data = data if data
set_access(access) if access && self.access != access
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_document(obj)\n visibility_changed = visibility_status(obj)\n obj.attributes = work_params\n obj.date_modified = Time.current.ctime\n obj.save\n VisibilityCopyJob.perform_later(obj) if visibility_changed\n InheritPermissionsJob.perform_later(obj) if work_params.fetch(:permissions_attri... | [
"0.68818676",
"0.64250505",
"0.6407086",
"0.6407086",
"0.6277202",
"0.6263566",
"0.6238744",
"0.6227901",
"0.6196237",
"0.61919606",
"0.6175464",
"0.6168635",
"0.6142867",
"0.6135202",
"0.61308074",
"0.6104177",
"0.61019415",
"0.60974413",
"0.60667354",
"0.6065294",
"0.605365... | 0.665254 | 1 |
For polymorphism on access control with Note and Section: | def document_id
id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_notes\n \n end",
"def private_notes\n end",
"def section; end",
"def audit section\n\t\t\tsection\n\t\tend",
"def can_edit?(doc_type)\n self.can_access?(doc_type)\n end",
"def access_info\n super\n end",
"def sections\n account.accessible_sections if account\n end",
"... | [
"0.5881289",
"0.58406115",
"0.5782376",
"0.5707754",
"0.5632676",
"0.5603648",
"0.546491",
"0.54600567",
"0.54448444",
"0.53993917",
"0.5398793",
"0.5328593",
"0.5307072",
"0.52543974",
"0.52543974",
"0.5235695",
"0.5230199",
"0.52281296",
"0.52259094",
"0.52257186",
"0.52118... | 0.0 | -1 |
Produce the full text of the document by combining the text of each of the pages. Used at initial import. | def combined_page_text
self.pages.order('page_number asc').pluck(:text).join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_pages_to_text\n reader.pages.each do |page|\n raw_extracted_pages << page.text.split(\"\\n\")\n end\n end",
"def content_fulltext(page_xml, paper_title, page_title)\n page_path = Pathname.new(@source)\n basename = page_path.basename.to_s.gsub('.xml', '')\n full_text_p... | [
"0.6827037",
"0.661266",
"0.63545054",
"0.6271447",
"0.6250127",
"0.62302476",
"0.62280506",
"0.620762",
"0.61110324",
"0.6095425",
"0.6049715",
"0.6027878",
"0.59439987",
"0.5918354",
"0.58808285",
"0.58788574",
"0.5835971",
"0.57839525",
"0.57797146",
"0.5739447",
"0.572546... | 0.73425186 | 0 |
Determine the number of annotations on each page of this document. | def per_page_annotation_counts
self.annotations.group('page_number').count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_annotations_count page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n str_uri = $product_uri... | [
"0.78737545",
"0.6964414",
"0.6594237",
"0.6590082",
"0.65886855",
"0.6553357",
"0.6550715",
"0.6539981",
"0.6535128",
"0.65301055",
"0.65301055",
"0.6505616",
"0.6499778",
"0.64700586",
"0.64520293",
"0.64335287",
"0.6422388",
"0.64068544",
"0.64063936",
"0.6401035",
"0.6397... | 0.8656055 | 0 |
Return an array of all of the document entity values for a given type, for Solr indexing purposes. | def entity_values(kind)
self.entities.kind(kind.to_s).pluck('value')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entities(type)\n @entities[type.name]\n end",
"def index\n @type_of_values = TypeOfValue.all\n end",
"def datatypes\n value.document.fetch(\"#{value.key}_type\", [])\n end",
"def fields_for_type(type)\n return @field_mapping[type] || Set.new\n end",
"def list(t... | [
"0.6474695",
"0.6416341",
"0.63455075",
"0.62797475",
"0.6140852",
"0.61085665",
"0.593722",
"0.5888546",
"0.58861524",
"0.5794548",
"0.57635224",
"0.5757715",
"0.5748562",
"0.5716814",
"0.5648104",
"0.564423",
"0.5637249",
"0.5605242",
"0.5586327",
"0.5575393",
"0.5568374",
... | 0.63140684 | 3 |
Reset the cached counter of public notes on the document. | def reset_public_note_count
count = annotations.unrestricted.count
if count != self.public_note_count
update_attributes :public_note_count => count
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_counter; end",
"def set_note(n)\n @note = 0\n end",
"def reset\n @count = 0\n end",
"def clear; @docs[] = {} end",
"def reset!\n LinerNotes.logger.debug \"--- RESETTING ---\"\n @track_credits = nil\n @album_credits = nil\n @individual_credits = nil\n @artwork = nil\... | [
"0.624501",
"0.61837107",
"0.6080125",
"0.60098344",
"0.5901831",
"0.5845609",
"0.58312446",
"0.57278055",
"0.5719366",
"0.5709244",
"0.56585896",
"0.562301",
"0.562301",
"0.5560256",
"0.554109",
"0.55210483",
"0.5510694",
"0.55036366",
"0.54875326",
"0.54749024",
"0.5469772"... | 0.750443 | 0 |
Return a hash of all the document's entities (for an API response). The hash is ordered by entity kind, after the sidebar, with individual entities sorted by relevance. | def ordered_entity_hash
hash = ActiveSupport::OrderedHash.new
DC::VALID_KINDS.each {|kind| hash[kind] = [] }
entities.each do |e|
hash[e.kind].push :value => e.value, :relevance => e.relevance
end
hash.each do |key, list|
hash[key] = list.sort_by {|e| -e[:relevance] }
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entities\n @entities ||= begin\n acc = {}\n @api.routes.filter_map(&:entity).each do |entity|\n collect_entities(acc, entity)\n end\n acc.keys.sort_by(&:name)\n end\n end",
"def entities\n return bad_request unless params[:id] and request.format.json? || r... | [
"0.6685144",
"0.6448963",
"0.5882639",
"0.5882639",
"0.5837262",
"0.5734265",
"0.5731404",
"0.5664527",
"0.5650625",
"0.56401956",
"0.56066865",
"0.5595238",
"0.5595238",
"0.55951166",
"0.5537426",
"0.54904765",
"0.5458033",
"0.54162407",
"0.54103583",
"0.5402562",
"0.5385085... | 0.67121935 | 0 |
updates the document's character count by detecting the largest end_offset off our pages. | def reset_char_count!
update_attributes :char_count => 1+self.pages.maximum(:end_offset).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_length(offset, end_offset)\n effective_line = @locator.line_for_offset(end_offset) - @locator.line_for_offset(offset)\n locator.char_length(offset, end_offset) + (effective_line * @leading_line_offset)\n end",
"def char_length(offset, end_offset)\n end",
"def char_length(offset, end_offs... | [
"0.57933974",
"0.56286603",
"0.55321014",
"0.54675525",
"0.54235876",
"0.5374911",
"0.5298904",
"0.52900696",
"0.5244548",
"0.52311796",
"0.52136344",
"0.51916903",
"0.51326364",
"0.5110331",
"0.5110331",
"0.5102242",
"0.5098795",
"0.5072326",
"0.50568926",
"0.50568926",
"0.5... | 0.7333622 | 0 |
Does this document have a title? | def titled?
title.present? && (title != DEFAULT_TITLE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasTitle\n if @title then\n true\n else\n false\n end\n end",
"def inferred_title?(document); end",
"def has_title?\n @title != nil\n end",
"def title?\n @assigned_paragraph_type == :title\n end",
"def inferred_title?(document)\n return false unles... | [
"0.8606401",
"0.8454915",
"0.8200039",
"0.8041204",
"0.8004934",
"0.79137343",
"0.78353626",
"0.7740822",
"0.7740822",
"0.7700232",
"0.76467276",
"0.75731164",
"0.7557868",
"0.75455636",
"0.74813765",
"0.74781764",
"0.7375217",
"0.7311967",
"0.72917736",
"0.72851545",
"0.7203... | 0.7805069 | 7 |
When the access level changes, all subresource and asset permissions need to be updated. | def set_access(access_level)
changes = {:access => PENDING}
changes[:publish_at] = nil if PUBLIC_LEVELS.include? access_level
update_attributes changes
background_update_asset_access access_level
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_access_controls!\n update!(edit_users: permission_template.agent_ids_for(access: 'manage', agent_type: 'user'),\n edit_groups: permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))\n end",
"def do_acl_changes\n if access_controls.requires_changes?\n ... | [
"0.6638481",
"0.6476497",
"0.6476497",
"0.6448233",
"0.62101257",
"0.61848336",
"0.6075828",
"0.6074644",
"0.600127",
"0.59954625",
"0.59309286",
"0.59273237",
"0.58997303",
"0.58997303",
"0.58597916",
"0.5847865",
"0.5847865",
"0.57794476",
"0.5778734",
"0.5778734",
"0.57787... | 0.6898231 | 0 |
If we need to change the ownership of the document, we have to propagate the change to all associated models. | def set_owner(account)
unless org = account.organization
errors.add(:account, "must have an organization") and return false
end
update_attributes(:account_id => account.id, :organization_id => org.id)
sql = "account_id = #{account.id}, organization_id = #{org.id}"
self.pages.update_all( sql )
self.entities.update_all( sql )
self.entity_dates.update_all( sql )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_ownership; end",
"def restore_ownership; end",
"def after_save \n return unless @owner\n\n unless owner_role.nil?\n owner_role.users.each do |user|\n accepts_no_role!( :owner, user ) # unassign previous owners\n end\n end\n \n... | [
"0.6337711",
"0.6337711",
"0.6123703",
"0.60103095",
"0.58914506",
"0.58688754",
"0.5866902",
"0.58403426",
"0.5801534",
"0.57156944",
"0.56937575",
"0.5689962",
"0.56714606",
"0.56451887",
"0.5631376",
"0.5605006",
"0.5595832",
"0.5570872",
"0.5565383",
"0.55379623",
"0.5536... | 0.51721907 | 65 |
Documents don't themselves have an aspect ratio, as individual pages can have differing aspect ratios. We should considering calculating and storing an ideal aspect ratio that will be wrong for the least number of pages. Until then, we just return the first page's aspect ratio. | def safe_aspect_ratio
pages.first.safe_aspect_ratio
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aspect_ratio\n return 'none' unless fixed_ratio?\n dims = fullsize_settings[:dimensions]\n dims[0].to_f / dims[1]\n end",
"def aspect_ratio\n if self.width && self.height\n return self.width/self.height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n ... | [
"0.73481125",
"0.72288257",
"0.7040896",
"0.69896793",
"0.668754",
"0.66756976",
"0.662657",
"0.65336084",
"0.6385839",
"0.6345753",
"0.62481636",
"0.62335086",
"0.6145229",
"0.6095233",
"0.6034445",
"0.5984581",
"0.5973498",
"0.5916359",
"0.5895308",
"0.5820019",
"0.5762467"... | 0.8242837 | 0 |
Externally used image path, not to be confused with `page_image_path()` | def page_image_template
"#{slug}-p{page}-{size}.gif"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_path\n \"#{PATH}/#{image_filename}\"\n end",
"def page_image_path(page_number, size)\n File.join(pages_path, \"#{slug}-p#{page_number}-#{size}.gif\")\n end",
"def giant_path\n \"g_#{image_path}\"\n end",
"def image_path(image)\r\n image.rel_path\r\n end",
"def image(page_image = '... | [
"0.7650894",
"0.7416475",
"0.7297698",
"0.72710353",
"0.7265467",
"0.7253573",
"0.7217244",
"0.71998996",
"0.7185095",
"0.7183806",
"0.7165193",
"0.7113745",
"0.7054708",
"0.70529044",
"0.70217425",
"0.699451",
"0.6991893",
"0.6980747",
"0.69629896",
"0.6854156",
"0.68498015"... | 0.68138754 | 23 |
Internally used image path, not to be confused with page_image_template() | def page_image_path(page_number, size)
File.join(pages_path, "#{slug}-p#{page_number}-#{size}.gif")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_image_template\n \"#{slug}-p{page}-{size}.gif\"\n end",
"def image_path\n \"#{PATH}/#{image_filename}\"\n end",
"def giant_path\n \"g_#{image_path}\"\n end",
"def image_for(page)\n if page.main_image.exists?\n image_tag page.main_image.url\n else\n image_tag page.root.mai... | [
"0.7723291",
"0.75510156",
"0.740188",
"0.73719907",
"0.72654647",
"0.7210056",
"0.7180687",
"0.71671045",
"0.71297526",
"0.71255475",
"0.71107906",
"0.71013737",
"0.708507",
"0.70850617",
"0.7084603",
"0.7056477",
"0.70080036",
"0.6991442",
"0.698584",
"0.6970849",
"0.696984... | 0.74867046 | 2 |
Temporarily used for tabula processing intended to be extracted into a tabula namespace in future. | def page_csv_path(page_number)
File.join(pages_path, "#{slug}-p#{page_number}.csv")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_table; end",
"def post_processing_tables(nodes)\n tables = nodes\n .css('table:not(.o-ld-columns-table)')\n .add_class('c-ld-table')\n tables.wrap('<div class=\"c-ld-table__wrap\"></div>') unless @options[:material]\n end",
"def reconstitute_step(step_text... | [
"0.5954213",
"0.54071563",
"0.52411115",
"0.5240897",
"0.5155906",
"0.51430553",
"0.510546",
"0.50890815",
"0.50829566",
"0.5076232",
"0.50529045",
"0.50250256",
"0.50164926",
"0.50161356",
"0.501386",
"0.49771923",
"0.4949652",
"0.49276152",
"0.4917898",
"0.49131048",
"0.490... | 0.0 | -1 |
Keep a local ProcessingJob record of this active CloudCrowd Job. Use record_job | def record_job(job_json)
job = JSON.parse(job_json)
processing_jobs.create!(
:account_id => account_id,
:cloud_crowd_id => job['id'],
:title => title,
:remote_job => job
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue\n # If a Document is associated with this ProcessingJob, determine\n # whether the Document is available to be worked on, and if it's not\n # use ActiveRecord's error system to indicate it's unavailability.\n #if document and document.has_running_jobs?\n # errors.add(:document, \"This doc... | [
"0.6781324",
"0.6015498",
"0.59980714",
"0.59472966",
"0.5873365",
"0.5867775",
"0.5859998",
"0.584067",
"0.57934386",
"0.57781696",
"0.5767818",
"0.57500464",
"0.57348454",
"0.57296985",
"0.57122576",
"0.5711334",
"0.5699153",
"0.56836224",
"0.56673217",
"0.56673217",
"0.565... | 0.6681429 | 1 |
Create an identical clone of this document, in all ways (except for the ID). toggles to include various aspects of documents: include_docdata => true/false include_sections => true/false include_annotations => true/false & conditioned on if the recipient should be treated as owner include_project => true/false: copy the documents into the same projects the original doc is in. | def duplicate!(recipient=nil, options={})
Document.transaction do
# Clone the document.
newattrs = attributes.dup.merge({
:access => PENDING,
:created_at => Time.now,
:updated_at => Time.now
})
newattrs.delete('id')
newattrs[:account_id] = recipient.id if recipient
newattrs[:organization_id] = recipient.organization.id if recipient and not newattrs[:organization_id]
copy = Document.create!(newattrs.merge({:hit_count => 0, :detected_remote_url => nil}))
newattrs = {:document_id => copy.id}
# Clone the docdata.
if docdata and options['include_docdata']
Docdata.create! document_id: copy_id, data: docdata.data.dup
end
# Clone the associations.
associations = [entities, entity_dates, pages]
associations.push sections if options['include_sections']
# Copy all notes that are visible by either the document owner or the recipient
account_context = options['as_owner'] ? self.account : recipient
associations.push annotations.accessible(account_context) if options['include_annotations']
# Copy the new document into all of the same projects as the old document
associations.push project_memberships if options['include_project']
associations.each do |association|
association.each do |model|
model_attrs = model.attributes.dup.merge newattrs
model_attrs.delete('id')
model.class.create! model_attrs
end
end
# Clone the assets.
DC::Store::AssetStore.new.copy_assets(self, copy, self.access)
# Reindex, set access.
copy.index
copy.set_access access
copy
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_for_template(document)\n dup_field = self.dup\n dup_field.document = document\n dup_field\n end",
"def replicate\n\n self.class.new(document, ref, source: source.dup)\n end",
"def build\n if expand_document\n combine_layout\n combine_activity_metadata\n ... | [
"0.6470156",
"0.6108942",
"0.6086397",
"0.6070406",
"0.57580686",
"0.5739125",
"0.571301",
"0.5681215",
"0.56742346",
"0.5669589",
"0.5634285",
"0.5602384",
"0.55871075",
"0.55836535",
"0.55686194",
"0.5552745",
"0.54687065",
"0.5444203",
"0.5413753",
"0.5395581",
"0.5391251"... | 0.7389626 | 0 |
TODO: Make the to_json an extended form of the canonical. | def as_json(opts={})
json = {
:id => id,
:organization_id => organization_id,
:account_id => account_id,
:created_at => created_at.to_date.strftime(DISPLAY_DATE_FORMAT),
:access => access,
:page_count => page_count,
:annotation_count => annotation_count || 0,
:public_note_count => public_note_count,
:title => title,
:slug => slug,
:source => source,
:description => description,
:organization_name => organization_name,
:organization_slug => organization_slug,
:organization_documents_url => organization_documents_url,
:account_name => account_name,
:account_slug => account_slug,
:account_documents_url => account_documents_url,
:related_article => related_article,
:pdf_url => pdf_url,
:thumbnail_url => thumbnail_url( { :cache_busting => opts[:cache_busting] } ),
:full_text_url => full_text_url,
:page_image_url => page_image_url_template( { :cache_busting => opts[:cache_busting] } ),
:page_text_url => page_text_url_template( { :cache_busting => opts[:cache_busting] } ),
:canonical_url => canonical_url(:html),
:document_viewer_url => document_viewer_url,
:document_viewer_js => canonical_url(:js),
:reviewer_count => reviewer_count,
:remote_url => remote_url,
:detected_remote_url => detected_remote_url,
:publish_at => publish_at.as_json,
:hits => hits,
:mentions => mentions,
:total_mentions => total_mentions,
:project_ids => project_ids,
:char_count => char_count,
:data => data,
:language => language,
:file_hash => file_hash
}
if opts[:annotations]
json[:annotations_url] = annotations_url if commentable?(opts[:account])
json[:annotations] = self.annotations_with_authors(opts[:account])
end
json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(options={})\n canonical(options).to_json\n end",
"def to_json_string\n MARC::JSONLWriter.encode(self)\n end",
"def to_json\n to_raw.to_json\n end",
"def to_json(*)\n\t\t\t# to_json needs to not care about arguments with the C extension\n\t\t\t# version of the JSON gem.\n\t\t\t... | [
"0.75769156",
"0.6889507",
"0.6834035",
"0.6825121",
"0.67475337",
"0.66842425",
"0.66818535",
"0.6641304",
"0.6641304",
"0.663225",
"0.6610654",
"0.65974265",
"0.65822506",
"0.65784353",
"0.65712535",
"0.65712535",
"0.6565441",
"0.6565441",
"0.6548345",
"0.6548345",
"0.65483... | 0.0 | -1 |
The filtered attributes we're allowed to display in the admin UI. | def admin_attributes
{
:id => id,
:account_name => account_name,
:organization_name => organization_name,
:page_count => page_count,
:thumbnail_url => thumbnail_url,
:pdf_url => pdf_url(direct: true),
:public => public?,
:title => public? ? title : nil,
:source => public? ? source : nil,
:created_at => created_at.to_datetime.strftime(DISPLAY_DATETIME_FORMAT),
:remote_url => remote_url,
:detected_remote_url => detected_remote_url
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_filter_attributes\n resource_class.attribute_names\n end",
"def attributes\n @allowed_attributes\n end",
"def _filtered_attributes\n return accessible_attributes.to_a if accessible_attributes.present?\n\n return self.new.attributes.keys - protected_attributes.to_a\n ... | [
"0.7758516",
"0.74291545",
"0.730456",
"0.72977936",
"0.7288793",
"0.7039144",
"0.6999964",
"0.6968357",
"0.69572985",
"0.68503386",
"0.68135995",
"0.66777176",
"0.6675979",
"0.66697246",
"0.6630031",
"0.6595662",
"0.658562",
"0.6517738",
"0.65152496",
"0.65148485",
"0.649069... | 0.0 | -1 |
Updates file_size and file_hash Will default to reading the data from the asset_store or can be passed arbitrary data such as from a file on disk | def update_file_metadata(data)
update_attributes!( :file_size => data.bytesize, :file_hash => Digest::SHA1.hexdigest( data ) )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_file_info\n if self.path\n size = File.exists?(self.path) ? File.size(self.path) : nil\n end\n if size\n (value, units) = bits_to_human_readable(size)\n self.size = value unless value.nil? or value.empty?\n self.size_units = units unless units.nil? or units.empty?\n ... | [
"0.6791512",
"0.66723084",
"0.6563773",
"0.64980394",
"0.64271307",
"0.6394023",
"0.6344489",
"0.62978506",
"0.62961334",
"0.62264585",
"0.6208466",
"0.61774457",
"0.6166524",
"0.60745484",
"0.6072598",
"0.6070162",
"0.60647684",
"0.6060879",
"0.60525876",
"0.60396755",
"0.60... | 0.73113394 | 0 |
Used for unit tests | def sleep(n)
Kernel.sleep(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def spec; end",
"def spec; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end"... | [
"0.7921957",
"0.7030221",
"0.7030221",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
"0.68979514",
... | 0.0 | -1 |
wraps Savon client methods for convenience | def get_lead_by_idnum(idnum)
@client.get_lead_by_idnum(idnum)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_client\n Savon.client(\n wsdl: @wsdl,\n endpoint: @endpoint,\n convert_request_keys_to: :none,\n soap_version: 1,\n pretty_print_xml: true,\n filters: [:password],\n logger: ... | [
"0.6878374",
"0.6774605",
"0.66199154",
"0.65472716",
"0.6526434",
"0.64873487",
"0.643791",
"0.6412938",
"0.6331157",
"0.63168603",
"0.6292211",
"0.628581",
"0.6259567",
"0.6238324",
"0.6203991",
"0.61314803",
"0.61314803",
"0.6021638",
"0.60110563",
"0.6002162",
"0.59782755... | 0.0 | -1 |
returns true if the two cuboids intersect each other. False otherwise. | def intersects?(other)
raise "NOT A CUBOID" unless other.is_a? Cuboid
self_range = range_finder
other_range = other.range_finder
self_range.each do |k,_|
return false unless overlap?(self_range[k], other_range[k])
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersects?(other_cuboid)\n\t\toverlaps_along_x_with?(other_cuboid) && overlaps_along_y_with?(other_cuboid) && overlaps_along_z_with?(other_cuboid)\n\tend",
"def intersects?(cuboid)\n return true if self == cuboid\n !left_face_is_right_of_other_right_face(cuboid) &&\n !right_face_is_left_of_other_... | [
"0.78990805",
"0.76804894",
"0.7523567",
"0.70820683",
"0.70796764",
"0.6934062",
"0.6906339",
"0.68007666",
"0.6741866",
"0.6598876",
"0.6483527",
"0.6462282",
"0.64231575",
"0.6355845",
"0.6319558",
"0.6306597",
"0.6286855",
"0.6268682",
"0.6268682",
"0.6268682",
"0.6259042... | 0.725815 | 3 |
rotates along given axis | def rotate!(axis)
raise "INVALID AXIS" unless ["x", "y", "z"].include?(axis.to_s)
case axis
when "x"
@origin[2] -= height
@origin[2] = 0 if z < 0
@dimensions[1], @dimensions[2] = depth, height
when "y"
@origin[2] -= width
@origin[2] = 0 if z < 0
@dimensions[0], @dimensions[2] = depth, width
when "z"
@origin[1] -= width
@origin[1] = 0 if y < 0
@dimensions[0], @dimensions[1] = height, width
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate!(axis)\n center = [origin[X]+width/2, origin[Y]+height/2, origin[Z]+length/2]\n case axis\n when :x\n self.height, self.length = self.length, self.height\n when :y\n self.width, self.length = self.length, self.width\n when :z\n self.width, self.height = self.height, self.wi... | [
"0.76205575",
"0.7495789",
"0.73058647",
"0.6895596",
"0.6892747",
"0.6885244",
"0.6478798",
"0.639373",
"0.6134381",
"0.6083075",
"0.60657007",
"0.60223764",
"0.60081553",
"0.59958315",
"0.59859276",
"0.59215266",
"0.59166354",
"0.59003484",
"0.5887707",
"0.58770895",
"0.585... | 0.7164591 | 3 |
check to see if the x, y and z range of 2 cuboids overlap | def overlap?(self_range, other_range)
return true if self_range == other_range
overlap_helper(self_range, other_range) || overlap_helper(other_range, self_range)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersects?(other_cuboid)\n\t\toverlaps_along_x_with?(other_cuboid) && overlaps_along_y_with?(other_cuboid) && overlaps_along_z_with?(other_cuboid)\n\tend",
"def colliding?(block)\n x2 > block.x1 &&\n x1 < block.x2 &&\n y2 > block.y1 &&\n y1 < block.y2 &&\n z2 > block.z1 &&\n z1 <... | [
"0.7726147",
"0.7491228",
"0.7271436",
"0.71529996",
"0.71063",
"0.70563054",
"0.6983636",
"0.695283",
"0.6880446",
"0.67826754",
"0.6779791",
"0.6734316",
"0.6718926",
"0.6690226",
"0.66063446",
"0.65880823",
"0.65805286",
"0.65580344",
"0.65351194",
"0.6493899",
"0.6480472"... | 0.0 | -1 |
Create a topic ==== Parameters name Name of topic to create ==== See Also | def create_topic(name)
request({
'Action' => 'CreateTopic',
'Name' => name,
:parser => Fog::Parsers::AWS::SNS::CreateTopic.new
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create name\n response = client.create_topic(:name => name)\n Topic.new(response.topic_arn, :config => config)\n end",
"def create_topic(sns, topic_name)\n req_hash = generate_request('CreateTopic', 'Name' => topic_name)\n arn = request_info(req_hash, SnsCreateTopicParser.new(:lo... | [
"0.91790056",
"0.82937074",
"0.8227159",
"0.80858",
"0.79557437",
"0.78835845",
"0.7814814",
"0.7768391",
"0.7694547",
"0.7612487",
"0.7532647",
"0.7486461",
"0.7410618",
"0.7378798",
"0.734722",
"0.7326911",
"0.7292466",
"0.7277718",
"0.7275666",
"0.7245585",
"0.72146744",
... | 0.88835526 | 1 |
support setting an RGeo object or a WKT string | def serialize(value)
return if value.nil?
geo_value = cast_value(value)
# TODO: - only valid types should be allowed
# e.g. linestring is not valid for point column
# raise "maybe should raise" unless RGeo::Feature::Geometry.check_type(geo_value)
RGeo::WKRep::WKBGenerator.new(hex_format: true, type_format: :ewkb, emit_ewkb_srid: true)
.generate(geo_value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wkt=(value)\n begin\n a = ::Gis::FACTORY.parse_wkt(value)\n b = a.geometry_type.type_name.tableize.singularize.to_sym\n\n self.geographic_item = GeographicItem.new(b => a)\n @wkt_error = nil\n rescue RGeo::Error::RGeoError => e\n self.geographic_item = nil\n @wkt_error = e.... | [
"0.7202398",
"0.6309818",
"0.6215792",
"0.6098635",
"0.6024202",
"0.6024202",
"0.6006036",
"0.59561497",
"0.59482825",
"0.5900866",
"0.5875878",
"0.58646154",
"0.5804384",
"0.5798024",
"0.5790414",
"0.5756337",
"0.56999433",
"0.56589955",
"0.5646789",
"0.5641992",
"0.56418467... | 0.0 | -1 |
convert WKT string into RGeo object | def parse_wkt(string)
wkt_parser(string).parse(string)
rescue RGeo::Error::ParseError
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_wkt(string)\n value, srid = string.split(\",\")\n @srid = srid if srid.present?\n # factory = factory_settings.get_column_factory(table_name, column, constraints)\n factory = @factory_generator || RGeo::ActiveRecord::RGeoFactorySettings.new\n wkt_parser(factor... | [
"0.71993065",
"0.6746403",
"0.64745647",
"0.6186708",
"0.6157979",
"0.6085415",
"0.60383284",
"0.597152",
"0.59067166",
"0.5870072",
"0.58491415",
"0.5817878",
"0.57695055",
"0.56940246",
"0.5660838",
"0.5649549",
"0.5619508",
"0.55949056",
"0.55864155",
"0.55830747",
"0.5580... | 0.6931328 | 1 |
The +name+ split and joined into a string seperated by "/"'s | def path
name.split("::").join("/").downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_name\n\t\t@full_name.split('')\n\tend",
"def parts\n name.split(\" \")\n end",
"def split_name(name)\n file_name = File.basename(name)\n mres = /^([^\\/\\.]+)\\.(.+)$/i.match(file_name)\n mres.nil? ? [file_name, ''] : [mres[1], mres[2]]\n end",
"def name_join\n... | [
"0.6712902",
"0.6598084",
"0.6593246",
"0.64444995",
"0.6421173",
"0.636001",
"0.63291526",
"0.6315965",
"0.6314213",
"0.6314213",
"0.6212336",
"0.61808264",
"0.61607",
"0.6140464",
"0.61230034",
"0.60938805",
"0.60892445",
"0.60728806",
"0.6072206",
"0.6042162",
"0.59701186"... | 0.5805264 | 35 |
The +path+ plus the current action.html.erb | def full_path
path + "/#{@action}.html.erb"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_path; end",
"def path\n\t\trequest.original_fullpath\n\tend",
"def path\n @global_page.path\n end",
"def view_path\n @@view_path\n end",
"def show\n render @current_template\n end",
"def to_render\n \"#{controller}/#{action}\"\n end",
"def current_action\... | [
"0.68426466",
"0.6774888",
"0.6670076",
"0.6610921",
"0.654586",
"0.6506843",
"0.6495319",
"0.64738184",
"0.64653623",
"0.6461044",
"0.6453939",
"0.6449542",
"0.6425803",
"0.6423476",
"0.6411562",
"0.6411562",
"0.6357818",
"0.6357818",
"0.6351074",
"0.63361335",
"0.63083845",... | 0.80868953 | 0 |
The Controllers class name without the word `controller` in it. | def name
self.class.to_s.gsub(/controller$/i, "")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller_full_name\n controller.class.name.sub('Controller','').gsub('::','_').underscore\n end",
"def controller_name(name)\n @controller_class_name = \"#{name}_controller\".camelize\n end",
"def controller_name\n @controller_name ||= controller.class.to_s.sub('Controller', '').... | [
"0.8138946",
"0.81307435",
"0.8116277",
"0.79861736",
"0.7981022",
"0.79437536",
"0.79402995",
"0.78532916",
"0.78292066",
"0.77975655",
"0.77604365",
"0.77519697",
"0.77496713",
"0.77435577",
"0.7738385",
"0.76681775",
"0.7547195",
"0.7489283",
"0.74226636",
"0.7379831",
"0.... | 0.838742 | 0 |
Setting up the GET request | def get_response_body
uri = URI.parse(@url) #parse the url being passed in with 'URI.parse'
response = Net::HTTP.get_response(uri) # 'GET' the response of the uri with 'Net::HTTP.get_resonse' and pass in the uri variable
response.body #return the 'body' from the 'response' variable
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GET; end",
"def get; end",
"def _get\n http_method(:get)\n end",
"def get\n start { |connection| connection.request http :Get }\n end",
"def get\n\t\t\tself.make_request!({uri: self.to_uri, method: :get})\n\t\tend",
"def get endpoint\n do_request :get, endpoint\n end",
"def ... | [
"0.7655196",
"0.7311063",
"0.72740865",
"0.72560245",
"0.72164136",
"0.71721923",
"0.71032083",
"0.69700783",
"0.6962748",
"0.69190234",
"0.6865394",
"0.68603307",
"0.6852004",
"0.68427813",
"0.6840409",
"0.6840409",
"0.6837059",
"0.682648",
"0.6811289",
"0.6787137",
"0.67394... | 0.0 | -1 |
Call this method if you want the player to learn | def play_to_learn(tateti, opponent)
best_play = nil
value = nil
tateti.empty_cells.each do |possible_play|
current_possible = Tateti.new(tateti.copy_board)
current_possible.play(possible_play[0], possible_play[1], signature)
current_possible_value = get_leaf_value(current_possible, opponent)
if value.nil? || current_possible_value > value
best_play = possible_play
value = current_possible_value
end
end
update_weights(best_play, @eta)
update_matrix
tateti.play(best_play[0], best_play[1], signature)
return tateti
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_a\n $game_system.se_play($data_system.decision_se)\n scene = GamePlay::Skill_Learn.new(@pokemon, @ui.learnable_skills[@index].id)\n scene.main\n if scene.learnt\n @return_data = true\n @running = false\n else\n Graphics.transition\n end\n end",
"de... | [
"0.68083525",
"0.6510004",
"0.64347064",
"0.6417011",
"0.63358337",
"0.63358337",
"0.62427026",
"0.62427026",
"0.62427026",
"0.6215584",
"0.6215584",
"0.6215584",
"0.6215584",
"0.6215584",
"0.6215584",
"0.6215584",
"0.6182033",
"0.6150178",
"0.61481744",
"0.61362034",
"0.6134... | 0.0 | -1 |
Method used to calculate one possible final board and its value only letting players use play method | def get_leaf_value(tateti, opponent)
# Assume its turn of the opponent
loop do
tateti = opponent.play(tateti)
break if !tateti.winner.nil?
break if tateti.tie?
tateti = play(tateti)
break if !tateti.winner.nil?
break if tateti.tie?
end
return game_function(tateti)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def win_block_1_2(player)\n\n\t\tif player == 1\n\t\t\tproduct = 1\n\t\telse\n\t\t\tproduct = 4\n\t\tend\n\n\t\tif self.board[0] == \"0\" && (self.board[1].to_i * self.board[2].to_i == product || self.board[3].to_i * self.board[6].to_i == product || self.board[4].to_i * self.board[8].to_i == product )\n\t\t\tretur... | [
"0.71388805",
"0.6633895",
"0.65473354",
"0.64825106",
"0.6421695",
"0.64081186",
"0.63770586",
"0.6359299",
"0.63577694",
"0.6350082",
"0.6343247",
"0.62910604",
"0.6290867",
"0.62817544",
"0.6257944",
"0.62224907",
"0.6220637",
"0.6218962",
"0.62176746",
"0.62169486",
"0.62... | 0.0 | -1 |
Plays according to what the player have learned | def play(tateti)
best_value = nil
best_play = nil
tateti.empty_cells.each do |possible_play|
row = possible_play[0]
col = possible_play[1]
current_value = @play_matrix[row][col]
if best_value.nil? || current_value > best_value
best_value = current_value
best_play = possible_play
end
end
tateti.play(best_play[0], best_play[1], signature)
return tateti
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n @played = knows_legals? ? random_play : most_likely_play\n end",
"def play\r\n display_welcome_message\r\n init_players\r\n\r\n loop do\r\n play_match\r\n break unless play_again?\r\n end\r\n\r\n display_goodbye_message\r\n end",
"def play\n display_welcome_m... | [
"0.7563246",
"0.74452245",
"0.7326587",
"0.7291661",
"0.7221097",
"0.7176399",
"0.7174837",
"0.71102804",
"0.7089614",
"0.70865387",
"0.7061119",
"0.7058428",
"0.7045526",
"0.7006848",
"0.6998227",
"0.6998227",
"0.6998227",
"0.6998227",
"0.69852924",
"0.6964193",
"0.69231814"... | 0.0 | -1 |
before_action :set_space_type, only: [:show, :edit, :update, :destroy] GET /space_types GET /space_types.json | def index
@space_types = @space_types.order(:name)
respond_to do |format|
format.js
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_space_type\n @space_type = SpaceType.find(params[:id])\n end",
"def set_space_type\n @space_type = SpaceType.find(params[:id])\n end",
"def set_space_type\n @space_type = SpaceType.find(params[:id])\n end",
"def create\n @space_type = SpaceType.new(space_type_params)\n autho... | [
"0.76273173",
"0.7608862",
"0.7608862",
"0.68890697",
"0.67971057",
"0.67481714",
"0.6651089",
"0.6613869",
"0.6268525",
"0.61668247",
"0.6166034",
"0.6166034",
"0.6136154",
"0.60745776",
"0.6074244",
"0.6074244",
"0.6074244",
"0.6074244",
"0.6074244",
"0.6056657",
"0.5950025... | 0.662102 | 7 |
GET /space_types/1 GET /space_types/1.json | def show
respond_to do |format|
format.js
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @space_types = @space_types.order(:name)\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def set_space_type\n @space_type = SpaceType.find(params[:id])\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{... | [
"0.66851836",
"0.64573693",
"0.64471376",
"0.6391785",
"0.6391785",
"0.6383449",
"0.62726235",
"0.61619806",
"0.6093615",
"0.6086681",
"0.6030398",
"0.601878",
"0.59964496",
"0.5983734",
"0.5979993",
"0.5892507",
"0.58694977",
"0.5853532",
"0.5845269",
"0.5833435",
"0.5829441... | 0.0 | -1 |
POST /space_types POST /space_types.json | def create
@space_type = SpaceType.new(space_type_params)
authorize! :create, @space_type
respond_to do |format|
if @space_type.save
format.html { redirect_to @space_type, notice: t('.create_ok') }
format.json { render action: 'show', status: :created, location: @space_type }
else
format.html { render action: 'new' }
format.json { render json: @space_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def space_type_params\n params.require(:space_type).permit(:name)\n end",
"def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end",
"def add_space_type(template, clim, building_type, spc_type)\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"A... | [
"0.69664407",
"0.65157187",
"0.65092963",
"0.63412845",
"0.6136117",
"0.6122288",
"0.6054214",
"0.60184675",
"0.60184675",
"0.59732586",
"0.59732586",
"0.5948731",
"0.5948731",
"0.5903168",
"0.57803077",
"0.57726896",
"0.5736006",
"0.5731621",
"0.5684437",
"0.56249815",
"0.56... | 0.67583036 | 1 |
PATCH/PUT /space_types/1 PATCH/PUT /space_types/1.json | def update
respond_to do |format|
old_name = @space_type.name
if @space_type.update(space_type_params)
@space_type.spaces.each { |s| s.touch }
format.html { redirect_to @space_type, notice: t('.update_ok') }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @space_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end",
"def update\n if @space.update(space_params)\n render json: @space, status: :ok\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end",
"def set_space_type\n @space_type = S... | [
"0.7292051",
"0.6436006",
"0.63852006",
"0.6380993",
"0.63784087",
"0.63784087",
"0.63504165",
"0.63433325",
"0.6327819",
"0.6315074",
"0.62682146",
"0.6256635",
"0.6246546",
"0.6173676",
"0.6141779",
"0.61315477",
"0.6125417",
"0.6122588",
"0.6122341",
"0.6107857",
"0.608935... | 0.786411 | 0 |
DELETE /space_types/1 DELETE /space_types/1.json | def destroy
@space_type.destroy
respond_to do |format|
format.html { redirect_to space_types_url, status: 303 }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7057087",
"0.7019595",
"0.70014274",
"0.69960076",
"0.6978413",
"0.69512826",
"0.69446206",
"0.69306666",
"0.6877801",
"0.6839855",
"0.68057626",
"0.67871445",
"0.6780286",
"0.6777816",
"0.6757962",
"0.6752708",
"0.6752708",
"0.67316777",
"0.6726969",
"0.6723898",
"0.67201... | 0.7996014 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_space_type
@space_type = SpaceType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def space_type_params
params.require(:space_type).permit(
:name, :short_name, :spaces_count, :notes,
equipment_items_attributes: [:id, :qty, :notes, :equipment_model_id, :_destroy] )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Add a file (IO instance) or filename (responding to to_str) to this group. | def add(file_or_filename)
if file_or_filename.respond_to?(:to_io)
add_file file_or_filename.to_io
elsif file_or_filename.respond_to?(:to_str)
add_filename file_or_filename
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file file\n if not File.file? file\n raise ArgumentError\n else\n @files.push file\n puts \"#{File.basename file} added to package #{@name}\" if @verbose\n end\n end",
"def add_file(str)\n\t\t@files.push(str)\n\tend",
"def add_file (file)\n @files[file.path... | [
"0.6983619",
"0.6971453",
"0.68681395",
"0.68613744",
"0.68383956",
"0.67734784",
"0.6758105",
"0.67193085",
"0.6655178",
"0.6460086",
"0.64396197",
"0.6312505",
"0.6234488",
"0.6214845",
"0.61766",
"0.61743474",
"0.61599505",
"0.61571217",
"0.6109019",
"0.6107618",
"0.599853... | 0.7960889 | 0 |
Add the IO instance +file+ to this group. | def add_file(file)
setup_file_tailer file
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file(file)\n @files << file\n end",
"def add_file (file)\n @files[file.path] = file\n end",
"def add_file(file)\n @files[file.name] = file\n file.parent = self\n end",
"def addFile(file)\r\n @files << file\r\n end",
"def add_file (file)\n @files[file.path... | [
"0.76329976",
"0.7561803",
"0.7550584",
"0.7486133",
"0.7466988",
"0.69956297",
"0.68230516",
"0.6543025",
"0.651876",
"0.64229244",
"0.64128184",
"0.6314754",
"0.6299916",
"0.6263896",
"0.62555766",
"0.6254994",
"0.6210089",
"0.62063205",
"0.61620283",
"0.61512566",
"0.61213... | 0.70765704 | 5 |
Add a file created by opening +filename+ to this group after stepping +n+ lines backwards from the end of it. | def add_filename(filename, n = 0)
file = Logfile.open(filename.to_str, :backward => n)
file.backward n
setup_file_tailer file
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(filename)\n raise StandardError, \"That filename is invalid, its too long\" if filename.length > 255\n # Get the next record number\n p n = getNextRecordNumber\n \n filename = File.expand_path(filename)\n filename.gsub!(/^([a-z])/){$1.upcase}\n \n utf8 = filename\n # Are there a... | [
"0.56700957",
"0.55981344",
"0.5490302",
"0.5464723",
"0.53666383",
"0.53162956",
"0.52750343",
"0.52734905",
"0.524358",
"0.5184762",
"0.5158358",
"0.5153315",
"0.5141805",
"0.50886977",
"0.50778514",
"0.50717044",
"0.5047773",
"0.5047773",
"0.5037931",
"0.5035951",
"0.50216... | 0.7640431 | 0 |
Iterate over all files contained in this group yielding to +block+ for each of them. | def each_file(&block)
each_tailer { |t| t.file }.map(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n @files.each(&block)\n end",
"def each(&block)\n\t\t\t\tfiles = []\n\n\t\t\t\t@filenames.each do |filename|\n\t\t\t\t\tf = open_file(filename)\n\t\t\t\t\tf.each do |line|\n\t\t\t\t\t\tline.gsub!(\"\\n\",\"\")\n\n\t\t\t\t\t\t# Ignore these lines since they does not contain a\n\t\t\t\t\t\... | [
"0.80323106",
"0.7818534",
"0.78127897",
"0.7635867",
"0.7465636",
"0.7359753",
"0.72199017",
"0.7203133",
"0.700522",
"0.6931638",
"0.68576515",
"0.68576515",
"0.68499184",
"0.68456817",
"0.6802476",
"0.67830515",
"0.6758182",
"0.6707364",
"0.66735905",
"0.66613203",
"0.6647... | 0.76924634 | 3 |
Iterate over all tailers in this group yielding to +block+ for each of them. | def each_tailer(&block)
@tailers.list.map(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end",
"def tail\n wait_for_activity do |tailer|\n tailer.pending_lines.each do |line|\n line.extend LineExtension\n line.instance_variable_set :@tailer, tailer\n yield line\n ... | [
"0.64705664",
"0.6391662",
"0.63500714",
"0.6252506",
"0.6173574",
"0.6153464",
"0.60445",
"0.5946809",
"0.5942449",
"0.5941352",
"0.59347117",
"0.5928642",
"0.59150916",
"0.5906767",
"0.5898796",
"0.58932215",
"0.5881881",
"0.5853531",
"0.5840768",
"0.58348775",
"0.5825165",... | 0.8152976 | 0 |
Stop all tailers in this group at once. | def stop
each_tailer { |t| t.stop }
each_tailer { |t| t.join }
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_all!\n @devices.each(&:stop!)\n end",
"def stop\r\n logger.info{\"stop_dispatchers #{@group}\"}\r\n return unless @group\r\n @group.list.each {|d| d[:dying] = true}\r\n @group.list.each {|d| d.join }\r\n @dispatch_targets = \"\"\r\n end",
"def stop_all\n @resou... | [
"0.6860611",
"0.6478915",
"0.63873327",
"0.6318151",
"0.627823",
"0.62006503",
"0.61925113",
"0.60933924",
"0.6019008",
"0.6013114",
"0.5999452",
"0.5985321",
"0.59636724",
"0.594251",
"0.59315616",
"0.5917357",
"0.59011674",
"0.59001845",
"0.5892454",
"0.5883986",
"0.5870436... | 0.75995207 | 0 |
Tail all the lines of all the files in the Tail::Group instance, that is yield to each of them. Every line is extended with the LineExtension module, that adds some methods to the line string. To get the path of the file this line was received from call line.file.path. | def tail
wait_for_activity do |tailer|
tailer.pending_lines.each do |line|
line.extend LineExtension
line.instance_variable_set :@tailer, tailer
yield line
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_file(&block)\n each_tailer { |t| t.file }.map(&block)\n end",
"def tail_file\n file_watch = FileWatch::Tail.new\n file_watch.tail( \"#{@path}*\" )\n file_watch.subscribe do |_, line|\n process_line( line )\n end\n end",
"def each_line(*args, &block)\n IO.fo... | [
"0.6510908",
"0.6249164",
"0.564926",
"0.54589766",
"0.54008055",
"0.534556",
"0.53061855",
"0.52799016",
"0.5279679",
"0.5264458",
"0.5158363",
"0.51000345",
"0.5092031",
"0.50782996",
"0.50687075",
"0.50687075",
"0.4975333",
"0.49530557",
"0.4947006",
"0.49245948",
"0.48945... | 0.7038521 | 0 |
Notes that the given variable name is provided either by the CloudFormation environment or by another template. | def defined(name)
@undefined_variables -= [name]
@defined_variables |= [name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refurbish variable_name\n Value.typed @vars[variable_name], variable_name.to_s.sub(/^\\@/, '') #.sub(/^\\$/, '')\n end",
"def variable_name=(variable_name)\n self[:variable_name] = variable_name.downcase.gsub(/[^0-9a-z_ ]/i, \"\").strip.tr(\" \", \"_\")\n end",
"def lookupvar(name)\n p... | [
"0.6594396",
"0.62164074",
"0.61589015",
"0.60820913",
"0.6062689",
"0.60330683",
"0.6022929",
"0.6022929",
"0.5981369",
"0.59636843",
"0.5941758",
"0.58705735",
"0.58321524",
"0.5787757",
"0.5784766",
"0.5781882",
"0.57719296",
"0.575948",
"0.5735199",
"0.56896687",
"0.56554... | 0.0 | -1 |
Notes that the given variable name is used as an input into a template. | def referenced(name)
@undefined_variables |= [name] unless @defined_variables.include?(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refurbish variable_name\n Value.typed @vars[variable_name], variable_name.to_s.sub(/^\\@/, '') #.sub(/^\\$/, '')\n end",
"def template_ivar\n \"@#{template_name.downcase}\".to_sym\n end",
"def variable_name=(variable_name)\n self[:variable_name] = variable_name.downcase.gsub(/[^0-9a-z_... | [
"0.722488",
"0.670614",
"0.6467525",
"0.63224137",
"0.63224137",
"0.6288513",
"0.62228125",
"0.6221403",
"0.6155122",
"0.61331856",
"0.61200035",
"0.610101",
"0.60931987",
"0.60640407",
"0.60640407",
"0.60421026",
"0.60152",
"0.6014361",
"0.5948788",
"0.59264916",
"0.59200835... | 0.0 | -1 |
before_validation :ensure_file_is_accessible pass in columns to plot | def initialize(attributes={})
super
# @attributes={}
#attributes.each { |key, val| (@attributes[key] = val) if respond_to?("#{key}=") }
#
# @attributes.each do |name, value|
# send("#{name}=", value)
# end
run_callbacks :initialize do
@r_values = []
@pr_values = []
@dmax = 0.0
@pr_max = -Float::MAX
@pr_min = Float::MAX
@cols =[0,1]
@filename = @file_blob.filename
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_domain(record,row)\n #SUBPLOT\n #a meno che il numero di subplot sia incluso tra 1 e 12\n unless (1..12).include?(record.subplot)\n #salvo l'errore\n save_error(record,\"Wrong subplot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e s... | [
"0.5602226",
"0.5497967",
"0.5492223",
"0.53162205",
"0.52915907",
"0.5283613",
"0.52708554",
"0.5261385",
"0.5251319",
"0.5243778",
"0.5167704",
"0.51356894",
"0.51299155",
"0.5113238",
"0.5108351",
"0.5106229",
"0.50818",
"0.5064727",
"0.5034494",
"0.50328237",
"0.5017601",... | 0.474144 | 68 |
file should already be validated during upload, no need to double check | def read_contents
#puts "pofr file #{@file_blob.filename}"
file_lines=[]
@file_blob.open do |file|
File.open(file){|x| file_lines = x.readlines}
puts file_lines[0]
puts file_lines.last
end
if @file_blob.filename.extension == "out" # GNOM
getDataLinesFromGnom(file_lines)
elsif @file_blob.filename.extension == "dat" # scatter
puts "reading file @file #{@file_blob.filename}"
getDataLinesFromScatter(file_lines)
end
@dmax = @r_values.last
@pr_values.each do |y|
@pr_max = (y[1] > @pr_max) ? y[1] : @pr_max
@pr_min = (y[1] < @pr_min) ? y[1] : @pr_min
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_file(file)\n end",
"def check_file\n super\n end",
"def validate_file(filename)\n return true\nend",
"def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.a... | [
"0.791152",
"0.72847843",
"0.72402275",
"0.72293377",
"0.72215986",
"0.7182079",
"0.7114536",
"0.7093546",
"0.7028747",
"0.6977053",
"0.6956772",
"0.69545656",
"0.6900014",
"0.6834158",
"0.6834158",
"0.6811859",
"0.68005717",
"0.6799437",
"0.6764987",
"0.6761738",
"0.6738392"... | 0.0 | -1 |
Boolean method that determines if there is a dicount applicable to the line item. Returns true if the line_item can be discounted. Returns false otherwise. | def has_discount?
!discount.nil? && (!discount.product_list? || discount.product_ids.include?(line_item.product_id))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discount_amount\n has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0\n end",
"def is_discounted\n price.to_i < 10\n end",
"def apply_discount\n\n #Check if discount is applicable. Purchases is a hash with the stock item as\n # a key. disc_items is the list of ... | [
"0.63958365",
"0.6342182",
"0.6298566",
"0.62357354",
"0.61703545",
"0.61703545",
"0.61700547",
"0.6165784",
"0.6146745",
"0.6098343",
"0.6045398",
"0.6024317",
"0.6019758",
"0.59431356",
"0.59374064",
"0.59182966",
"0.5910624",
"0.58971137",
"0.58790725",
"0.58580625",
"0.58... | 0.7031669 | 0 |
Returns that amount that is discounted from the line item. Returns 0 if there is no applicable discount. | def discount_amount
has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discounted_total\n line_item.total_in_cents - discount_amount\n end",
"def get_discounted_amount\n\t\tif self.discount.nil?\n\t\t\t0\n\t\telse\n\t\t\tself.amount * self.discount\n\t\tend\n\n end",
"def discount_amount\n all_discounts = line_items.collect { |li| li.discounts }.flatten\n mapping =... | [
"0.8330925",
"0.7665453",
"0.76641643",
"0.76087475",
"0.7547135",
"0.73917145",
"0.73597383",
"0.733183",
"0.73027223",
"0.7204924",
"0.7191906",
"0.7164064",
"0.7102184",
"0.7101042",
"0.7099847",
"0.7091651",
"0.70402247",
"0.70356846",
"0.7035187",
"0.70177925",
"0.693969... | 0.8395994 | 0 |
Returns that total amount that will be charged for the line item taking into account any applicable discount. | def discounted_total
line_item.total_in_cents - discount_amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end",
"def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].su... | [
"0.8150358",
"0.79515874",
"0.79193884",
"0.7789169",
"0.76566005",
"0.76113844",
"0.7552692",
"0.7522501",
"0.7505379",
"0.7482933",
"0.74801713",
"0.7440243",
"0.73556066",
"0.7262891",
"0.7222655",
"0.71931213",
"0.7141181",
"0.7126781",
"0.71064097",
"0.70661384",
"0.7049... | 0.85232097 | 0 |
Part 1: How big is the subgraph containing '0' Essentially generated by a breadth first search | def subgraph_with(vertex)
vertices = Set.new
edges = Set.new
pending = [vertex]
until pending.empty?
this_node = pending.shift
conn_edges, conn_nodes = neighbors(this_node)
conn_nodes.each do |node|
pending << node unless vertices.include?(node)
end
vertices << this_node
edges << conn_edges
end
PipeGraph.new(edges, vertices)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= ... | [
"0.62283415",
"0.61713403",
"0.6133745",
"0.60346776",
"0.6001972",
"0.5975894",
"0.5969828",
"0.5968527",
"0.5917075",
"0.5913511",
"0.5912248",
"0.58996624",
"0.5886517",
"0.58621854",
"0.5861451",
"0.5852817",
"0.5849068",
"0.5843676",
"0.5842256",
"0.5835864",
"0.5831141"... | 0.0 | -1 |
Part 2: How many subgraphs are there? | def subgraphs
subs = []
nodes_to_hit = @vertices.dup
until nodes_to_hit.empty?
subgraph = subgraph_with(nodes_to_hit.to_a.first)
subs << subgraph
nodes_to_hit -= subgraph.vertices
end
subs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n @graphs.inject(0) {|memo, g| memo += g.size}\n end",
"def number_of_edges\n @adj.values.map(&:length).inject(:+)\n end",
"def edges\n edges = 0\n @graph.each_value do |v|\n edges += v.size\n end\n edges\n end",
"def size\n\t\t@graph.size\n\tend",
"def vertex_cou... | [
"0.70592535",
"0.6713531",
"0.66128975",
"0.6481643",
"0.64406306",
"0.6377136",
"0.63748354",
"0.63649714",
"0.6357266",
"0.6291252",
"0.62727916",
"0.6216807",
"0.62087005",
"0.6164723",
"0.6065929",
"0.6047042",
"0.6042155",
"0.6019763",
"0.5987444",
"0.597597",
"0.5944948... | 0.68094414 | 1 |
GET /type_spends GET /type_spends.json | def index
@type_spends = TypeSpend.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end",
"def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end",
"def index\n ... | [
"0.5639627",
"0.5563108",
"0.5484765",
"0.5408027",
"0.53468215",
"0.52912515",
"0.52535987",
"0.52492",
"0.5208997",
"0.5160403",
"0.5160403",
"0.5154902",
"0.514129",
"0.5138585",
"0.510025",
"0.50882685",
"0.5086667",
"0.5084799",
"0.5071767",
"0.50553745",
"0.50340605",
... | 0.64120215 | 0 |
GET /type_spends/1 GET /type_spends/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @type_spends = TypeSpend.all\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def index\n @heart_rate_types = HeartRateType.all\n\n respond_to do |fo... | [
"0.68092483",
"0.5606812",
"0.55895877",
"0.556787",
"0.55632246",
"0.5535312",
"0.5508944",
"0.5415928",
"0.5393468",
"0.5372552",
"0.53638375",
"0.5358073",
"0.53431433",
"0.53099465",
"0.5308323",
"0.5305816",
"0.53039306",
"0.53034866",
"0.529288",
"0.52862304",
"0.526090... | 0.0 | -1 |
POST /type_spends POST /type_spends.json | def create
@type_spend = TypeSpend.new(type_spend_params)
respond_to do |format|
if @type_spend.save
format.html { redirect_to @type_spend, notice: 'Type spend was successfully created.' }
format.json { render :show, status: :created, location: @type_spend }
else
format.html { render :new }
format.json { render json: @type_spend.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @type_spends = TypeSpend.all\n end",
"def create\n @slot_type_options =\n @newsletter.slot_types.try(:map) { |type| [type.name, type.id] }\n .append(['+ Add another type', 'new'])\n\n @slot = @newsletter.slots.build(slot_params)\n\n respond_to do |format|\n if @... | [
"0.5583205",
"0.5558214",
"0.5554737",
"0.5477166",
"0.5410528",
"0.53973454",
"0.53973454",
"0.5330582",
"0.5275746",
"0.5266227",
"0.52426887",
"0.521633",
"0.52086836",
"0.5157111",
"0.5155337",
"0.51474756",
"0.5117887",
"0.51015735",
"0.5082392",
"0.5061917",
"0.50576",
... | 0.54942954 | 3 |
PATCH/PUT /type_spends/1 PATCH/PUT /type_spends/1.json | def update
respond_to do |format|
if @type_spend.update(type_spend_params)
format.html { redirect_to @type_spend, notice: 'Type spend was successfully updated.' }
format.json { render :show, status: :ok, location: @type_spend }
else
format.html { render :edit }
format.json { render json: @type_spend.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @type.update(type_params)\n end",
"def update\n respond_to do |format|\n if @spending.update(spending_params)\n format.html { redirect_to @spending, notice: 'Spending was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render a... | [
"0.615752",
"0.6034026",
"0.59777164",
"0.5964778",
"0.59570384",
"0.59546965",
"0.59451306",
"0.59365535",
"0.593154",
"0.5917625",
"0.59059685",
"0.59027517",
"0.58969545",
"0.5894304",
"0.5889677",
"0.58754635",
"0.5874857",
"0.58543897",
"0.5847064",
"0.5846698",
"0.58403... | 0.59709686 | 3 |
DELETE /type_spends/1 DELETE /type_spends/1.json | def destroy
@type_spend.destroy
respond_to do |format|
format.html { redirect_to type_spends_url, notice: 'Type spend was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @addresstype = Addresstype.find(params[:id])\n @addresstype.destroy\n\n respond_to do |format|\n format.html { redirect_to addresstypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.de... | [
"0.6533858",
"0.6475706",
"0.64441544",
"0.64405197",
"0.6419661",
"0.64052206",
"0.6403103",
"0.638258",
"0.6358583",
"0.63218886",
"0.6317211",
"0.6317211",
"0.63141406",
"0.6300886",
"0.63004285",
"0.6297554",
"0.6288666",
"0.6276399",
"0.62738574",
"0.62507355",
"0.624787... | 0.6822667 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_type_spend
@type_spend = TypeSpend.find(params[:id]) rescue not_found
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def type_spend_params
params.require(:type_spend).permit(:name, :description, :code, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Try the channel first, then roles, then the server | def names_from_context
search = [team_name_from_channel_name] + team_names_from_roles
(search + [bot.config.dig(server.id, 'default_team')]).compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serversForCapRoles(roles)\n find_servers(:roles => roles).collect { |x| x.host }\nend",
"def find_channel(id: nil, name: nil, server_id: nil, server_name: nil)\n server = find_server(id: server_id, name: server_name)\n if server\n find_channel_in_server(id: id, name: name, server: server)\n else\n ... | [
"0.5720341",
"0.56589437",
"0.56453264",
"0.56047165",
"0.55786675",
"0.5382283",
"0.53383464",
"0.52945673",
"0.52794886",
"0.5250711",
"0.5222046",
"0.52152044",
"0.5201001",
"0.5186215",
"0.5174222",
"0.5159841",
"0.514997",
"0.5128987",
"0.5118287",
"0.5100035",
"0.507361... | 0.0 | -1 |
Compiles and caches marc, even if cached marc exists. | def compile_marc
@marc = Sierra::Data::Helpers::SierraMARC.compile_marc(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def caching_compile(action, template)\n if Global.compile && action.template\n Cache.compiled[action.relaxed_hash] ||= compile(action, template)\n else\n compile(action, template)\n end\n end",
"def compile\n @version, @uri = Ruby.find_ruby(@configurat... | [
"0.5613974",
"0.5589122",
"0.5463801",
"0.5337648",
"0.5285645",
"0.5278577",
"0.5270932",
"0.52607185",
"0.52275854",
"0.5197679",
"0.51414925",
"0.5132814",
"0.51307714",
"0.5064622",
"0.5005117",
"0.4975766",
"0.497216",
"0.49615714",
"0.49615714",
"0.49342835",
"0.4930692... | 0.603821 | 0 |
Compiles and caches marc, abnormally. This uses prepared statements which may be quicker than marc / compile_marc's use of associations for leader/control/varfields. However this method does not cache the leader/control/varfield values, it retrieves, so is likely slower if you also will need to retrieve those associations/fields for other reasons. | def quick_marc
@marc = Sierra::Data::Helpers::SierraMARC.compile_marc(
self,
ldr: @leader_field || Sierra::Data::LeaderField.
by_record_id(record_id: id),
cfs: @control_fields || Sierra::Data::ControlField.
by_record_id(record_id: id),
vfs: @varfields || Sierra::Data::Varfield.
by_record_id(record_id: id)
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_marc\n @marc = Sierra::Data::Helpers::SierraMARC.compile_marc(self)\n end",
"def _compile!\n code = @collection.attributes.map do |_,(klass,mapped)|\n %{\n def deserialize_#{ mapped }(value)\n Lotus::Utils::Kernel.#{klass}(value)\n ... | [
"0.5925297",
"0.5203729",
"0.5078971",
"0.5057087",
"0.4984734",
"0.4932112",
"0.48944306",
"0.48818266",
"0.48788586",
"0.48468804",
"0.48451093",
"0.4817521",
"0.4804821",
"0.47933313",
"0.47621754",
"0.4723399",
"0.4713499",
"0.47050372",
"0.4695349",
"0.46773624",
"0.4674... | 0.61666507 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def unit_params
params.require(:unit).permit(:name, :unit, :create_user, :edit_user, :comment)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /clients GET /clients.json | def index
@clients = Client.page(params[:page] || 1).per(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cli... | [
"0.8153739",
"0.80063516",
"0.7787718",
"0.7723655",
"0.7567505",
"0.7567505",
"0.7552252",
"0.74898314",
"0.74426955",
"0.7392605",
"0.73510695",
"0.7308904",
"0.7292815",
"0.7288331",
"0.7288331",
"0.7288331",
"0.7288331",
"0.7288331",
"0.7288331",
"0.7288331",
"0.72777784"... | 0.6951358 | 42 |
GET /clients/1 GET /clients/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def inde... | [
"0.77151686",
"0.7692742",
"0.76121694",
"0.76004916",
"0.75575113",
"0.755476",
"0.752935",
"0.752935",
"0.752935",
"0.752935",
"0.752935",
"0.752935",
"0.752935",
"0.7514162",
"0.74707705",
"0.7333753",
"0.7307614",
"0.7303017",
"0.72995025",
"0.7250661",
"0.7203704",
"0.... | 0.0 | -1 |
POST /clients POST /clients.json | def create
@client = Client.new(client_params)
respond_to do |format|
begin
ActiveRecord::Base.transaction do
@client.save!
@address = Address.new(address_params)
@address.client_id = @client.id
@address.save!
end
format.html { redirect_to @client, notice: 'Client was successfully created.' }
format.json { render :show, status: :created, location: @client }
rescue
format.html { render :new }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_url, notice: 'El cliente se creó correctamente' }\n format.json { render :index, status: :created, location: @client }\n else\n format.html { render... | [
"0.72085994",
"0.71753484",
"0.7120956",
"0.7116921",
"0.710099",
"0.6981326",
"0.6981326",
"0.6981326",
"0.6979284",
"0.6971666",
"0.6971666",
"0.6971666",
"0.6970004",
"0.69603",
"0.6956069",
"0.69386387",
"0.69206727",
"0.691133",
"0.689539",
"0.6878896",
"0.6864519",
"0... | 0.6187541 | 78 |
PATCH/PUT /clients/1 PATCH/PUT /clients/1.json | def update
respond_to do |format|
begin
ActiveRecord::Base.transaction do
@client.update!(client_params)
@client.address.update!(address_params)
end
format.html { redirect_to @client, notice: 'Client was successfully updated.' }
format.json { render :show, status: :ok, location: @client }
rescue
format.html { render :edit }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @client.update(client_params)\n render json: @client\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n ... | [
"0.7246776",
"0.7098947",
"0.7001019",
"0.7001019",
"0.6907153",
"0.6907153",
"0.6898349",
"0.68953735",
"0.68737906",
"0.68383723",
"0.6836901",
"0.6832358",
"0.68251896",
"0.68093616",
"0.6761033",
"0.67596495",
"0.6749836",
"0.6744567",
"0.6742964",
"0.6738345",
"0.6662724... | 0.6326184 | 53 |
DELETE /clients/1 DELETE /clients/1.json | def destroy
respond_to do |format|
begin
ActiveRecord::Base.transaction do
OrderDetail.joins(:order).where(orders: { client_id: @client.id }).destroy_all
Order.where(client_id: @client.id).destroy_all
@client.destroy
end
format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }
format.json { head :no_content }
rescue
format.html { redirect_to clients_url, notice: 'Error. :p' }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n fo... | [
"0.7799133",
"0.7799133",
"0.77840954",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.7773193",
"0.77693796",
"0.7714836",
"0.7636574",
"0.76239145",
"0.75873226",
"0.75829566",
"0.75397116",
"0.75370675",
"0.753706... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_client
@client = Client.preload(:address).find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def client_params
params.require(:client).permit(:name, :password, :password_confirmation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
PATCH/PUT /products/1 PATCH/PUT /products/1.json | def update
@venue = Venue.find(params[:id])
state_id = params[:venue][:state]
town_id = params[:venue][:town]
postal_code_id = params[:venue][:postal_code]
p state_id, town_id, postal_code_id
location_relation = LocationRelation.where(:state_id => state_id, :postal_code_id => postal_code_id, :town_id => town_id).first
respond_to do |format|
if @venue.update(
:name => params[:venue][:name],
:address => params[:venue][:address],
:location_relation_id => location_relation.id,
:room_name => params[:venue][:room_name],
:room_cost => params[:venue][:room_cost],
:room_setup => params[:venue][:room_setup],
:capacity => params[:venue][:capacity],
:screen => params[:venue][:screen],
:whiteboard_available => params[:venue][:whiteboard_available],
:catering => params[:venue][:catering],
:lunch_available => params[:venue][:lunch],
:notes => params[:venue][:notes],
:contact => params[:venue][:contact],
:number => params[:venue][:number]
)
format.html { redirect_to venues_path, notice: 'RTO was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @venue.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @colle... | [
"0.7269931",
"0.6935652",
"0.68690825",
"0.6846676",
"0.68126076",
"0.67678404",
"0.6749974",
"0.6741848",
"0.67151767",
"0.6700884",
"0.6686023",
"0.66597176",
"0.6654553",
"0.66536564",
"0.664067",
"0.664067",
"0.66382414",
"0.6631012",
"0.6631012",
"0.6627257",
"0.6620688"... | 0.0 | -1 |
Check for authorized user | def correct_user
@user ||= (@character ? @character.user : @clutch.user)
redirect_to user_path(current_user), alert: "That does not belong to you!" unless is_current_user?(@user) || is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized?(user)\n true\n end",
"def authorized?\n # TODO(samstern): Check for expired token.\n !(session[:user_id].nil?)\n end",
"def authorized?(user_id)\n logged_in_user_id == user_id\n end",
"def authorized\n\t\tif current_user\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n... | [
"0.8252605",
"0.8167617",
"0.8067663",
"0.7996582",
"0.7945356",
"0.792822",
"0.79031134",
"0.7898001",
"0.78932744",
"0.7837472",
"0.78125626",
"0.77961665",
"0.7788877",
"0.7739458",
"0.7739458",
"0.7705936",
"0.7705874",
"0.77023256",
"0.7685791",
"0.76849866",
"0.7677199"... | 0.0 | -1 |
Checks to see if the actual_spaces after an lbracket equals the value | def measure(actual_spaces, lineno, column)
if actual_spaces != @config
msg = "Line has #{actual_spaces} space(s) after a [, "
msg << "but should have #{@config}."
@problems << Problem.new(problem_type, lineno, column + 1, msg,
@options[:level])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance_space?\n inside_empty_brackets?\n end",
"def inside_blank_pair?\n closing_pair(prev_char(:skip_space => true)) == next_char(:skip_space => true)\n end",
"def position_taken?(fir, sec)\n if (fir[sec] == \" \") || (fir[sec] == \"\") || (fir[sec] == nil)\n return false\n else\n ... | [
"0.6832021",
"0.651518",
"0.6242812",
"0.62184983",
"0.6162069",
"0.6143169",
"0.6126169",
"0.6107561",
"0.61052454",
"0.61001885",
"0.60994846",
"0.6076188",
"0.60572034",
"0.60383356",
"0.5999305",
"0.5988711",
"0.59877175",
"0.59841573",
"0.59668326",
"0.595133",
"0.595133... | 0.0 | -1 |
Counts the number of spaces after the lbracket. | def count_spaces(lexed_line, column)
event_index = lexed_line.event_index(column)
if event_index.nil?
log 'No lbracket in this line. Moving on...'
@do_measurement = false
return
end
next_event = lexed_line.at(event_index + 1)
log "Next event: #{next_event}"
if next_event.nil?
log 'lbracket must be at the end of the line.'
@do_measurement = false
return 0
end
[:on_nl, :on_ignored_nl].each do |event|
if next_event[1] == event
log "lbracket is followed by a '#{event}'. Moving on."
@do_measurement = false
return 0
end
end
if next_event[1] == :on_rbracket
log 'lbracket is followed by a rbracket. Moving on.'
@do_measurement = false
return 0
end
second_next_event = lexed_line.at(event_index + 2)
log "Event + 2: #{second_next_event}"
[:on_comment, :on_lbrace].each do |event|
if second_next_event[1] == event
log "Event + 2 is a #{event}. Moving on."
@do_measurement = false
return next_event.last.size
end
end
next_event[1] != :on_sp ? 0 : next_event.last.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_spaces(lexed_line, column)\n event_index = lexed_line.event_index(column)\n\n if event_index.nil?\n log 'No lbrace in this line. Moving on...'\n @do_measurement = false\n return\n end\n\n next_event = lexed_line.at(event_index + 1)\n\n if nex... | [
"0.70418525",
"0.658439",
"0.6513675",
"0.6488543",
"0.6488543",
"0.6295566",
"0.62891656",
"0.6245838",
"0.6185864",
"0.6178162",
"0.6155",
"0.61413807",
"0.61413807",
"0.6133925",
"0.61050975",
"0.5995918",
"0.5947635",
"0.59331095",
"0.5918501",
"0.58683413",
"0.5821014",
... | 0.70826674 | 0 |
the attricbutes of the tool when first creating it | def initialize(tool_name, time_used)
@tool_name = tool_name #make the given tool name into a instance variable to use in other area
@time = time_used #make the given time used into a instance variable to use in other area
@tool_health = 100
@current_time = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tool_attrs=(tool_attributes={})\n tool_attributes.each_pair do |k,v|\n tool.send(\"#{k}=\", v)\n end\n end",
"def tool_attributes(overrides = {})\n {\n name: \"Pros and Cons\",\n description: \"Weighing up pros and cons can speed up the decision-making process,\n improve y... | [
"0.6415285",
"0.64112633",
"0.5985611",
"0.5779437",
"0.5768114",
"0.57666206",
"0.57365674",
"0.5706035",
"0.570463",
"0.57045114",
"0.5644419",
"0.5628853",
"0.5617216",
"0.55888355",
"0.55859834",
"0.55729324",
"0.5508657",
"0.5502608",
"0.5494366",
"0.5489616",
"0.5489081... | 0.5848172 | 3 |
the damage done and what happen to the tool and item | def damage(item_damaged) #allow the item class to be use through the parameter
until @current_time == @time || item_damaged.item_health == 0 || @tool_health == 0
item_damaged.item_health -= 5
@tool_health -= 10
@current_time += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def item_effect_no_recovery(item)\r\n # If HP recovery rate and recovery amount are 0\r\n if item.recover_hp_rate == 0 and item.recover_hp == 0\r\n # Set damage to empty string\r\n self.damage = ''\r\n # If SP recovery... | [
"0.658866",
"0.658866",
"0.64421237",
"0.6419076",
"0.63061005",
"0.62276524",
"0.62129027",
"0.6201596",
"0.6129299",
"0.61285526",
"0.6115125",
"0.60675794",
"0.60284436",
"0.59782135",
"0.59689283",
"0.59382385",
"0.5932258",
"0.5922257",
"0.58690464",
"0.5833041",
"0.5829... | 0.6205301 | 7 |
when the item is first created, the inputs that the user put is save as instance variables | def initialize(item_name, item_health)
@item_name = item_name
@item_health = item_health
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_required_params_into_new_item_object\n @new_item.plane_id = plane.id\n @new_item.dep_airport_code = departure_airport.code\n @new_item.arr_airport_code = arrival_airport.code\n @new_item.inflight_duration_in_seconds = calculate_inflight_duration\n end",
"def new... | [
"0.6439379",
"0.6347448",
"0.63215697",
"0.62827027",
"0.62627256",
"0.62627256",
"0.62627256",
"0.6214163",
"0.61589295",
"0.61163557",
"0.60723484",
"0.6037059",
"0.6034132",
"0.60244673",
"0.6020945",
"0.6018476",
"0.5970915",
"0.5970213",
"0.5961268",
"0.59607476",
"0.595... | 0.0 | -1 |
checks whether the tool breaks, the item breaks, both breaks, or nothing breaks | def broken(tool_condition) #allow the tool class to be use through the parameter
if @item_health == 0 && tool_condition.tool_health == 0 #when both health reach 0 at the same time
puts "Both #{@item_name} and #{tool_condition.tool_name} break at the same time!"
elsif @item_health <= 0 #when the item's health is 0 or below 0 before the tool's health
puts "The #{@item_name} breaks first!"
elsif tool_condition.tool_health <= 0 #when the tool's health reaches 0 or below 0 before the item's health
puts "Your #{tool_condition.tool_name} breaks first!"
else
puts "Nothing breaks. \nYour #{tool_condition.tool_name}'s health is now #{tool_condition.tool_health}. \nThe #{@item_name}'s health is now #{@item_health}."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def break?\n @break\n end",
"def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cur... | [
"0.5960296",
"0.58975303",
"0.5763711",
"0.55955744",
"0.55845857",
"0.55553985",
"0.55226916",
"0.5513445",
"0.5507034",
"0.5492271",
"0.5450597",
"0.5446428",
"0.5409863",
"0.540484",
"0.5399324",
"0.5399088",
"0.5394322",
"0.5394322",
"0.5394322",
"0.5393399",
"0.53917164"... | 0.6877373 | 0 |
Get city names from the hash | def get_city_names(hash)
hash.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_city_names(hash)\n\thash.each { |k, v| puts k}\nend",
"def get_city_names(somehash)\n somehash.keys\n end",
"def get_city_name(myhash)\n myhash.keys\nend",
"def get_city_names(hash)\n hash.each{ |k, v| puts k}\nend",
"def get_city_names(hashbook)\n hashbook.keys\nend",
"def get_city_name... | [
"0.8179079",
"0.7861688",
"0.7727905",
"0.76723766",
"0.7663262",
"0.7639538",
"0.75658274",
"0.7516943",
"0.7432483",
"0.7432483",
"0.74241716",
"0.7383513",
"0.73674905",
"0.73635846",
"0.7300421",
"0.72706527",
"0.723864",
"0.7204035",
"0.7172686",
"0.71348774",
"0.7053699... | 0.82532233 | 0 |
Get area code based on given hash and key | def get_area_code(hash, key)
hash[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_area_code(hash, k)\n\thash[key]\nend",
"def get_area_code(somehash, key)\n somehash[key]\n end",
"def get_area_code(hash, key)\n hash[key]\nend",
"def get_area_code(somehash, key)\n# Write code here\nsomehash[key]\nend",
"def get_area_code(some_hash, key)\n some_hash[key]\nend",
"def ge... | [
"0.83546644",
"0.8275985",
"0.81900907",
"0.79980356",
"0.7952049",
"0.79248387",
"0.79248387",
"0.79227644",
"0.7880038",
"0.7821541",
"0.77975863",
"0.7790438",
"0.7685832",
"0.75850207",
"0.7423085",
"0.73710346",
"0.735917",
"0.7281254",
"0.7193891",
"0.7108609",
"0.69925... | 0.8265433 | 2 |
render a confirmation page unless the 'confirm' param is 'true' (which should only be set in the submit button on said confirmation page) | def destroy
@user = User.find(params[:id])
case params['commit']
when 'cancel'
redirect_back_or @user
when 'confirm'
logger.info "deleting #{@user}"
logger.info params['reason_for_leaving'] # TODO
@user.destroy
flash.now.warning \
:user_destroyed,
'Bye bye',
"You've successfully deleted your account. We're sorry to see you go!"
redirect_to root_path and return
else
render 'confirm_delete' and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm\n options.fetch(:confirm, nil)\n end",
"def confirm\n\n end",
"def require_confirmation\n if account_signed_in? and !current_account.confirmed?\n redirect_to waiting_pages_path\n end\n end",
"def confirmation_form\n end",
"def confirm\n end",
"def confir... | [
"0.7100115",
"0.7023031",
"0.69155264",
"0.68982965",
"0.68524027",
"0.68524027",
"0.6768341",
"0.6726914",
"0.66671365",
"0.6593077",
"0.6593077",
"0.6593077",
"0.6593077",
"0.6593077",
"0.65924346",
"0.65599346",
"0.6547198",
"0.65462995",
"0.6536393",
"0.65114444",
"0.6506... | 0.0 | -1 |
void cancel() Handle a 'Cancel' button press. | def cancel
redirect_to( default_path ) if params[:commit] == 'cancel'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel\n end",
"def cancel\n end",
"def cancel; end",
"def cancel; end",
"def cancel!; end",
"def cancel\r\n # @todo Emit a warning for attempts to cancel an action after it's been\r\n # executed\r\n @cancelled = true\r\n end",
"def cancel_button_clicked\n\t\t\t@path = nil\n\t... | [
"0.83979553",
"0.83979553",
"0.79665047",
"0.79665047",
"0.78787744",
"0.7859218",
"0.78412783",
"0.7671917",
"0.76702726",
"0.7656187",
"0.76331735",
"0.7604381",
"0.76022077",
"0.7563968",
"0.7503058",
"0.74916416",
"0.7449462",
"0.74391484",
"0.7419796",
"0.7419796",
"0.74... | 0.73756367 | 38 |
value should enter at the root, then go down | def add(value)
@root = add_at_node(@root, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(value)\n puts \"Inserting :\" + value.to_s\n current_node = @root\n\n while nil != current_node\n\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n puts \"val is less\"\n\n ... | [
"0.64694065",
"0.63584346",
"0.632828",
"0.6324421",
"0.6324421",
"0.6314161",
"0.62989813",
"0.6204862",
"0.61975",
"0.6174148",
"0.6157001",
"0.61506456",
"0.60948265",
"0.6080464",
"0.6078495",
"0.60756147",
"0.6074412",
"0.6071448",
"0.6064325",
"0.6064235",
"0.60470855",... | 0.0 | -1 |
add a value to the tree anchored at a node | def add_at_node(node, value)
if node == nil
return Node.new(value)
else
if value <= node.value
node.left_child = add_at_node(node.left_child, value)
else
node.right_child = add_at_node(node.right_child, value)
end
return node
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(value)\n @root = add_at_node(@root, value)\n end",
"def add(node, value)\n tree_navigator.descendents(node).each do |descendent|\n values[descendent] += value\n end\n end",
"def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and... | [
"0.76587677",
"0.7567673",
"0.74158627",
"0.71036375",
"0.7068475",
"0.69247437",
"0.6859794",
"0.6847555",
"0.68399704",
"0.68210447",
"0.682073",
"0.6818211",
"0.67921317",
"0.67771864",
"0.6752892",
"0.67485195",
"0.6742964",
"0.6738661",
"0.6729502",
"0.6729502",
"0.67295... | 0.7449494 | 2 |
Get a list of a list of all nodes at each depth Modified breadthfirst traversal with queues | def get_list_of_lists
# placeholder for all the list of lists we will return
list_of_lists = []
# initialize list and assume root is available
current_list = []
current_list << @root
# look at current level - do we have anything to see?
while !current_list.empty?
# for the next level items, we don't want to touch those yet
list_for_next_level = []
# list of nodes we are able to find at this level
list_at_this_level = []
# now iterate through all the items at this level
while !current_list.empty?
node = current_list.shift
list_at_this_level << node.value
list_for_next_level << node.left_child if node.left_child
list_for_next_level << node.right_child if node.right_child
end
# add the list at this level to the return list
list_of_lists << list_at_this_level
# update current list being seen with the list of the next level
current_list = list_for_next_level
end
return list_of_lists
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child... | [
"0.7893685",
"0.76704955",
"0.7622377",
"0.7541304",
"0.74240565",
"0.7318918",
"0.7299305",
"0.72898924",
"0.71443915",
"0.7019555",
"0.6918057",
"0.6884628",
"0.6732115",
"0.67297536",
"0.66902626",
"0.66781795",
"0.66743857",
"0.6670282",
"0.66371065",
"0.6633641",
"0.6600... | 0.0 | -1 |
= 5 4! 4 3! 3 2! 20! = 20 19 18 ... | def factorial_iterative(n)
result = 1
while n > 1
result *= n # mutation: changing result
n -= 1 # mutation: changing n
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magic_numbers(count)\nend",
"def faculty(n)\n return (1..n).inject(1, :*)\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def cracklepop3\n (1..100).zip(Array.new 100, nil).map do |i,x|\n [i%3, i%5].map.with_index do |y, j| \n x = x.to_s + ['crackle','po... | [
"0.571617",
"0.55380774",
"0.55144596",
"0.53439206",
"0.533198",
"0.5294451",
"0.518323",
"0.5177784",
"0.5175835",
"0.51668876",
"0.5159616",
"0.51539",
"0.51419765",
"0.5128577",
"0.5127559",
"0.5123809",
"0.5103327",
"0.5102613",
"0.5099302",
"0.5098045",
"0.5083513",
"... | 0.0 | -1 |
thanks to bruce williams for this trick | def method_missing(meth, *args, &block) #:nodoc:
returning template.__send__(meth, *args, &block) do
self.class.class_eval %{delegate :#{meth}, :to => :template}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def rassoc(p0) end",
"def probers; end",
"def anchored; end",
"def formation; end",
"def offences_by; end",
"def schubert; end",
"def terpene; end",
"def stderrs; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
... | [
"0.6200665",
"0.5924958",
"0.59247",
"0.5911556",
"0.5719761",
"0.5682469",
"0.5678156",
"0.5676054",
"0.56355536",
"0.551877",
"0.551877",
"0.551877",
"0.551877",
"0.551877",
"0.551877",
"0.54856586",
"0.54856586",
"0.54856586",
"0.54856586",
"0.5473758",
"0.54667515",
"0.... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def image_params
params.require(:image).permit(:article_id, :user_id, :uploaded_image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /items GET /items.json | def index
@items = if params[:cart_id]
Cart.find(params[:cart_id]).items
elsif params[:customer_id]
Customer.find(params[:customer_id]).items
elsif params[:sort]
case params[:sort]
when 'cart_id'
Item.order("cart_id #{params[:cart_sort_direction]}")
when 'product_color_id'
Item.order("product_color_id #{params[:product_color_sort_direction]}")
when 'size_id'
Item.order("size_id #{params[:size_sort_direction]}")
when 'purchased'
Item.order("charges.result #{params[:purchased_sort_direction]}").joins(:charges)
when 'coupon'
Item.order("coupons.name #{params[:coupon_sort_direction]}").joins(:coupons)
end
else
Item
end.order('created_at desc').page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @items }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items =... | [
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.71181... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.