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 |
|---|---|---|---|---|---|---|
Returns an empty string, because this chunk should always be empty. | def content
ChunkyPNG::Datastream.empty_bytearray
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_text\n \"\"\n end",
"def final\n \"\"\n end",
"def final\n \"\"\n end",
"def empty!\n self.replace(\"\")\n end",
"def content\n ''\n end",
"def clear\n ''\n end",
"def noop\n \"\"\n end",
"def empty?\n to... | [
"0.71633136",
"0.6880981",
"0.6793156",
"0.67802614",
"0.6735104",
"0.6601575",
"0.6471702",
"0.6464944",
"0.6405512",
"0.63493043",
"0.63448894",
"0.6324027",
"0.6300541",
"0.6300541",
"0.6300541",
"0.6296618",
"0.6273017",
"0.62568784",
"0.6227967",
"0.62270397",
"0.6212054... | 0.0 | -1 |
Creates the content to write to the stream, by concatenating the keyword with the value, joined by a null character. | def content
[keyword, value].pack('Z*a*')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_tag(tag,value)\n @io << \"<value><#{tag}>#{text(value)}</#{tag}></value>\"\n end",
"def put(text)\n ostream << text\n ostream.flush\n end",
"def text(value)\n attributes[:streams] << { text: value }\n end",
"def placeholder\n s = \"\"\n buffe... | [
"0.6020991",
"0.57742596",
"0.56495965",
"0.56188476",
"0.54598397",
"0.541934",
"0.54093075",
"0.5350565",
"0.5346245",
"0.5327916",
"0.5304636",
"0.5288337",
"0.5221924",
"0.52182883",
"0.51878977",
"0.5112828",
"0.50705177",
"0.50633025",
"0.5058929",
"0.50537354",
"0.5046... | 0.5457247 | 5 |
Creates the content to write to the stream, by concatenating the keyword with the deflated value, joined by a null character. | def content
[keyword, ChunkyPNG::COMPRESSION_DEFAULT, Zlib::Deflate.deflate(value)].pack('Z*Ca*')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def placeholder\n s = \"\"\n buffer << s\n s\n end",
"def write_tag(tag,value)\n @io << \"<value><#{tag}>#{text(value)}</#{tag}></value>\"\n end",
"def write(what)\n @body = \"\" if !@body\n @body += what.to_s if what && what.class\n end",
"def write(text, nulla... | [
"0.5974092",
"0.5621466",
"0.5335463",
"0.5313048",
"0.530541",
"0.5302922",
"0.52708167",
"0.5269492",
"0.52402574",
"0.52182275",
"0.52003795",
"0.5197329",
"0.5185728",
"0.5176349",
"0.5139975",
"0.5128909",
"0.5115096",
"0.5062138",
"0.5033676",
"0.49404284",
"0.49229267"... | 0.0 | -1 |
Always call this function last in the multiple conditional check so that the checkpoint message does not being echoed unnecessarily | def timeup quiet = false, cutoff_time = ENV['RELEASE_TAG'] ? 60.0 : 45.0
unless File.exists?('start_time.log')
system 'touch start_time.log split_time.log' if ENV['CI']
return nil
end
current_time = Time.now
elapsed_time = (current_time - File.atime('start_time.log')) / 60.0
unless quiet
lap_time = (current_time - File.atime('split_time.log')) / 60.0
system 'touch split_time.log'
puts "\n=== elapsed time: #{elapsed_time.to_i} minutes #{((elapsed_time - elapsed_time.to_i) * 60.0).round} seconds, lap time: #{lap_time.to_i} minutes #{((lap_time - lap_time.to_i) * 60.0).round} seconds ===\n\n" unless File.exists?('already_timeup.log'); $stdout.flush
end
return system('touch already_timeup.log') if elapsed_time > cutoff_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkpoint_helper(checkpointer, sequence_number = nil)\n checkpointer.checkpoint(sequence_number)\n rescue Aws::KCLrb::CheckpointError => e\n # Here, we simply retry once.\n # More sophisticated retry logic is recommended.\n checkpointer.checkpoint(sequence_number) if sequence_number\n end",
"d... | [
"0.6073494",
"0.6037517",
"0.5995766",
"0.57341397",
"0.56962556",
"0.56442785",
"0.55990016",
"0.5571417",
"0.55065423",
"0.54880387",
"0.5450922",
"0.5434581",
"0.53777516",
"0.5346586",
"0.53455484",
"0.53273976",
"0.53257525",
"0.53257525",
"0.53256047",
"0.53194064",
"0.... | 0.0 | -1 |
update database with latest Marvel releases | def update_marvel(date)
release_date = date
publisher = Publisher.find_or_create_by_name("Marvel")
while release_date <= date + 4.months do
log("retrieving marvel data for #{release_date.strftime('%Y-%m-%d')}")
doc = Hpricot(open("#{URL_Marvel}/catalog/?date=#{release_date.strftime('%Y-%m-%d')}"))
books = (doc/"a[@class=title_link]")
books = books.each { |book| fetch_title_marvel(publisher, book.innerHTML.strip, "#{URL_Marvel}#{book.attributes['href']}", release_date) }
release_date += 1.week
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @repo.reset_hard\n @repo.pull_rebase\n log << \"Database updated. Now at: #{version}\"\n end",
"def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_... | [
"0.7226418",
"0.68371224",
"0.63962847",
"0.6271625",
"0.6250466",
"0.6135049",
"0.6130336",
"0.61087954",
"0.6043331",
"0.60410076",
"0.59804314",
"0.59804314",
"0.5936887",
"0.5878966",
"0.5860137",
"0.5838325",
"0.58333063",
"0.5807955",
"0.5782101",
"0.5777962",
"0.576222... | 0.57670367 | 20 |
update database with latest DC releases | def update_dc(date)
release_date = date
publisher = Publisher.find_or_create_by_name("DC")
while release_date <= date + 4.months do
log("retrieving dc data for #{release_date.strftime('%Y%m%d')}")
doc = Hpricot(open("#{URL_DC}?dat=#{release_date.strftime('%Y%m%d')}"))
books = doc/"a[@href*='\?cm\=']"
books = books.each { |book| fetch_title_dc(publisher, book.innerHTML.strip, "#{URL_DC}#{book.attributes['href']}") }
release_date += 1.month # dc listings by month
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @repo.reset_hard\n @repo.pull_rebase\n log << \"Database updated. Now at: #{version}\"\n end",
"def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_... | [
"0.6908217",
"0.67002493",
"0.6228074",
"0.60424894",
"0.5885806",
"0.58501494",
"0.5846386",
"0.5713005",
"0.5710732",
"0.56965053",
"0.56934655",
"0.56775665",
"0.5656161",
"0.5651178",
"0.56465024",
"0.56109184",
"0.5606278",
"0.559021",
"0.5578266",
"0.5572297",
"0.550931... | 0.65218115 | 2 |
fetch details and create/update model for a particular DC title | def fetch_title_dc(publisher, title, url, date = nil)
log("retrieving title information for [#{title}]", :debug)
doc = Hpricot(open(url))
# span.display_talent = "Written by, Art by... "
# span.display_copy = "A final confrontation pits..."
# span.display_data = "DC Universe | 32pg. | Color | $2.99 US"
# span.display_copy = "On sale June 6, 2007"
display_talent = ((doc/"#content-col2")/"p:first strong").innerHTML
display_copy = (doc/"#content-col2").innerHTML
display_date = ((doc/"#content-col2")/"p:last").innerHTML
title = RubyPants.new(title, -1).to_html
display_name, display_number = title.split('#')
display_name = check_title(display_name)
display_number = display_number.split(' ')[0] unless display_number.nil?
new_record = false
if display_number.nil?
# SoloBook
model = SoloBook.find_by_name(display_name)
if model.nil?
model = SoloBook.new(:name => display_name,
:publisher => publisher)
new_record = true
end
else
# Episode
series = Series.find_by_name(display_name)
if series.nil?
# Series doesn't exist, create new Series
series = Series.create!(:name => display_name,
:publisher => publisher)
log("created new series [#{display_name}]", :info)
model = series.episodes.build({ :number => display_number })
new_record = true
else
# Add episode to existing series
if series.find_episode(display_number).nil?
model = series.episodes.build({ :number => display_number })
new_record = true
else
model = series.find_episode(display_number)
end
end
end
model.talent = html2text(display_talent)
model.description = html2text(display_copy)
model.published_on = Date.parse(display_date.downcase.sub('on sale', '').gsub(/\s+/, ' ').strip)
model.save!
new_record ? log("created new book [#{title}]", :info) : log("updated existing book [#{title}]", :debug)
if model.cover_image.nil?
# get cover image (if we don't have one already)
image_element = (doc/"img").select { |elem| elem.attributes['src'].match(/media\/product\/.*180x270.jpg/) }
image_url = nil
unless image_element.empty?
image_url = image_element[0].attributes['src']
image_url = "#{URL_DC_Media}#{image_url.gsub(/180x270/,'400x600')}" # full size art
end
get_cover_image(model, image_url)
end
rescue ActiveRecord::RecordInvalid => e
log("failed to create or update book [#{title}]", :info)
log("errors: #{model.errors.full_messages.join(', ')}", :info)
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_title_marvel(publisher, title, url, date = nil) \n log(\"retrieving title information for [#{title}]\", :debug)\n doc = Hpricot(open(url))\n \n display_description = (doc/\"font[@class=plain_text]\").innerHTML\n\n title = RubyPants.new(title, -1).to_html\n display_name,... | [
"0.55922514",
"0.55852306",
"0.55035514",
"0.5496427",
"0.54549944",
"0.5409511",
"0.5382595",
"0.53744924",
"0.5301359",
"0.5301359",
"0.5301359",
"0.5301359",
"0.5301359",
"0.52581793",
"0.52512264",
"0.5244808",
"0.5237615",
"0.52089113",
"0.51761216",
"0.51709807",
"0.508... | 0.6131278 | 0 |
fetch details and create/update model for a particular DC title | def fetch_title_marvel(publisher, title, url, date = nil)
log("retrieving title information for [#{title}]", :debug)
doc = Hpricot(open(url))
display_description = (doc/"font[@class=plain_text]").innerHTML
title = RubyPants.new(title, -1).to_html
display_name, display_number = title.split('#')
display_name = check_title(display_name)
display_number = display_number.split(' ')[0] unless display_number.nil?
new_record = false
if display_number.nil?
# SoloBook
model = SoloBook.find_by_name(display_name)
if model.nil?
model = SoloBook.new(:name => display_name,
:publisher => publisher)
new_record = true
end
else
# Episode
series = Series.find_by_name(display_name)
if series.nil?
# Series doesn't exist, create new Series
series = Series.create!(:name => display_name,
:publisher => publisher)
log("created new series [#{display_name}]", :info)
model = series.episodes.build({ :number => display_number })
new_record = true
else
# Add episode to existing series
if series.find_episode(display_number).nil?
model = series.episodes.build({ :number => display_number })
new_record = true
else
model = series.find_episode(display_number)
end
end
end
display_talent, display_description = display_description.split("<strong>THE STORY:</strong>")
display_description ||= "" # if description was empty make sure it's non-nil
display_description = display_description.split("<strong>PRICE:</strong>")[0]
model.talent = html2text(display_talent).strip.titleize
model.description = html2text(display_description).strip
model.published_on = date
model.save!
new_record ? log("created new book [#{title}]", :info) : log("updated existing book [#{title}]", :debug)
if model.cover_image.nil?
# get cover image (if we don't have one already)
image_element = (doc/"img").select { |elem| elem.attributes['src'].match(/thumb/) }
image_url = nil
unless image_element.empty?
image_url = image_element[0].attributes['src']
image_url = "#{URL_Marvel}#{image_element[0].attributes['src'].gsub('_thumb', '_full')}" # full size art
end
get_cover_image(model, image_url)
end
rescue ActiveRecord::RecordInvalid => e
log("failed to create book [#{title}]", :info)
log("errors: #{model.errors.full_messages.join(', ')}", :info)
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_title_dc(publisher, title, url, date = nil)\n log(\"retrieving title information for [#{title}]\", :debug)\n doc = Hpricot(open(url))\n \n # span.display_talent = \"Written by, Art by... \"\n # span.display_copy = \"A final confrontation pits...\"\n # span.display_data = \"D... | [
"0.6131278",
"0.55852306",
"0.55035514",
"0.5496427",
"0.54549944",
"0.5409511",
"0.5382595",
"0.53744924",
"0.5301359",
"0.5301359",
"0.5301359",
"0.5301359",
"0.5301359",
"0.52581793",
"0.52512264",
"0.5244808",
"0.5237615",
"0.52089113",
"0.51761216",
"0.51709807",
"0.5087... | 0.55922514 | 1 |
update cover image for a specified model | def get_cover_image(book, url)
if not url.nil?
name = book.name || "#{book.series.name} \##{book.number}"
log("attempting to retrieve cover art [#{url}]", :debug)
cover_image = book.build_cover_image(:uploaded_data => UrlUpload.new(url))
if cover_image.save
log("successfully added cover art [#{name}]", :debug)
else
log("unable to add cover art [#{name}]", :debug)
end
else
log("invalid URL for cover art [#{name}]", :debug)
end
rescue OpenURI::HTTPError
log("cover art not found [#{name}]", :debug)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\r\n @album = Album.find(params[:id])\r\n if params[:album][:coverpage]\r\n tem_coverPage = upload_file(params[:album][:coverpage],\"app/assets/images/album_images\")\r\n params[:album][:coverpage] = \"album_images/\"+tem_coverPage\r\n end\r\n\r\n respond_to do |format|\r\n\r\n ... | [
"0.6791484",
"0.6707012",
"0.67048645",
"0.6671547",
"0.656356",
"0.65613914",
"0.6477551",
"0.64714533",
"0.644548",
"0.63592976",
"0.634392",
"0.634392",
"0.634392",
"0.6308377",
"0.6270875",
"0.62613964",
"0.626087",
"0.61981976",
"0.6153218",
"0.61379963",
"0.61192554",
... | 0.0 | -1 |
replace name with the converted value in TITLE_CONVERSION_LIST if it's been flagged for modification (due to an improper solicitation, etc) | def check_title(name)
# titleize without the botched 'S (apostrophe-s) issue
name = name.humanize.strip.squeeze(' ').gsub(/\b([a-z])/) { $1.capitalize }.gsub(/\'S/, '\'s')
match = TITLE_CONVERSION_LIST.keys.select { |t| name.match(/#{Regexp.escape(t)}/i) }
unless match.empty?
match = match.sort.reverse[0] # select the longest match (most accurate)
name = TITLE_CONVERSION_LIST[match]
end
log("checked display name is [#{name}]", :debug)
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def titleize_proper_names\n self.author = self.author.titleize\n self.editor = self.editor.titleize if self.editor\n self.buyed_from = self.buyed_from.titleize if self.buyed_from\n end",
"def parameterize_title_for_name\n self.name = title.parameterize if title\n end",
"def titleize\n dup.tap(... | [
"0.64437896",
"0.59596187",
"0.59278756",
"0.58932835",
"0.58932835",
"0.5821976",
"0.5809699",
"0.5759938",
"0.5744363",
"0.572556",
"0.5718931",
"0.5718462",
"0.57045025",
"0.56232184",
"0.5615835",
"0.5611629",
"0.55944186",
"0.55754536",
"0.5556236",
"0.5552546",
"0.55311... | 0.5975166 | 1 |
convert issue description data from html to text TODO: this method is a mess. clean it up. | def html2text(html)
html ||= "" # ensure string is non-nil
text = html.
gsub(/( |\n|\s)+/im, ' ').squeeze(' ').strip.
gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i, '\4')
linkregex = /<[^>]*(src|href)=\s*(.?)([^>\s]*)\2[^>]*>\s*/i
while linkregex.match(text)
text.sub!(linkregex, "")
end
text = CGI.unescapeHTML(
text.
gsub(/<(script|style)[^>]*>.*<\/\1>/im, '').
gsub(/<!--.*-->/m, '').
gsub(/<hr(| [^>]*)>/i, "___\n").
gsub(/<li(| [^>]*)>/i, "\n* ").
gsub(/<blockquote(| [^>]*)>/i, '> ').
gsub(/<(br)(| [^>]*)>/i, "\n").
gsub(/<(\/h[\d]+|p)(| [^>]*)>/i, "\n\n").
gsub(/<[^>]*>/, '')
).lstrip.gsub(/\n[ ]+/, "\n") + "\n"
converted = []
text.split(//).collect { |c| converted << ( c[0] > 127 ? "&##{c[0]};" : c ) }
converted.join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description_html\n convert_html description\n end",
"def description_text\n\t\t\tif @data[\"description\"] \n\t\t\t\thtml_data = @data[\"description\"][\"text\"] \n\t\t\t\tparsed_data = Nokogiri::HTML(html_data)\n\t\t\t\tparsed_data.text\n\t\t\tend\n\t\tend",
"def prepare_description(description)\n ... | [
"0.7353803",
"0.68599296",
"0.68399286",
"0.65262973",
"0.6502272",
"0.6481965",
"0.6481965",
"0.64485556",
"0.64310735",
"0.6406984",
"0.6406984",
"0.63582337",
"0.6242538",
"0.6217766",
"0.6200403",
"0.6194629",
"0.6194629",
"0.61676276",
"0.6107801",
"0.6098693",
"0.607708... | 0.5788015 | 51 |
log to standard logger facility and dump to stdout too | def log(msg, level = :info)
puts("ZapUpdater: " + msg)
RAILS_DEFAULT_LOGGER.info("ZapUpdater: " + msg)
@mail_log << msg + "<br/>\r\n" if level == :info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_to_stdout\n log_to STDOUT\n end",
"def log\n @@log ||= Logger.new($stdout)\n end",
"def log_write(msg)\n puts msg\n end",
"def log(message)\n STDOUT.puts message\nend",
"def log\n @log ||= Logger.new($stdout)\n end",
"def log(*args)\n @out.puts(*args)\n end... | [
"0.7931657",
"0.692836",
"0.69221705",
"0.69119364",
"0.68880635",
"0.6869514",
"0.6722475",
"0.66870356",
"0.6676261",
"0.6675951",
"0.6673436",
"0.66717297",
"0.66601485",
"0.6658912",
"0.6641645",
"0.6641645",
"0.6602516",
"0.65761954",
"0.65761495",
"0.65702075",
"0.65270... | 0.0 | -1 |
Log metadata about this ruleset to the currently running deployment | def notify
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n print_debug 'In #run'\n audit self.class.payloads, self.class.options\n end",
"def record_to_statsd\n # Only record production deployments in production graphite\n if self.environment == \"production\"\n key = \"deploys.#{self.application.shortname}\"\n STATSD.i... | [
"0.54689825",
"0.535538",
"0.53269994",
"0.5161476",
"0.51572037",
"0.5146851",
"0.5136871",
"0.51100266",
"0.5036239",
"0.5034545",
"0.50262606",
"0.5020156",
"0.49960792",
"0.4988747",
"0.49785566",
"0.4966656",
"0.49507624",
"0.4945704",
"0.49307033",
"0.4916723",
"0.49162... | 0.0 | -1 |
Insert a rule into an existing security group. | def addRule(hosts,
proto: "tcp",
port: nil,
egress: false,
port_range: "0-65535"
)
rule = Hash.new
rule["proto"] = proto
if hosts.is_a?(String)
rule["hosts"] = [hosts]
else
rule["hosts"] = hosts
end
if port != nil
port = port.to_s if !port.is_a?(String)
rule["port"] = port
else
rule["port_range"] = port_range
end
ec2_rule = convertToEc2([rule])
begin
if egress
MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_egress(
group_id: @cloud_id,
ip_permissions: ec2_rule
)
else
MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_ingress(
group_id: @cloud_id,
ip_permissions: ec2_rule
)
end
rescue Aws::EC2::Errors::InvalidPermissionDuplicate => e
MU.log "Attempt to add duplicate rule to #{@cloud_id}", MU::DEBUG, details: ec2_rule
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_group(group, rule)\n return false unless rule.is_a?(Rule)\n @groups ||= {}\n (@groups[group] ||= []) << rule\n end",
"def add_rule(key, rule = nil, &block)\n key = key.to_sym\n if rules[key].nil?\n rule ||= Rule.new(key, &block)\n rules[key] = rule\n else\n ... | [
"0.6768331",
"0.66592056",
"0.6553603",
"0.64926904",
"0.6476545",
"0.64582264",
"0.6352097",
"0.6234922",
"0.6197109",
"0.61785495",
"0.6114273",
"0.6113903",
"0.59489554",
"0.59410363",
"0.59260315",
"0.5871608",
"0.58088213",
"0.5715657",
"0.56822675",
"0.5634673",
"0.5618... | 0.5647617 | 19 |
Manufacture an EC2 security group. The second parameter, rules, is an "ingress_rules" structure parsed and validated by MU::Config. | def setRules(rules, add_to_self: false, ingress: true, egress: false)
return if rules.nil? or rules.size == 0
if add_to_self
rules.each { |rule|
if rule['sgs'].nil?
new_rule = rule.clone
new_rule.delete('hosts')
rule['sgs'] = Array.new if rule['sgs'].nil?
rule['sgs'] << { "Ref" => @cfm_name }
end
}
end
ec2_rules = convertToEc2(rules)
# Creating an empty security group is ok, so don't freak out if we get
# a null rule list.
if !ec2_rules.nil?
ec2_rules.each { |rule|
next if rule.nil? or rule[:ip_ranges].nil? # XXX whaaat
rule[:ip_ranges].each { |cidr|
MU::Cloud::CloudFormation.setCloudFormationProp(
@cfm_template[@cfm_name],
"SecurityGroupIngress",
{
"IpProtocol" => rule[:ip_protocol],
"FromPort" => rule[:from_port],
"ToPort" => rule[:to_port],
"CidrIp" => cidr[:cidr_ip]
}
)
}
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertToEc2(rules)\n ec2_rules = []\n if rules != nil\n rules.each { |rule|\n ec2_rule = Hash.new\n rule['proto'] = \"tcp\" if rule['proto'].nil? or rule['proto'].empty?\n ec2_rule[:ip_protocol] = rule['proto']\n\n p_start = nil\... | [
"0.7184339",
"0.61924857",
"0.58716196",
"0.5747694",
"0.55351424",
"0.5526258",
"0.5476864",
"0.5455429",
"0.5451784",
"0.5440346",
"0.5416581",
"0.5384735",
"0.52951914",
"0.51761967",
"0.5116565",
"0.51091504",
"0.5106706",
"0.5069618",
"0.50331575",
"0.5004386",
"0.499176... | 0.6506932 | 1 |
Convert our config languages description of firewall rules into Amazon's. This rule structure is as defined in MU::Config. | def convertToEc2(rules)
ec2_rules = []
if rules != nil
rules.each { |rule|
ec2_rule = Hash.new
rule['proto'] = "tcp" if rule['proto'].nil? or rule['proto'].empty?
ec2_rule[:ip_protocol] = rule['proto']
p_start = nil
p_end = nil
if rule['port_range']
p_start, p_end = rule['port_range'].split(/\s*-\s*/)
elsif rule['port']
p_start = rule['port']
p_end = rule['port']
elsif rule['proto'] != "icmp"
raise MuError, "Can't create a TCP or UDP security group rule without specifying ports: #{rule}"
end
if rule['proto'] != "icmp"
if p_start.nil? or p_end.nil?
raise MuError, "Got nil ports out of rule #{rule}"
end
ec2_rule[:from_port] = p_start.to_i
ec2_rule[:to_port] = p_end.to_i
else
ec2_rule[:from_port] = -1
ec2_rule[:to_port] = -1
end
if (!defined? rule['hosts'] or !rule['hosts'].is_a?(Array)) and
(!defined? rule['sgs'] or !rule['sgs'].is_a?(Array)) and
(!defined? rule['lbs'] or !rule['lbs'].is_a?(Array))
raise MuError, "One of 'hosts', 'sgs', or 'lbs' in rules provided to createEc2SG must be an array."
end
ec2_rule[:ip_ranges] = []
ec2_rule[:user_id_group_pairs] = []
if !rule['hosts'].nil?
rule['hosts'].each { |cidr|
next if cidr.nil? # XXX where is that coming from?
cidr = cidr + "/32" if cidr.match(/^\d+\.\d+\.\d+\.\d+$/)
ec2_rule[:ip_ranges] << {cidr_ip: cidr}
}
end
if !rule['lbs'].nil?
# XXX This is a dopey place for this, dependencies() should be doing our legwork
rule['lbs'].each { |lb_name|
if @dependencies.has_key?("loadbalancer") and @dependencies["loadbalancer"].has_key?(lb_name)
# MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "DependsOn", @dependencies["loadbalancer"][lb_name].cloudobj.cfm_name)
end
}
end
if !rule['sgs'].nil?
rule['sgs'].each { |sg_name|
# XXX This is a dopey place for this, dependencies() should be doing our legwork
if @dependencies.has_key?("firewall_rule") and @dependencies["firewall_rule"].has_key?(sg_name)
# MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "DependsOn", @dependencies["firewall_rule"][sg_name].cloudobj.cfm_name)
end
}
end
if !ec2_rule[:user_id_group_pairs].nil? and
ec2_rule[:user_id_group_pairs].size > 0 and
!ec2_rule[:ip_ranges].nil? and
ec2_rule[:ip_ranges].size > 0
MU.log "Cannot specify ip_ranges and user_id_group_pairs", MU::ERR
raise MuError, "Cannot specify ip_ranges and user_id_group_pairs"
end
ec2_rule.delete(:ip_ranges) if ec2_rule[:ip_ranges].size == 0
ec2_rule.delete(:user_id_group_pairs) if ec2_rule[:user_id_group_pairs].size == 0
if !ec2_rule[:user_id_group_pairs].nil? and
ec2_rule[:user_id_group_pairs].size > 0
ec2_rule.delete(:ip_ranges)
elsif !ec2_rule[:ip_ranges].nil? and
ec2_rule[:ip_ranges].size > 0
ec2_rule.delete(:user_id_group_pairs)
end
ec2_rules << ec2_rule
}
end
return ec2_rules
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatRules config\n\tresult = \"\"\n\t\n\t# rule set filename is not indicated from the name of the rule set, so a mapping is used\n\trulesetFiles = {\"Android\" => \"android\",\"Basic\" => \"basic\",\"Braces\" => \"braces\",\"Clone Implementation\" => \"clone\",\"Code Size\" => \"codesize\",\"Comments\" => \... | [
"0.61242247",
"0.57955056",
"0.579042",
"0.57717",
"0.55693173",
"0.5555996",
"0.55405885",
"0.5540385",
"0.55349433",
"0.5494803",
"0.54843014",
"0.54843014",
"0.5432833",
"0.539634",
"0.5370612",
"0.53447706",
"0.53441375",
"0.5321945",
"0.5312328",
"0.5306548",
"0.52898777... | 0.5943718 | 1 |
=begin :type prefix: String :type suffix: String :rtype: Integer =end | def f(prefix, suffix)
@hash[prefix].nil? || @hash[prefix][suffix].nil? ? -1 : @hash[prefix][suffix]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_part_with_prefix(prefix, suffix)\n num = @parts.select { |n, _| n.start_with?(prefix) && n.end_with?(suffix) }\n .map { |n, _| n[prefix.length..-1][0..-(suffix.size + 1)].to_i }\n .max\n num = (num || 0) + 1\n \"#{prefix}#{num}#{suffix}\"\n end... | [
"0.7463263",
"0.6559145",
"0.64508134",
"0.60494727",
"0.60494727",
"0.60494727",
"0.60494727",
"0.60494727",
"0.59450126",
"0.5874299",
"0.58166337",
"0.5691618",
"0.5691618",
"0.56827635",
"0.5674452",
"0.5581028",
"0.5558828",
"0.5558499",
"0.5558499",
"0.5558499",
"0.5558... | 0.6696163 | 1 |
context block to dry up code describe 'post page' do context 'when user is an admin' do before(:each) do | def login(email, password)
visit '/users/sign_in'
fill_in 'Email', :with => email
fill_in 'Password', :with => password
click_button 'Log in'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_02_comment_on_post_as_guest\n end",
"def login_admin\n let(:current_user) { create(:user, admin: true) }\n\n before(:each) { sign_in current_user }\n end",
"def feature_login_admin\n before(:each) do\n admin = create(:attached_admin)\n\n visit admin_root_path\n ... | [
"0.6524277",
"0.62141687",
"0.6136024",
"0.60426456",
"0.59583485",
"0.5937462",
"0.59214634",
"0.5907417",
"0.58659613",
"0.58245283",
"0.58046734",
"0.57997787",
"0.5797049",
"0.5794898",
"0.57789236",
"0.57289034",
"0.57219946",
"0.57177067",
"0.5706512",
"0.5696779",
"0.5... | 0.0 | -1 |
return the chef config files dir or fail hard | def chef_config_path
if Chef::Config['config_file']
::File.dirname(Chef::Config['config_file'])
else
raise("No chef config file defined. Are you running \
chef-solo? If so you will need to define a path for the ohai_plugin as the \
path cannot be determined")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_directory\n \"C:\\\\chef\"\n end",
"def find_config_path\n path = Pathname(Pathname.pwd).ascend{|d| h=d+config_filename; break h if h.file?}\n end",
"def cfg_dir\n File.join(@full_path, CONFIG_DIR)\n end",
"def chef_config_path\n Berkshelf.root.join(\"spec/config... | [
"0.78017294",
"0.7541503",
"0.7502662",
"0.7380222",
"0.7167201",
"0.71493816",
"0.7068944",
"0.70639604",
"0.7021905",
"0.7008876",
"0.7008876",
"0.7001938",
"0.69809324",
"0.6899863",
"0.6894657",
"0.6793473",
"0.6776487",
"0.67223704",
"0.67008024",
"0.66179454",
"0.660591... | 0.77907807 | 1 |
is the desired plugin dir in the ohai config plugin dir array? | def in_plugin_path?(path)
# get the directory where we plan to stick the plugin (not the actual file path)
desired_dir = ::File.directory?(path) ? path : ::File.dirname(path)
case node['platform']
when 'windows'
::Ohai::Config.ohai['plugin_path'].map(&:downcase).include?(desired_dir.downcase)
else
::Ohai::Config.ohai['plugin_path'].include?(desired_dir)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe_plugin_dir(path:)\n path and plugin_dir path: path or self\n end",
"def plugin_directory; end",
"def plugins_directory\n @@plugins_directory ||= './plugins'\n end",
"def plugins_path; end",
"def current_plugin?\n if Origen.application_loaded?\n Origen.app.plugins.curre... | [
"0.75336653",
"0.7378803",
"0.7114235",
"0.70886266",
"0.70205355",
"0.69956034",
"0.6961204",
"0.6949756",
"0.68870604",
"0.68290204",
"0.6709665",
"0.6660084",
"0.6555435",
"0.6493822",
"0.6465093",
"0.64543086",
"0.64234895",
"0.634609",
"0.63372",
"0.6327181",
"0.6302366"... | 0.820934 | 0 |
we need to warn the user that unless the path for this plugin is in Ohai's plugin path already we're going to have to reload Ohai on every Chef run. Ideally in future versions of Ohai /etc/chef/ohai/plugins is in the path. | def plugin_path_warning
Chef::Log.warn("The Ohai plugin_path does not include #{desired_plugin_path}. \
Ohai will reload on each chef-client run in order to add this directory to the \
path unless you modify your client.rb configuration to add this directory to \
plugin_path. The plugin_path can be set via the chef-client::config recipe. \
See 'Ohai Settings' at https://docs.chef.io/config_rb_client.html#ohai-settings \
for more details.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ohai_plugin_path\n \"/etc/chef/ohai_plugins\"\n end",
"def setup_ohai\n Ohai::Config[:plugin_path] << ohai_plugin_path\n @ohai = Ohai::System.new\n @ohai.all_plugins\n end",
"def compile_ohai_plugins\n return super unless $CHEFSPEC_MODE\n return if $CHEFSPEC_PRELOAD\n\n s... | [
"0.7636913",
"0.66288525",
"0.6389356",
"0.63807756",
"0.6358395",
"0.6192538",
"0.58402437",
"0.58359164",
"0.56772554",
"0.56727105",
"0.56377244",
"0.55836606",
"0.5564606",
"0.55620384",
"0.5516394",
"0.5486679",
"0.5484506",
"0.5479545",
"0.5479366",
"0.54792345",
"0.546... | 0.8726781 | 0 |
this resource forces itself to run at compile_time | def after_created
return unless compile_time
Array(action).each do |action|
run_action(action)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main\n super\n return self\n end",
"def exec\n super\n end",
"def compile!\n raise NotImplementedError\n end",
"def regenerator; end",
"def run; new.run; end",
"def run\n super\n end",
"def run\n super\n end",
"def compile\n end",
"def onCompile\n end",
... | [
"0.61323965",
"0.60312074",
"0.6000105",
"0.59993094",
"0.5967604",
"0.59609103",
"0.59609103",
"0.5853844",
"0.585312",
"0.5841339",
"0.5832365",
"0.58277166",
"0.5800191",
"0.5800191",
"0.5799184",
"0.5799184",
"0.57721496",
"0.57673275",
"0.57605636",
"0.57605636",
"0.5734... | 0.0 | -1 |
we need a method that replicates Array.sort method builtin to Ruby we will need recursion as we go thru each word pair in the unsorted Array we will need recursion again as we compare each new word that is being sorted to the words already stored in the sorted Array | def sort some_array # This "wraps" rec_sort so you don't have to pass rec_sort an empty array each iteration
rec_sort some_array, []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort array\n\tcount = -2\n\t\t# count number of words in first list\n\t\tarray.each do |word|\n\t\tcount = count + 1\n\t\tend\n\trecursive_sort(array, [ ], [ ], count)\nend",
"def sort array\n\tcount = -2\n\t\t# count number of words in first list\n\t\tarray.each do |word|\n\t\tcount = count + 1\n\tend\n\tre... | [
"0.82708365",
"0.8268202",
"0.81447226",
"0.7787669",
"0.7706872",
"0.76213",
"0.754766",
"0.7499072",
"0.74946284",
"0.7299443",
"0.72955865",
"0.72787476",
"0.7270108",
"0.72666633",
"0.72200227",
"0.7216597",
"0.7205846",
"0.71453196",
"0.71306723",
"0.7121634",
"0.7065897... | 0.0 | -1 |
Add a frame to the message (positioning it at the end of message). Any ZMQ::Message automatically gets copied out to a ruby string (user still responsible for original ZMQ::Message), strings are added directly. | def add(frame)
msg_frame = convert_frame(frame)
return nil if msg_frame.nil?
@msg_frames << msg_frame
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames.unshift(msg_frame)\n self\n end",
"def push(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames.unshift(msg_frame)\n self\n end",
"def... | [
"0.70751184",
"0.70751184",
"0.64102805",
"0.6161355",
"0.60879815",
"0.59986806",
"0.59584296",
"0.58947015",
"0.58887535",
"0.5644586",
"0.558231",
"0.55789757",
"0.5523461",
"0.5521585",
"0.5515992",
"0.55045575",
"0.5493586",
"0.5429489",
"0.5426171",
"0.5420571",
"0.5411... | 0.7219567 | 1 |
Add a frame to the front of the message. Frame can be either a string or a ZMQ::Message. The method copies out any string given in a ZMQ::Message (and the user is still in charge of properly closing such a message). | def push(frame)
msg_frame = convert_frame(frame)
return nil if msg_frame.nil?
@msg_frames.unshift(msg_frame)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames << msg_frame\n self\n end",
"def add(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames << msg_frame\n self\n end",
"def push(obj)\n ... | [
"0.6618648",
"0.6618648",
"0.59120953",
"0.5898879",
"0.58269763",
"0.57802206",
"0.5601004",
"0.54635406",
"0.5391144",
"0.53286916",
"0.5303479",
"0.5247716",
"0.5223775",
"0.5216274",
"0.51866853",
"0.512249",
"0.51193976",
"0.5116066",
"0.5103631",
"0.50944704",
"0.506547... | 0.72565156 | 1 |
Remove the address from the front of a message. Takes care of also removing any empty frame. | def unwrap
frame = pop
if @msg_frames.first.size == 0
pop
end
frame
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_pre_address(address)\n address = address.sub(/^\\s*mail\\:\\s*/i, '')\n address.gsub(/.*\\,\\s+(\\d+\\b\\s+\\w)/i, '\\1')\n end",
"def remove_message(name)\n\t\tend",
"def remove_prefix(msg)\n msg.sub(PREFIX_REGEX, \"|\")\n end",
"def remove_original_address(opts)\n opt... | [
"0.62554634",
"0.5772375",
"0.5660778",
"0.55819464",
"0.552734",
"0.55093575",
"0.54551965",
"0.5402385",
"0.53923184",
"0.5281751",
"0.5267525",
"0.52554804",
"0.52297485",
"0.5227724",
"0.521531",
"0.52020454",
"0.52020454",
"0.5200364",
"0.5199173",
"0.5191443",
"0.518918... | 0.5131577 | 23 |
Create a duplicate of the message. | def duplicate
dup_frames = @msg_frames.map {|frame| frame.dup}
ZMQ::StringMultipartMessage.new(dup_frames)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_duplicate_message(message, clone)\n if message.request?\n if message.from_user_info == @from && message.to_user_info == @to\n if clone.outgoing? && message.incoming?\n clone.duplicate = true\n else\n ... | [
"0.7034578",
"0.6996422",
"0.6937953",
"0.67715174",
"0.6319098",
"0.6307666",
"0.6281456",
"0.6262816",
"0.62531364",
"0.6162757",
"0.61578",
"0.61570317",
"0.61515903",
"0.61447096",
"0.6094837",
"0.60811496",
"0.6079748",
"0.6079748",
"0.6045895",
"0.6016814",
"0.59561193"... | 0.71045434 | 0 |
GET /positions/1 GET /positions/1.json | def show
@position = Position.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @position }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @positions = Position.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @positions }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @position }\n end\n end",
... | [
"0.7592656",
"0.7122526",
"0.68040425",
"0.67908335",
"0.67804617",
"0.67543066",
"0.67370677",
"0.67292786",
"0.6698444",
"0.66883117",
"0.661597",
"0.6583506",
"0.6575291",
"0.65597713",
"0.6540365",
"0.64919364",
"0.6491296",
"0.64289105",
"0.63477904",
"0.63469964",
"0.63... | 0.7194168 | 4 |
Decrypts a block of data (encrypted_data) given an encryption key and an initialization vector (iv). Keys, iv's, and the data returned are all binary strings. Cipher_type should be "AES256CBC", "AES256ECB", or any of the cipher types supported by OpenSSL. Pass nil for the iv if the encryption type doesn't use iv's (like ECB). :return: => String :arg: encrypted_data => String :arg: key => String :arg: iv => String :arg: cipher_type => String | def decrypt(encrypted_data, key, iv, cipher_type)
aes = OpenSSL::Cipher::Cipher.new(cipher_type)
aes.decrypt
aes.key = key
aes.iv = iv if iv != nil
aes.update(encrypted_data) + aes.final
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_data(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.padding = 0\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decrypt encrypted_data, key, iv, cipher_type\n aes = OpenS... | [
"0.8432963",
"0.8187987",
"0.75452805",
"0.74710566",
"0.7119538",
"0.70949453",
"0.70847267",
"0.7000138",
"0.6980801",
"0.6946616",
"0.693633",
"0.688547",
"0.6851703",
"0.6817218",
"0.68083364",
"0.6757908",
"0.66244787",
"0.6618416",
"0.659759",
"0.65801257",
"0.6572465",... | 0.8439621 | 0 |
Encrypts a block of data given an encryption key and an initialization vector (iv). Keys, iv's, and the data returned are all binary strings. Cipher_type should be "AES256CBC", "AES256ECB", or any of the cipher types supported by OpenSSL. Pass nil for the iv if the encryption type doesn't use iv's (like ECB). :return: => String :arg: data => String :arg: key => String :arg: iv => String :arg: cipher_type => String | def encrypt(data, key, iv, cipher_type)
aes = OpenSSL::Cipher::Cipher.new(cipher_type)
aes.encrypt
aes.key = key
aes.iv = iv if iv != nil
aes.update(data) + aes.final
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_data(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end",
"def encrypt data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.encrypt... | [
"0.8367523",
"0.8310651",
"0.8018604",
"0.7561377",
"0.7245172",
"0.7221345",
"0.69133705",
"0.68800205",
"0.6872039",
"0.68715656",
"0.68711346",
"0.6845555",
"0.6768463",
"0.6674719",
"0.6661547",
"0.65922177",
"0.6588938",
"0.6569504",
"0.6516006",
"0.6479473",
"0.6410227"... | 0.83820516 | 0 |
insert a new note into a database | def save
if @id
# run an UPDATE query if it is in the database
DB[:conn].execute("UPDATE notes SET text='#{@text}', is_complete='#{@is_complete}' WHERE id=#{@id}")
else
# INSERT if it's not in the database yet.
DB[:conn].execute("INSERT INTO notes(text) VALUES('#{@text}')")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_note(db, category, name, note)\n db.execute(\"INSERT INTO notes (category, name, note) VALUES (?, ?, ?)\", [category, name, note])\nend",
"def note(uid, note)\n single(\"INSERT INTO notes (assumption_uid, content) VALUES ($1, $2)\", [uid, note])\nend",
"def new_note(content)\n note = Note.new({... | [
"0.8154324",
"0.7843895",
"0.706663",
"0.70261586",
"0.6955155",
"0.68844074",
"0.6884008",
"0.68751156",
"0.6796505",
"0.6711709",
"0.6674796",
"0.66637397",
"0.66467154",
"0.66272354",
"0.6570325",
"0.6569332",
"0.65283144",
"0.65212995",
"0.6506293",
"0.6504767",
"0.649416... | 0.7322147 | 2 |
Runs a program locally. | def run(program,*args)
system(program,*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_local(cmd)\n system(cmd)\n end",
"def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n `#{cmd}`\n end",
"def run(cmd)\n #logger.trace \"executing locally: #{cmd.inspect}\" if logger\n run_locally cmd\n # puts `#{cmd}`\nend",
"def local\n... | [
"0.69531864",
"0.68587",
"0.6522916",
"0.6191551",
"0.6101409",
"0.6028299",
"0.6013207",
"0.599349",
"0.5983679",
"0.5983679",
"0.59690535",
"0.5917468",
"0.588048",
"0.5861798",
"0.5851168",
"0.5830518",
"0.5827285",
"0.5826208",
"0.57766294",
"0.5772347",
"0.5694776",
"0... | 0.6893583 | 1 |
Prints out a message. | def echo(message)
puts message
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_message(msg)\n print \">> #{msg.to_s} \\n\"\n end",
"def print(message)\n output.print(message)\n end",
"def message(msg)\n STDOUT.puts msg\n end",
"def msg(message)\n stdout.puts message\n end",
"def print(msg = '')\n clear_line\n print_no_newline(msg)... | [
"0.82025903",
"0.8136033",
"0.7783097",
"0.7782362",
"0.77149785",
"0.7577262",
"0.7570735",
"0.75509006",
"0.7514466",
"0.7514466",
"0.7495838",
"0.7434366",
"0.7385435",
"0.73768455",
"0.73505324",
"0.73366743",
"0.73358387",
"0.7326738",
"0.7325645",
"0.726797",
"0.7266087... | 0.7578541 | 5 |
Changes the current working directory. | def cd(path,&block)
if block
cwd = Dir.pwd
Dir.chdir(path)
block.call()
Dir.chdir(cwd)
else
Dir.chdir(path)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chdir; end",
"def chdir(path)\n ensure_relative_path! :chdir, path\n @path += path\n end",
"def cd(target = ENV['HOME'])\n Dir.chdir(target.strip)\n \"Directory changed to #{Dir.pwd}\"\n end",
"def change_dir f\n unless File.directory? f\n perror \"#{f} is not a directory, o... | [
"0.7231913",
"0.7016624",
"0.69395834",
"0.6899795",
"0.67380613",
"0.67330027",
"0.6712974",
"0.6612908",
"0.6517972",
"0.6497891",
"0.64919966",
"0.6487929",
"0.64867973",
"0.6484557",
"0.64830977",
"0.6446424",
"0.6394484",
"0.63352346",
"0.63135314",
"0.6305189",
"0.62720... | 0.58607316 | 42 |
Only allow a trusted parameter "white list" through. | def tv_episode_params
params.require(:tv_episode).permit(:title, :tmdb_episode_id, :description, :air_date, :episode_number, :season_number, :tvshow_image_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Examples p no_dupes?([1, 1, 2, 1, 3, 2, 4]) => [3, 4] p no_dupes?(['x', 'x', 'y', 'z', 'z']) => ['y'] p no_dupes?([true, true, true]) => [] | def no_consecutive_repeats?(arr)
(0...arr.length - 1).each { |i| return false if arr[i] == arr[i + 1] }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nondupes(array)\n new_array = []\n array.each do |elem| \n if array.count(elem) == 1\n new_array << elem \n end\n end\n new_array\nend",
"def no_dupes?(arr)\n arr.reject do |ele|\n # debugger\n arr.count(ele) > 1\n end\nend",
"def nondupes(array)\n array.map do |elem| \n array.coun... | [
"0.7766084",
"0.7752476",
"0.7736155",
"0.7614962",
"0.75363356",
"0.7488069",
"0.74668366",
"0.746124",
"0.7444679",
"0.740563",
"0.73547494",
"0.73296684",
"0.73166203",
"0.72992706",
"0.72074765",
"0.71457577",
"0.7128234",
"0.70464814",
"0.7034207",
"0.69885266",
"0.69842... | 0.0 | -1 |
Examples p no_consecutive_repeats?(['cat', 'dog', 'mouse', 'dog']) => true p no_consecutive_repeats?(['cat', 'dog', 'dog', 'mouse']) => false p no_consecutive_repeats?([10, 42, 3, 7, 10, 3]) => true p no_consecutive_repeats?([10, 42, 3, 3, 10, 3]) => false p no_consecutive_repeats?(['x']) => true | def char_indices(str)
indices = Hash.new([])
str.each_char.with_index { |char, i| indices[char] += [i] }
indices
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_consecutive_repeats?(array)\n (0...array.length - 1).each {|index| return false if array[index] == array[index + 1] }\n true\nend",
"def no_consecutive_repeats?(array)\n (0...array.length - 1).each do |i|\n return false if array[i] == array[i+1]\n end\n true\nend",
"def no_consecut... | [
"0.76850927",
"0.76576746",
"0.76258814",
"0.7618245",
"0.75910467",
"0.75884116",
"0.75857764",
"0.75857764",
"0.7583619",
"0.7580226",
"0.7568152",
"0.756634",
"0.7528283",
"0.7512146",
"0.74973285",
"0.74478567",
"0.743711",
"0.73797923",
"0.73648095",
"0.7362042",
"0.7354... | 0.0 | -1 |
Examples p longest_streak('a') => 'a' p longest_streak('accccbbb') => 'cccc' p longest_streak('aaaxyyyyyzz') => 'yyyyy p longest_streak('aaabbb') => 'bbb' p longest_streak('abc') => 'c' | def bi_prime?(num)
primes = list_primes_until(num)
primes.any? { |x| primes.any? { |y| x * y == num } }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_streak(str)\n return str if str.length < 2\n \n max_streak = \"\"\n i = 0\n j = 1\n while i < str.length - 1\n j = i + 1\n cur_streak = \"\"\n while j < str.length && str[i] == str [j]\n j += 1\n end\n\n cur_streak = str[i...j]\n ma... | [
"0.8441022",
"0.82704574",
"0.8244169",
"0.81410116",
"0.7903884",
"0.7563653",
"0.7093256",
"0.68494946",
"0.68438303",
"0.6665296",
"0.65755576",
"0.63198435",
"0.63146186",
"0.6296605",
"0.6270927",
"0.6257507",
"0.6256804",
"0.62223566",
"0.6215854",
"0.62054133",
"0.6185... | 0.0 | -1 |
Examples p bi_prime?(14) => true p bi_prime?(22) => true p bi_prime?(25) => true p bi_prime?(94) => true p bi_prime?(24) => false p bi_prime?(64) => false | def vigenere_cipher(message, keys)
chars = message.split('')
i = -1
enc_chars = chars.map do |char|
i = (i + 1) % keys.length
encrypt_char(char, keys[i])
end
enc_chars.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bi_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return true if is_prime?(n) && is_prime?(num/n)\n end\n end\n false\nend",
"def bi_prime?(num)\n (2...num).each do |i|\n return true if num % i == 0 && prime?(i) && prime?(num / i)\n end\n false\nend",
"def b... | [
"0.8281085",
"0.82703304",
"0.8257007",
"0.82348573",
"0.82134205",
"0.8178718",
"0.81769645",
"0.81700945",
"0.81395066",
"0.8127853",
"0.8118922",
"0.8098536",
"0.80793047",
"0.8078909",
"0.8074484",
"0.8047045",
"0.80304784",
"0.8002915",
"0.7993853",
"0.79491615",
"0.7948... | 0.0 | -1 |
Examples p vigenere_cipher("toerrishuman", [1]) => "upfssjtivnbo" p vigenere_cipher("toerrishuman", [1, 2]) => "uqftsktjvobp" p vigenere_cipher("toerrishuman", [1, 2, 3]) => "uqhstltjxncq" p vigenere_cipher("zebra", [3, 0]) => "ceerd" p vigenere_cipher("yawn", [5, 1]) => "dbbo" | def vowel_rotate(str)
vowel_indices = (0...str.length).select { |i| 'aeiou'.include?(str[i]) }
rotated_indices = vowel_indices.rotate(-1)
rotated_chars = str.split('').map.with_index do |char, i|
vowel_indices.include?(i) ? str[rotated_indices.shift] : char
end
rotated_chars.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vigenere_cipher(string, key_sequence, alphabet)\r\n\r\nend",
"def vigenere_cipher(message, keys)\n alphabetic = (\"a\"..\"z\").to_a\n encrypted = \"\"\n\n message.each_char.with_index do |char, i|\n num = keys[i % keys.length]\n index = alphabetic.index(char)\n encrypted += alphabetic[(index + nu... | [
"0.79110205",
"0.7902209",
"0.78207576",
"0.78193635",
"0.77866805",
"0.7767322",
"0.7756652",
"0.77224773",
"0.7721039",
"0.7709031",
"0.76752245",
"0.76732403",
"0.7630802",
"0.7607273",
"0.76066494",
"0.7589914",
"0.75896025",
"0.7548111",
"0.7546698",
"0.75004023",
"0.748... | 0.0 | -1 |
If created user is first user, then make it an admin user | def first_user_hook
if User.with_role(:admin).count == 0
self.grant :admin
else # set editor as default role
self.grant :editor if self.roles.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def make_admin_if_first_user\n self.make_admin if self.first_user?\n end",
"def record_first_admin\n return unless User.count.zero?\n\n self.admin = true\n end",
"def upgra... | [
"0.83339506",
"0.80765986",
"0.78233045",
"0.77503175",
"0.7548114",
"0.75064355",
"0.7444957",
"0.7295863",
"0.7219491",
"0.718042",
"0.71701646",
"0.71561134",
"0.7139989",
"0.71387243",
"0.71384287",
"0.7115287",
"0.7110341",
"0.7086334",
"0.708213",
"0.7056174",
"0.705472... | 0.6897297 | 34 |
GET /efforts GET /efforts.json | def index
@efforts = Effort.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @efforts }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @effort }\n end\n end",
"def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.er... | [
"0.7128618",
"0.7128059",
"0.6579969",
"0.6416515",
"0.6225248",
"0.6212075",
"0.60979205",
"0.59309536",
"0.5849424",
"0.57973653",
"0.57282275",
"0.5720143",
"0.5697248",
"0.5672627",
"0.56671894",
"0.5658207",
"0.56552464",
"0.56409734",
"0.56394607",
"0.5636336",
"0.56323... | 0.7651738 | 0 |
GET /efforts/1 GET /efforts/1.json | def show
@effort = Effort.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @effort }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @effort }\n end\n end",
"def index\n @efforts = Effort.all\n\n respond_to do |format|\n format.html # index.html.erb\n fo... | [
"0.7495704",
"0.74258894",
"0.6464546",
"0.6396182",
"0.638218",
"0.6340826",
"0.62139845",
"0.60046506",
"0.5952846",
"0.59344625",
"0.5875357",
"0.5875357",
"0.58585757",
"0.58548373",
"0.5851356",
"0.5851356",
"0.5831068",
"0.5828114",
"0.5814851",
"0.57949436",
"0.5786053... | 0.75051475 | 0 |
GET /efforts/new GET /efforts/new.json | def new
@effort = Effort.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @effort }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @effort = Effort.new(user_id: spree_current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @effort }\n end\n end",
"def create\n @effort = Effort.new(params[:effort])\n\n respond_to do |format|\n if @e... | [
"0.730456",
"0.70629305",
"0.69774073",
"0.68256575",
"0.6792218",
"0.6576796",
"0.6576796",
"0.65649194",
"0.65649194",
"0.65513456",
"0.6547807",
"0.6547807",
"0.6547807",
"0.6547807",
"0.65412456",
"0.6538537",
"0.65374184",
"0.6531159",
"0.6520965",
"0.6515067",
"0.651147... | 0.80478424 | 0 |
POST /efforts POST /efforts.json | def create
@effort = Effort.new(params[:effort])
respond_to do |format|
if @effort.save
format.html { redirect_to @effort, notice: 'Effort was successfully created.' }
format.json { render json: @effort, status: :created, location: @effort }
else
format.html { render action: "new" }
format.json { render json: @effort.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @efforts = Effort.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @efforts }\n end\n end",
"def create\n @effort = Effort.new(params[:effort])\n @effort.started_at = Time.now if params[:commit] == \"Iniciar atividade\"\n\n ... | [
"0.6383167",
"0.6292616",
"0.60142577",
"0.6010825",
"0.57508177",
"0.5703241",
"0.5688933",
"0.55571604",
"0.5556797",
"0.5534042",
"0.5513427",
"0.54798985",
"0.547407",
"0.5438401",
"0.5421402",
"0.5394739",
"0.5378964",
"0.5377503",
"0.53509384",
"0.53286004",
"0.532108",... | 0.6762209 | 0 |
PUT /efforts/1 PUT /efforts/1.json | def update
@effort = Effort.find(params[:id])
respond_to do |format|
if @effort.update_attributes(params[:effort])
format.html { redirect_to @effort, notice: 'Effort was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @effort.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @effort = Effort.find(params[:id])\n @effort.completed_at = Time.now if params[:commit] == \"Concluir atividade\"\n\n respond_to do |format|\n if @effort.update_attributes(params[:effort])\n format.html { redirect_to admin_efforts_path, notice: 'Alocação atuali... | [
"0.65331805",
"0.64933944",
"0.6129887",
"0.6000726",
"0.5985331",
"0.5969388",
"0.5923918",
"0.5922773",
"0.59196436",
"0.5885111",
"0.5882329",
"0.5845489",
"0.5836597",
"0.58312607",
"0.5830117",
"0.5828616",
"0.57698005",
"0.5761425",
"0.5739286",
"0.5726388",
"0.57254183... | 0.7192345 | 0 |
DELETE /efforts/1 DELETE /efforts/1.json | def destroy
@effort = Effort.find(params[:id])
@effort.destroy
respond_to do |format|
format.html { redirect_to efforts_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @effort = Effort.find(params[:id])\n @effort.destroy\n\n respond_to do |format|\n format.html { redirect_to efforts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @editability = Editability.find(params[:id])\n @editabil... | [
"0.73529345",
"0.6870871",
"0.68154883",
"0.66863745",
"0.65773666",
"0.6575156",
"0.65736735",
"0.65386367",
"0.6522808",
"0.65180516",
"0.6500292",
"0.6498986",
"0.6470524",
"0.6450188",
"0.6443897",
"0.6429751",
"0.6413883",
"0.64088935",
"0.6404612",
"0.6390975",
"0.63871... | 0.7626579 | 0 |
CSS class for HTML status codes | def class_for_code(code)
"r#{Integer(code)/100}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_code; end",
"def http_status\n self[:status_code]\n end",
"def status_code\n STATUS_CODE\n end",
"def status_code\n self.status.to_i\n end",
"def status_code(*)\n end",
"def status_codes\n STATUS_CODES\n end",
"def status_code_meaning(number)\... | [
"0.70320207",
"0.7025712",
"0.69347167",
"0.6843483",
"0.6825588",
"0.68053716",
"0.67739874",
"0.67426944",
"0.67426944",
"0.67426944",
"0.67309284",
"0.6674621",
"0.6619383",
"0.6604126",
"0.65755445",
"0.65755445",
"0.65683436",
"0.65647644",
"0.6559685",
"0.65022594",
"0.... | 0.0 | -1 |
// For example, S = "abba", T = "^abba$". // ^ and $ signs are sentinels appended to each end to avoid bounds checking | def preProcess(s)
n = s.length().to_i
if n==0
return "^$"
end
ret = "^"
(0..n-1).each do |re|
ret += ('#' + s[re].to_s)
end
ret += '#$'
return ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minSubstringWithAllChars(s, t)\n (0..s.size).lazy.map { |l|\n (0..s.size - l).lazy.map { |i| s[i, l] }\n .find { |x| t.each_char.all? { |c| x[c] } }\n }.find { |x| x }\nend",
"def sseq(s, t)\n\tindices = []\n\tlast_idx = 0\n\tt.each_char do |chr|\n\t\ti = s.index(chr, last_idx+1)\n\t\... | [
"0.62537557",
"0.590668",
"0.58795315",
"0.5796636",
"0.57098556",
"0.5688818",
"0.56802994",
"0.56522447",
"0.5647781",
"0.5647702",
"0.5615694",
"0.5606609",
"0.55827665",
"0.55790293",
"0.5571723",
"0.5561692",
"0.5556649",
"0.55564815",
"0.5525966",
"0.54822415",
"0.54776... | 0.5470403 | 21 |
Saves the current state of all merged entities. For more complete error reporting, this method attempts to save all entities regardless of whether or not a previous entity or set of entities failed to save. However, it will return true if and only if all entities were saved. When data dependencies exist, this can lead to spurious errors; however, that can be dealt with by just looking further up in the log. There's no similar way to discover errors that aren't reported due to an early abort. | def save
collections = [participants, people,
contacts, events, instruments,
response_sets,
question_response_sets
].map { |c| current_for(c).compact }
ActiveRecord::Base.transaction do
collections.map { |c| save_collection(c) }.all?.tap do |ok|
if ok
logger.debug { "Re-saving response sets" }
current_for(response_sets).select { |rs| rs }.each { |rs| rs.target.reload.save }
logger.info { 'Merge saved' }
else
logger.fatal { 'Errors raised during save; rolling back' }
raise ActiveRecord::Rollback
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def committed?\n @saved\n end",
"def save\n save!\n rescue StandardError\n false\n end",
"def save\n begin\n save!\n true\n rescue\n false\n end\n end",
"def save!\n unless save\n self.class.fail_validate!(self) unless errors.empty?\n ... | [
"0.6109903",
"0.60229796",
"0.59732074",
"0.5901313",
"0.5892655",
"0.57836634",
"0.57782817",
"0.57714987",
"0.57659143",
"0.5695334",
"0.5694243",
"0.5682495",
"0.56547755",
"0.56536376",
"0.56320524",
"0.56197196",
"0.5610536",
"0.55997616",
"0.5595881",
"0.5588441",
"0.55... | 0.63260096 | 0 |
Adds and logs conflicts. | def add_conflict(entity, id, attr, o, c, p)
logger.warn { "Detected conflict on #{entity} #{attr}: [o, c, p] = #{[o, c, p].inspect}" }
conflicts.add(entity, id, attr, o, c, p)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conflicts\n @conflicts ||= []\n end",
"def conflicts\n @conflicts ||= []\n end",
"def message\n \"#{base} already defines #{conflicts}, also defined on #{owner}\"\n end",
"def conflict(val)\n conflicts << val\n conflicts.dup\n end",
"def conflict(val)\n conflic... | [
"0.753011",
"0.753011",
"0.7275232",
"0.71290165",
"0.71290165",
"0.67822963",
"0.6777635",
"0.6764266",
"0.6649675",
"0.6615368",
"0.6539875",
"0.6135",
"0.60148174",
"0.58816713",
"0.5863662",
"0.5833769",
"0.5806479",
"0.5745109",
"0.57001203",
"0.56801987",
"0.56792825",
... | 0.70366246 | 5 |
Search gem load paths. | def load_path(match, options={})
options = valid_load_options(options)
specs = specifications(options)
matches = []
specs.each do |spec|
list = []
spec.require_paths.each do |path|
glob = File.join(spec.full_gem_path, path, match)
list = Dir[glob] #.map{ |f| f.untaint }
list = list.map{ |d| d.chomp('/') }
# return relative paths unless absolute flag
if options[:relative] #not options[:absolute]
# the extra '' in File.join adds a '/' to the end of the path
list = list.map{ |f| f.sub(File.join(spec.full_gem_path, path, ''), '') }
end
matches.concat(list)
end
# activate the library if activate flag
spec.activate if options[:activate] && !list.empty?
end
matches
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_paths\n [root.join('lib'), root.join('spec')].join(':')\n end",
"def lookup_paths\n if list = ENV['RUBY_LIBRARY']\n list.split(/[:;]/)\n #elsif File.exist?(path_file)\n # File.readlines(path_file).map{ |x| x.strip }.reject{ |x| x.empty? || x =~ /^\\s*\\#/ }\n ... | [
"0.72364444",
"0.70900047",
"0.70517397",
"0.6956746",
"0.693558",
"0.69078434",
"0.69062763",
"0.6902592",
"0.68499345",
"0.679078",
"0.6691593",
"0.6680091",
"0.6625411",
"0.65592355",
"0.6555327",
"0.65509486",
"0.6537707",
"0.6521265",
"0.6518317",
"0.65023416",
"0.64837"... | 0.67986065 | 9 |
Search gem data paths. | def data_path(match, options={})
specs = specifications(options)
matches = []
specs.each do |spec|
list = []
glob = File.join(spec.full_gem_path, 'data', match)
list = Dir[glob] #.map{ |f| f.untaint }
list = list.map{ |d| d.chomp('/') }
matches.concat(list)
# activate the library if activate flag
spec.activate if options[:activate] && !list.empty?
end
matches
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paths_from_software_gems\n @paths_from_software_gems ||=\n Array(Config.software_gems).inject([]) do |array, name|\n if (spec = Gem::Specification.find_all_by_name(name).first)\n array << File.expand_path(spec.gem_dir)\n end\n\n array\n end\n end",
... | [
"0.67978895",
"0.6582824",
"0.65235054",
"0.64876014",
"0.6485551",
"0.63830143",
"0.6360867",
"0.63585126",
"0.6349846",
"0.63223344",
"0.6300142",
"0.6299768",
"0.6294332",
"0.6285686",
"0.6240776",
"0.62154865",
"0.62132496",
"0.6209585",
"0.6206423",
"0.6202027",
"0.62020... | 0.70380396 | 0 |
Removes path and expiration values from cookie. | def extract_cookie(cookie_val)
cleaned_val = cookie_val.gsub(/(path=[^,;]+[,;])|(expires=.*)/, ' ')
cleaned_val.gsub!(/\s+/, ' ')
if @proxied_cookies.empty?
return ['', cleaned_val]
else
@proxied_cookies.each do |key|
if match = cleaned_val.match(/#{key}=(?<val>(.*));/i)
return [key, match[:val]]
end
end
end
['', '']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unset\n @cookies.delete cookie_name, cookie_options\n end",
"def clear_cookie\n create_accesses_cookie\n end",
"def delete_cookie(cookies)\n cookies.delete('token')\n @user.update(token: '')\n end",
"def destroy\n\t\tcookies.delete 'Vanilla'\n\t\tc... | [
"0.64445007",
"0.63492787",
"0.6333",
"0.63261294",
"0.62320757",
"0.6213248",
"0.6154333",
"0.6152161",
"0.61477566",
"0.6104468",
"0.6054121",
"0.6054121",
"0.6054121",
"0.6054121",
"0.6036387",
"0.6011818",
"0.60099953",
"0.60079265",
"0.5995761",
"0.5981008",
"0.59489274"... | 0.5270168 | 91 |
GET /problems/1 GET /problems/1.json | def show
request.headers
respond_to do |format|
format.html
format.mobile{render :layout => !request.xhr?}
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @problems = Problem.all\n\n render json: @problems\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.active.all\n\n respond_to do |format|\n ... | [
"0.7573485",
"0.7226409",
"0.7226409",
"0.7226409",
"0.7224276",
"0.71510506",
"0.7076648",
"0.7076648",
"0.7019441",
"0.6847158",
"0.67619693",
"0.6740194",
"0.6740194",
"0.6713735",
"0.67055875",
"0.67037416",
"0.6671908",
"0.6648854",
"0.66116905",
"0.65953594",
"0.6579332... | 0.0 | -1 |
GET /problems/new GET /problems/new.json | def new
@problem.description = <<-HERE.strip_heredoc
Your problem:
-------------
Items that **must** have:
1. house
3. table
2. fridge
Items to be _solved_:
- It would be good to have a nice Ipad
- and an Apple TV
- an a Time capsule
[Link to Apple](http://www.apple.com/)
> Knowing others is intelligence; knowing yourself is true wisdom. Mastering others is strength; mastering yourself is true power. If you realize that you have enough, you are truly rich.
This is a preformatted text1
This is a preformatted text2
HERE
@preview = BlueCloth.new(@problem.description).to_html.html_safe
respond_to do |format|
format.html # new.html.erb
format.json { render json: @problem }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n ... | [
"0.79234505",
"0.79234505",
"0.78800845",
"0.74476093",
"0.73984045",
"0.7243975",
"0.7222093",
"0.70534116",
"0.7007844",
"0.7007793",
"0.69895875",
"0.6941806",
"0.6937303",
"0.6918376",
"0.6877167",
"0.68579644",
"0.6856023",
"0.68521476",
"0.6817408",
"0.68165654",
"0.678... | 0.0 | -1 |
POST /problems POST /problems.json | def create
respond_to do |format|
if @problem.save
format.html { redirect_to @problem, notice: 'Problem was successfully created.' }
format.json { render json: @problem, status: :created, location: @problem }
else
format.html { render action: "new" }
format.json { render json: @problem.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @problem = Problem.new(problem_params)\n\n if @problem.save\n render json: @problem, status: :created, location: @problem\n else\n render json: @problem.errors, status: :unprocessable_entity\n end\n end",
"def index\n @problems = Problem.all\n\n render json: @problems\n ... | [
"0.7035215",
"0.67344344",
"0.6726247",
"0.66629434",
"0.66624814",
"0.6620491",
"0.6574222",
"0.6516654",
"0.65019697",
"0.6400685",
"0.6390408",
"0.63000333",
"0.6288726",
"0.6262413",
"0.6262413",
"0.625801",
"0.62116486",
"0.618457",
"0.6172585",
"0.61645955",
"0.6155211"... | 0.6478053 | 9 |
PUT /problems/1 PUT /problems/1.json | def update
respond_to do |format|
if @problem.update_attributes(params[:problem])
format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @problem.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @problem = Problem.find(params[:id])\n\n if @problem.update(problem_params)\n head :no_content\n else\n render json: @problem.errors, status: :unprocessable_entity\n end\n end",
"def update\n @problem = Problem.find_by_shortname(params[:id])\n create_tags\n respond_to... | [
"0.71729845",
"0.68736047",
"0.6796395",
"0.6796395",
"0.6796395",
"0.6678712",
"0.65402174",
"0.6522685",
"0.6511796",
"0.63718086",
"0.6302541",
"0.6302541",
"0.6302541",
"0.6302541",
"0.62581813",
"0.625274",
"0.6117491",
"0.6117491",
"0.6117491",
"0.6117491",
"0.6117491",... | 0.6683192 | 5 |
DELETE /problems/1 DELETE /problems/1.json | def destroy
@problem.destroy
respond_to do |format|
format.html { redirect_to problems_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find_by_shortname(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redi... | [
"0.7560659",
"0.7557449",
"0.755692",
"0.755692",
"0.755692",
"0.755692",
"0.7495239",
"0.7386734",
"0.7368817",
"0.73638684",
"0.73053366",
"0.72629756",
"0.7138887",
"0.7128535",
"0.70500004",
"0.70385283",
"0.70229536",
"0.70055926",
"0.7003952",
"0.68813664",
"0.67814624"... | 0.76009053 | 0 |
Returns true if a primitive's rectangle is entirely inside another primitive's rectangle. | def inside_rect? outer, tolerance = 0.0
Geometry.inside_rect? self, outer, tolerance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersect? rect\n rect.is_a?(Rectangle) && !(@x + @width < rect.x || rect.x + rect.width < @x || @y + @height < rect.y || rect.y + rect.height < @y)\n end",
"def included_in?(other_rect)\n self == self.intersects(other_rect)\n end",
"def contain?(rect)\n nself = self#.normalize\n rect = Rect.... | [
"0.7948215",
"0.793003",
"0.7684561",
"0.74702066",
"0.7290085",
"0.7253465",
"0.7161899",
"0.7124796",
"0.71138746",
"0.7045976",
"0.7030197",
"0.7018792",
"0.7002007",
"0.7002007",
"0.69897985",
"0.6957257",
"0.6946802",
"0.69150203",
"0.69141537",
"0.69093376",
"0.6886441"... | 0.7500801 | 3 |
Scales a primitive rect by a percentage. | def scale_rect percentage, *anchors
Geometry.scale_rect self, percentage, *anchors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(*args)\n r = Rect.new x, y, w, h\n r.resolution = r.resolution * Vector2[args.singularize]\n r\n end",
"def vscale(factor)\n @height = @height * factor\n @top *= factor\n self\n end",
"def scale(value)\r\n value * @height/2 + @height/4\r\n end",
"def scale(x, y)\n ... | [
"0.63197976",
"0.6116605",
"0.60990804",
"0.5944514",
"0.58709925",
"0.5776801",
"0.5719672",
"0.56415004",
"0.56407744",
"0.5614465",
"0.5609648",
"0.5562131",
"0.55542594",
"0.5543392",
"0.55390245",
"0.5535034",
"0.5492933",
"0.54394084",
"0.5434011",
"0.5426827",
"0.54217... | 0.84678346 | 0 |
Returns the angle from one primitive to another primitive. | def angle_to other_point
Geometry.angle_to self, other_point
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle(other)\n\n # Two options here:\n #\n # 1. Math.atan2(other.cross_length(self), dot(other)) \n #\n # This is stable but slower (x 1.5)\n #\n # 2. Math.acos(dot(other) / (r * other.r)) \n #\n # This is faster but unstable around 0 and pi where the grad... | [
"0.7642555",
"0.7580265",
"0.747291",
"0.7467351",
"0.74523467",
"0.7414426",
"0.7342401",
"0.7337862",
"0.726271",
"0.7156291",
"0.71125174",
"0.7042469",
"0.7018013",
"0.6877022",
"0.687598",
"0.68316835",
"0.68095326",
"0.6760979",
"0.6749183",
"0.6672454",
"0.66706693",
... | 0.74456096 | 5 |
Returns the angle to one primitive from another primitive. | def angle_from other_point
Geometry.angle_from self, other_point
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle_to other_point\n Geometry.angle_to self, other_point\n end",
"def other_angle(a, b)\n 180 - (a + b)\nend",
"def other_angle(a, b)\n 180 - (a + b)\nend",
"def angle(other)\n\n # Two options here:\n #\n # 1. Math.atan2(other.cross_length(self), dot(other)) \n #\n ... | [
"0.7545739",
"0.7384567",
"0.7372221",
"0.7313503",
"0.7262168",
"0.7184892",
"0.71301836",
"0.7107542",
"0.70649385",
"0.7044069",
"0.6990309",
"0.69445723",
"0.6893734",
"0.68116015",
"0.6789178",
"0.67859197",
"0.6727259",
"0.6716903",
"0.6675718",
"0.6672194",
"0.6672194"... | 0.7746496 | 0 |
Returns true if a primitive is within a circle specified by the circle's center and radius. | def point_inside_circle? circle_center_point, radius
Geometry.point_inside_circle? self, circle_center_point, radius
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inside_circle?(point, radius)\n (self.distance_to(point) <= radius)\n end",
"def within_radius_of?(center, radius)\n return false unless center\n (self.point == center.point) || (center.distance_to(self) <= radius)\n end",
"def intersects_with?(o_circle)\n pts_distance(@center, o_circle.c... | [
"0.8415395",
"0.82826495",
"0.80688614",
"0.73929596",
"0.73202246",
"0.7280403",
"0.7115079",
"0.7094616",
"0.69570464",
"0.6916512",
"0.68164206",
"0.6778389",
"0.6661389",
"0.66604054",
"0.6582593",
"0.65708387",
"0.6515795",
"0.643736",
"0.636547",
"0.635673",
"0.63431525... | 0.82744735 | 2 |
Returns a primitive that is anchored/repositioned based off its rectangle. | def anchor_rect anchor_x, anchor_y
current_w = self.w
current_h = self.h
delta_x = -1 * (anchor_x * current_w)
delta_y = -1 * (anchor_y * current_h)
self.shift_rect(delta_x, delta_y)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rectangle\n return @rectangle if @rectangle\n\n # Assume that the focal vector is Vector[0, 0, @focus.r]\n assumed = Vector[0, 0, @focus.r]\n @rectangle = [\n Vector[-@width/2, @height/2, @focus.r],\n Vector[ @width/2, @height/2, @focus.r],\n Vector[ @width/2, -@height/2, @focus.r]... | [
"0.630119",
"0.61938596",
"0.6166139",
"0.6120037",
"0.6005603",
"0.6005603",
"0.5917027",
"0.58906484",
"0.5822918",
"0.57254636",
"0.571822",
"0.5618471",
"0.5595407",
"0.55736554",
"0.5572011",
"0.55672526",
"0.5536303",
"0.55064225",
"0.5505891",
"0.5492515",
"0.5480817",... | 0.5334764 | 31 |
=begin Returns true if the message should be printed in the given timestamp, otherwise returns false. If this method returns false, the message will not be printed. The timestamp is in seconds granularity. :type timestamp: Integer :type message: String :rtype: Boolean =end | def should_print_message(timestamp, message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_print_message(timestamp, message)\n if log[message].nil? || timestamp - log[message] >= 10\n log.store(message, timestamp)\n return true\n end\n \n return false\n end",
"def should_print_message(timestamp, message)\n result = true\n if... | [
"0.81502783",
"0.81319153",
"0.78711414",
"0.76355124",
"0.7587671",
"0.62727463",
"0.5919023",
"0.58751553",
"0.58407587",
"0.5801317",
"0.5774184",
"0.57585645",
"0.56052476",
"0.5568675",
"0.5551019",
"0.5544103",
"0.55289567",
"0.55179673",
"0.5476676",
"0.5454002",
"0.54... | 0.7944626 | 2 |
GET /party_approvals or /party_approvals.json | def index
@party_approvals = PartyApproval.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approvals\n approvals_list = []\n if params[:count]\n if params[:skip]\n approvals_list = current_user.db_user.approval_approvers.order('created_at desc').offset(params[:skip].to_i).take(params[:count].to_i)\n else\n approvals_list = current_user.db_user.approval_approvers.order('... | [
"0.643207",
"0.6275669",
"0.592398",
"0.5904591",
"0.578622",
"0.5747836",
"0.5730095",
"0.56563437",
"0.56369066",
"0.5601522",
"0.55984646",
"0.55951494",
"0.55613357",
"0.55613214",
"0.5529902",
"0.54554397",
"0.5448509",
"0.5426189",
"0.54034215",
"0.53918517",
"0.5356828... | 0.6605213 | 0 |
GET /party_approvals/1 or /party_approvals/1.json | def show; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @party_approvals = PartyApproval.all\n end",
"def approvals\n approvals_list = []\n if params[:count]\n if params[:skip]\n approvals_list = current_user.db_user.approval_approvers.order('created_at desc').offset(params[:skip].to_i).take(params[:count].to_i)\n else\n ... | [
"0.66051",
"0.64246833",
"0.620986",
"0.6083993",
"0.60380757",
"0.5874765",
"0.5769815",
"0.5761945",
"0.56445503",
"0.5596188",
"0.5589476",
"0.5560001",
"0.5556063",
"0.55556804",
"0.5510933",
"0.5509608",
"0.5501054",
"0.5495915",
"0.5488678",
"0.54462737",
"0.53868616",
... | 0.0 | -1 |
POST /party_approvals or /party_approvals.json | def create
@party_approval = PartyApproval.new(party_approval_params)
respond_to do |format|
if @party_approval.save
format.html { redirect_to @party_approval, notice: 'Party approval was successfully created.' }
format.json { render :show, status: :created, location: @party_approval }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @party_approval.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def party_approval_params\n params.require(:party_approval).permit(:user, :party, :approval)\n end",
"def politician_approval_params\n params.require(:politician_approval).permit(:user, :party, :approval)\n end",
"def set_party_approval\n @party_approval = PartyApproval.find(params[:id])\n end",
... | [
"0.69791937",
"0.6520171",
"0.6458408",
"0.63690704",
"0.6335551",
"0.6312647",
"0.62580043",
"0.6023837",
"0.5969117",
"0.5886409",
"0.58461154",
"0.5826825",
"0.58157295",
"0.5810201",
"0.578843",
"0.57762676",
"0.576642",
"0.57582396",
"0.5749369",
"0.5747433",
"0.572701",... | 0.6896017 | 1 |
PATCH/PUT /party_approvals/1 or /party_approvals/1.json | def update
respond_to do |format|
if @party_approval.update(party_approval_params)
format.html { redirect_to @party_approval, notice: 'Party approval was successfully updated.' }
format.json { render :show, status: :ok, location: @party_approval }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @party_approval.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_party_approval\n @party_approval = PartyApproval.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @political_party.update(political_party_params)\n format.html { redirect_to @political_party, notice: 'Political party was successfully updated.' }\n format.json ... | [
"0.6594875",
"0.6508229",
"0.64911336",
"0.6352692",
"0.6327853",
"0.63191134",
"0.62818646",
"0.6247028",
"0.6158167",
"0.6094758",
"0.6075864",
"0.60524327",
"0.6009123",
"0.5998709",
"0.598375",
"0.59671915",
"0.58947796",
"0.5890873",
"0.58388966",
"0.58255935",
"0.582113... | 0.7152015 | 0 |
DELETE /party_approvals/1 or /party_approvals/1.json | def destroy
@party_approval.destroy
respond_to do |format|
format.html { redirect_to party_approvals_url, notice: 'Party approval was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_approver\n\n # get the client\n @client = Client.find(params[:client_id])\n\n # get the contract\n @contract = Contract.find(params[:id])\n\n # find the approver\n @approver = User.find(params[:user_id])\n\n # double check use is an approver\n if @contract.is_approver?(@approver)... | [
"0.6725972",
"0.6553308",
"0.6502757",
"0.65018857",
"0.63829803",
"0.6318106",
"0.63008183",
"0.621909",
"0.61684126",
"0.6152238",
"0.6144509",
"0.6131181",
"0.6101823",
"0.6059425",
"0.60181546",
"0.60181546",
"0.6016522",
"0.60050917",
"0.6000904",
"0.59897053",
"0.598824... | 0.6904088 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_party_approval
@party_approval = PartyApproval.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 |
Only allow a list of trusted parameters through. | def party_approval_params
params.require(:party_approval).permit(:user, :party, :approval)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
GET /rules/1 GET /rules/1.json | def show
flash.keep
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @rule }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @rules = Rule.all\n render_for_api :public, :json => @rules\n end",
"def show\n render json: @rule\n end",
"def rule(name)\n begin\n @name=name\n @content=get_rest \"rules/#{@name}\"\n rescue Stingray::NotFoundError \n nil\n end\n end",
"def index... | [
"0.71463287",
"0.7027388",
"0.69776374",
"0.6970006",
"0.6843102",
"0.6822989",
"0.6683223",
"0.6683223",
"0.6683223",
"0.6683223",
"0.6619106",
"0.6601413",
"0.6549146",
"0.65400594",
"0.64686435",
"0.64344156",
"0.6413582",
"0.64124274",
"0.6388942",
"0.63414055",
"0.630994... | 0.5950644 | 49 |
GET /rules/new GET /rules/new.json | def new
create_rule
@tid = params[:pattern_id]
if (@tid && @tid.to_i > 0)
if current_user.patterns.find(@tid).nil?
raise AppExceptions::InvalidParameter.new('Security Alert: Invalid pattern_id was specified!')
end
@rule.pattern_id = @tid
end
load_pattern
@guided_workflow = params[:guided_workflow]
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @rule }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @rule_set = RuleSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @rule_set }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rulebook }\n end\n end",
"def new... | [
"0.7555783",
"0.72656727",
"0.7149641",
"0.7116677",
"0.70686734",
"0.7029182",
"0.7013985",
"0.6961055",
"0.69131935",
"0.6908905",
"0.68914926",
"0.68903095",
"0.68700063",
"0.68451375",
"0.68110037",
"0.6792977",
"0.6707119",
"0.6659611",
"0.6639479",
"0.6617542",
"0.66050... | 0.7037782 | 5 |
POST /rules POST /rules.json | def create
# validating pattern_id, the specified pattern must belong to the current user
@tid = params[:rule][:pattern_id]
if (!(@tid && @tid.to_i > 0))
@tid = params[:pattern_id]
end
if (@tid && @tid.to_i > 0)
@pattern = current_user.patterns.find(@tid)
raise AppExceptions::InvalidParameter.new('Security Alert! Invalid pattern_id was specified!') unless @pattern
end
@rule = current_user.rules.new(params[:rule])
@rule.pattern = @pattern
@rule.save!
flash.keep
load_pattern
respond_to do |format|
format.html { redirect_to( url = pattern_path(@pattern), :flash => {:success => 'Successfully created the specified Rule.' })}
format.json { render :json => @rule, :status => :created }
end
rescue Exception => e
respond_to do |format|
warning_message = pre_process_exception(e)
if not warning_message.nil?
logger.debug(warning_message)
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:error => warning_message} }
format.json { render :json => @rule, :status => :unprocessable_entity }
end
error_message = "Failed to create the specified Rule."
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:error => error_message} }
format.json { render :json => @rule, :status => :unprocessable_entity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create rules\n raise ArgumentError.new('No rules provided') if rules.nil? || rules.empty?\n request = create_post_request(construct_rules(rules))\n response = fetch_data(request)\n return true if response.nil?\n return GnipApi::JsonParser.new.parse(response)\n end",
"d... | [
"0.7646483",
"0.71496737",
"0.70469105",
"0.68827236",
"0.68346715",
"0.6764645",
"0.6703075",
"0.6535743",
"0.6513507",
"0.6446378",
"0.6432997",
"0.6416578",
"0.6414961",
"0.63828355",
"0.6326537",
"0.6323394",
"0.6290568",
"0.62344164",
"0.6203308",
"0.6171059",
"0.6106182... | 0.0 | -1 |
PUT /rules/1 PUT /rules/1.json | def update
flash.keep
respond_to do |format|
if @rule.update_attributes(params[:rule])
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:success => 'Successfully updated the Rule.' }}
format.json { render :json => @rule }
else
log_message << @rule.errors.full_messages.to_s unless @rule.nil? || @rule.errors.nil? || @rule.errors.full_messages.nil?
logger.error(log_message)
logger.debug(e.backtrace)
error_message = "Failed to update the specified Rule."
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:error => error_message} }
format.json { render :json => @rule, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_rules\n create_update_rules\n end",
"def update!(**args)\n @rules = args[:rules] if args.key?(:rules)\n end",
"def update!(**args)\n @rules = args[:rules] if args.key?(:rules)\n end",
"def update\n respond_to do |format|\n if @rule.update(rule_params... | [
"0.7043215",
"0.68250173",
"0.68250173",
"0.67708766",
"0.66996753",
"0.66590863",
"0.65952486",
"0.6517969",
"0.6490037",
"0.6487923",
"0.6310482",
"0.6200341",
"0.61940855",
"0.61617744",
"0.61617744",
"0.61617744",
"0.61617744",
"0.6155782",
"0.61403614",
"0.6119514",
"0.6... | 0.56026965 | 55 |
GET /rules GET //rules.json | def index
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @rules }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rules\n @rules=get_endpoint('rule').keys\n end",
"def index\n @rules = Rule.all\n render_for_api :public, :json => @rules\n end",
"def get_all_rules\n @options = {\n headers: {\n \"User-Agent\": 'v2FilteredStreamRuby',\n \"Authorization\": \"Bearer #{@bearer_token}\"\n }\n ... | [
"0.7499306",
"0.72862667",
"0.7198168",
"0.7049526",
"0.68032885",
"0.6667045",
"0.66605824",
"0.6649178",
"0.6649178",
"0.6649178",
"0.6649178",
"0.66284627",
"0.66202074",
"0.66168904",
"0.6533221",
"0.6523069",
"0.65159124",
"0.6510809",
"0.6490104",
"0.6490104",
"0.647891... | 0.7071368 | 3 |
DELETE /rules/1 DELETE /rules/1.json | def destroy
@rule.destroy
flash.keep
respond_to do |format|
format.html { redirect_to pattern_path(@pattern), :flash => {:success => 'Successfully deleted the specified Rule.' } }
format.json { render :json => @rule, :status => :ok }
end
rescue Exception => e
respond_to do |format|
warning_message = pre_process_exception(e)
if not warning_message.nil?
logger.debug(warning_message)
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:error => warning_message} }
format.json { render :json => @rule, :status => :unprocessable_entity }
end
error_message = "Failed to destroy the specified Rule."
format.html { redirect_to pattern_rules_url(@pattern), :flash => {:error => error_message} }
format.json { render :json => @rule, :status => :unprocessable_entity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n return if @name.nil?\n delete_rest \"rules/#{@name}\"\n end",
"def destroy\n @rule.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @rule.destroy\n respond_to do |format|\n format.html { redirect_to rules_url }... | [
"0.767555",
"0.7588715",
"0.7470095",
"0.7402141",
"0.7284156",
"0.72284585",
"0.7158197",
"0.7144923",
"0.7144923",
"0.707657",
"0.7033421",
"0.7021132",
"0.7005468",
"0.69536763",
"0.69455576",
"0.68766856",
"0.6860493",
"0.68428296",
"0.6833697",
"0.6825529",
"0.6805035",
... | 0.0 | -1 |
GET /pro_asphalts GET /pro_asphalts.json | def index
@q = ProAsphalt.ransack(params[:q])
@pro_asphalts = policy_scope(@q.result.order(day: :desc).paginate(:page => params[:page], :per_page => 20))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @psa = Psa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @psa }\n end\n end",
"def index\n @site_plans = @product.site_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render js... | [
"0.6379269",
"0.6335165",
"0.62464714",
"0.62393945",
"0.6178793",
"0.61323595",
"0.6052054",
"0.60419554",
"0.6037285",
"0.5973937",
"0.5973345",
"0.59635615",
"0.5940387",
"0.59333044",
"0.59324217",
"0.5894664",
"0.5892881",
"0.5868076",
"0.585804",
"0.58449334",
"0.584257... | 0.58523124 | 19 |
GET /pro_asphalts/1 GET /pro_asphalts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @psa = Psa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @psa }\n end\n end",
"def show\n @asproduct = Asproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rend... | [
"0.66307276",
"0.6440781",
"0.64183074",
"0.63948107",
"0.6373259",
"0.6304016",
"0.62000364",
"0.6185852",
"0.6163788",
"0.61514455",
"0.6136792",
"0.6119852",
"0.6095174",
"0.6067323",
"0.60637444",
"0.6062768",
"0.6060332",
"0.6047385",
"0.6044225",
"0.60409296",
"0.602243... | 0.0 | -1 |
POST /pro_asphalts POST /pro_asphalts.json | def create
@pro_asphalt = ProAsphalt.new(pro_asphalt_params)
respond_to do |format|
if @pro_asphalt.save
format.html { redirect_to pro_asphalts_path(@pro_asphalt), notice: 'Pro asphalt was successfully created.' }
format.json { render :show, status: :created, location: @pro_asphalt }
else
format.html { render :new }
format.json { render json: @pro_asphalt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pro_asphalt_type = ProAsphaltType.new(pro_asphalt_type_params)\n\n respond_to do |format|\n if @pro_asphalt_type.save\n format.html { redirect_to @pro_asphalt_type, notice: 'Pro asphalt type was successfully created.' }\n format.json { render :show, status: :created, location... | [
"0.62469727",
"0.6104164",
"0.5992982",
"0.5991333",
"0.5924378",
"0.5784002",
"0.5672843",
"0.56616414",
"0.56147814",
"0.5579136",
"0.5576561",
"0.5573956",
"0.557165",
"0.55567193",
"0.5496198",
"0.54859376",
"0.54844826",
"0.54456675",
"0.5439304",
"0.5392716",
"0.5384893... | 0.68560326 | 0 |
PATCH/PUT /pro_asphalts/1 PATCH/PUT /pro_asphalts/1.json | def update
respond_to do |format|
if @pro_asphalt.update(pro_asphalt_params)
format.html { redirect_to pro_asphalts_path(@pro_asphalt), notice: 'Pro asphalt was successfully updated.' }
format.json { render :show, status: :ok, location: @pro_asphalt }
else
format.html { render :edit }
format.json { render json: @pro_asphalt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => ... | [
"0.64197206",
"0.6389722",
"0.6289051",
"0.62460405",
"0.6230696",
"0.622748",
"0.62242496",
"0.61871284",
"0.6154919",
"0.6154137",
"0.61442643",
"0.61331826",
"0.6088461",
"0.60534203",
"0.60404587",
"0.6039339",
"0.6038272",
"0.60241663",
"0.60094815",
"0.5997083",
"0.5992... | 0.6804847 | 0 |
DELETE /pro_asphalts/1 DELETE /pro_asphalts/1.json | def destroy
@pro_asphalt.destroy
respond_to do |format|
format.html { redirect_to pro_asphalts_url, notice: 'Pro asphalt was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @healthpro.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html ... | [
"0.7073675",
"0.6944771",
"0.69359535",
"0.69125956",
"0.6895646",
"0.68633246",
"0.68496364",
"0.6821556",
"0.6819525",
"0.6805395",
"0.6791739",
"0.67755556",
"0.67601293",
"0.675454",
"0.67471665",
"0.67424715",
"0.67424715",
"0.67424715",
"0.67424715",
"0.6740911",
"0.673... | 0.71840423 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pro_asphalt
@pro_asphalt = ProAsphalt.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 pro_asphalt_params
params.require(:pro_asphalt).permit(:province_pro_asset_id, :day, :pro_asphalt_hours, :pro_asphalt_machines_num, pro_asphalt_subs_attributes: ProAsphaltSub.attribute_names.map(&:to_sym).push(:_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 |
GEM FRIENDLY REFERENCE: GET /artists GET /artists.json | def index
if (params.has_key?(:artist))
searched_name = artist_params[:artist_name]
found = Artist.all.select{|n| n.artist_name.downcase == searched_name.downcase}
if found[0] != nil
@artists = found
else
@artists = Artist.all.reverse_order
require 'musicbrainz'
@foundArtists = MusicBrainz::Artist.search(artist_params[:artist_name])
# GEM GITHUB => https://github.com/localhots/musicbrainz
end
else
@artists = Artist.all.reverse_order
end
@artist = Artist.new
gon.next_artist_id = Artist.with_deleted.last.id + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artists\n # TODO: add param for albums and songs\n a = Artist.all\n render json: a\n end",
"def artists\n if RESPONSE.code == 200\n # Return data to page\n JSON.parse(RESPONSE.to_s)['topartists']['artist']\n else\n # print error message\n \"Error Code #{RESPONSE.code}\"\n ... | [
"0.7812069",
"0.7784614",
"0.76863056",
"0.7555241",
"0.7538351",
"0.7435646",
"0.73612255",
"0.7344018",
"0.7329503",
"0.732899",
"0.7262973",
"0.7262973",
"0.7262973",
"0.7262973",
"0.7262973",
"0.7262973",
"0.72628874",
"0.7251068",
"0.724836",
"0.7239009",
"0.7224838",
... | 0.70474195 | 26 |
GET /artists/1 GET /artists/1.json | def show
@artist = Artist.find(params[:id])
gon.artist = Artist.find(params[:id])
@artists = Artist.all
@venues = Venue.all
@concert = Concert.new
gon.sk_key = ENV['SK_API']
gon.tm_key = ENV['TM_API']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @artists = Artist.find(params[:id])\n puts @artists\n render json:@artists, status: :ok\n end",
"def artists\n # TODO: add param for albums and songs\n a = Artist.all\n render json: a\n end",
"def index\n if params[:album_id]\n @artists = Album.resolve(params[:album_id]).... | [
"0.8384725",
"0.80260485",
"0.8016215",
"0.7995721",
"0.7846519",
"0.7710554",
"0.7693747",
"0.76757026",
"0.7489406",
"0.74404496",
"0.73917294",
"0.73917294",
"0.73917294",
"0.73917294",
"0.73917294",
"0.73917294",
"0.733127",
"0.73234177",
"0.72865427",
"0.7215986",
"0.717... | 0.0 | -1 |
POST /artists POST /artists.json | def create
@artist = Artist.find_or_create_by(artist_name: artist_params[:artist_name])
@artist.update(artist_params)
gon.artist = @artist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @artist = Artist.new(params[:artist])\n\n respond_to do |format|\n if @artist.save\n format.html { redirect_to @artist, :notice => 'Artist was successfully created.' }\n format.json { render :json => @artist, :status => :created, :location => @artist }\n else\n for... | [
"0.74462026",
"0.74462026",
"0.73641914",
"0.73641914",
"0.73176426",
"0.731292",
"0.72659725",
"0.72546893",
"0.71016383",
"0.71015084",
"0.69932723",
"0.68638533",
"0.6809128",
"0.6808301",
"0.6780417",
"0.6761821",
"0.6760281",
"0.6695696",
"0.66905534",
"0.6678908",
"0.66... | 0.65347683 | 30 |
DELETE /artists/1 DELETE /artists/1.json | def destroy
@artist.destroy
respond_to do |format|
format.html { redirect_to artists_url, notice: 'Artist was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @artist = Artist.find(params[:id])\n @artist.destroy\n\n respond_to do |format|\n format.html { redirect_to artists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @artist = Artist.find(params[:id])\n @artist.destroy\n\n respond_to do |format|\n... | [
"0.7928831",
"0.7928831",
"0.79146665",
"0.7787535",
"0.77650654",
"0.7681658",
"0.7681658",
"0.7681658",
"0.7652797",
"0.76416695",
"0.75489223",
"0.7544106",
"0.75380546",
"0.7514569",
"0.74450904",
"0.74302214",
"0.7381367",
"0.73496217",
"0.7348394",
"0.71544236",
"0.7152... | 0.76563317 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_artist
@artist = Artist.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 artist_params
params.require(:artist).permit(:artist_name, :artist_image, :deleted_at, :mb_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 |
Remembers a user in the database for user in persistent sessions. | def remember
self.remember_token = User.new_token
update_attribute(:remember_digest, User.digest(remember_token))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def change_password\n @user = User.find_by_id(session[:remember_token])\n end",
"def load_user(user)\n session[:user_id] = user.id... | [
"0.6907703",
"0.6520468",
"0.6276567",
"0.6271878",
"0.6216145",
"0.619693",
"0.61958396",
"0.61565614",
"0.6154017",
"0.6150753",
"0.61354303",
"0.611746",
"0.611746",
"0.60892946",
"0.6061138",
"0.6054463",
"0.6048063",
"0.6048001",
"0.6047364",
"0.60468477",
"0.60464585",
... | 0.5833045 | 62 |
Returns true if the given token matches the digest. | def authenticated?(remember_token)
return false if remember_digest.nil?
BCrypt::Password.new(remember_digest).is_password?(remember_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n ... | [
"0.78424853",
"0.76170635",
"0.7406786",
"0.72879815",
"0.7143585",
"0.71428716",
"0.71428716",
"0.7028208",
"0.6984801",
"0.6964507",
"0.6905196",
"0.6859846",
"0.6843323",
"0.6824065",
"0.67973304",
"0.67884517",
"0.67749035",
"0.676529",
"0.6751168",
"0.67464095",
"0.67436... | 0.0 | -1 |
Returns true if the current user is reviewing the other user | def reviewing?(other_user)
reviewing.include?(other_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ever_reviewed_by?(user_id)\n\t\tself.reviews.any?{|review| review.user_id == user_id}\n\tend",
"def is_resident_review?\n user_review = self.user \n if user_review != nil\n user_review = self.user\n if user_review.is_resident_of?(self.city)\n return true \n else\n return fa... | [
"0.75062317",
"0.73316294",
"0.729414",
"0.71572375",
"0.7104558",
"0.7097598",
"0.7087988",
"0.707417",
"0.70628905",
"0.7010617",
"0.69329786",
"0.6839503",
"0.68301105",
"0.6784396",
"0.678437",
"0.67695665",
"0.67623967",
"0.67427266",
"0.6731118",
"0.6730113",
"0.6712953... | 0.8577895 | 0 |
GET /veiculo_motoristas GET /veiculo_motoristas.json | def index
v = params[:id]
@veiculo = Veiculo.find(v)
@veiculo_motoristas = VeiculoMotorista.where('veiculo_id=?',@veiculo.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @motoristas = Motorista.all\n end",
"def index\n @motorista = Motoristum.all\n end",
"def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end",
"def index\n @menc... | [
"0.715657",
"0.711209",
"0.6496485",
"0.64221895",
"0.64105785",
"0.6409307",
"0.63932294",
"0.6362864",
"0.6319858",
"0.62985593",
"0.62590164",
"0.6215608",
"0.6198035",
"0.6166453",
"0.6165283",
"0.6145858",
"0.61431426",
"0.6131027",
"0.6123103",
"0.6109765",
"0.6093716",... | 0.6963104 | 2 |
GET /veiculo_motoristas/1 GET /veiculo_motoristas/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @motorista = Motoristum.all\n end",
"def index\n @motoristas = Motorista.all\n end",
"def index\n v = params[:id]\n @veiculo = Veiculo.find(v)\n @veiculo_motoristas = VeiculoMotorista.where('veiculo_id=?',@veiculo.id)\n end",
"def set_motorista\n @motorista = Motorista.find... | [
"0.7034552",
"0.7017888",
"0.69255054",
"0.6478721",
"0.6391567",
"0.63090926",
"0.6297477",
"0.6290496",
"0.6276555",
"0.62532",
"0.6244004",
"0.61952424",
"0.61941785",
"0.61802965",
"0.61505544",
"0.61133623",
"0.6110617",
"0.6090354",
"0.6082925",
"0.6052975",
"0.60286653... | 0.0 | -1 |
POST /veiculo_motoristas POST /veiculo_motoristas.json | def create
@veiculo_motorista = VeiculoMotorista.new(veiculo_motorista_params)
respond_to do |format|
if @veiculo_motorista.save
format.html { redirect_to @veiculo_motorista, notice: 'Veiculo motorista was successfully created.' }
format.json { render :show, status: :created, location: @veiculo_motorista }
else
format.html { render :new }
format.json { render json: @veiculo_motorista.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @motorista = Motorista.new(motorista_params)\n\n respond_to do |format|\n if @motorista.save\n format.html { redirect_to @motorista, notice: 'Motorista was successfully created.' }\n format.json { render :show, status: :created, location: @motorista }\n else\n form... | [
"0.72027105",
"0.7016685",
"0.6976601",
"0.6560173",
"0.6491024",
"0.64376765",
"0.6427915",
"0.6420078",
"0.6240106",
"0.60365313",
"0.5992116",
"0.598732",
"0.59785324",
"0.59689844",
"0.59529907",
"0.59221596",
"0.5910748",
"0.588988",
"0.58633775",
"0.58596474",
"0.585471... | 0.7000522 | 2 |
PATCH/PUT /veiculo_motoristas/1 PATCH/PUT /veiculo_motoristas/1.json | def update
respond_to do |format|
if @veiculo_motorista.update(veiculo_motorista_params)
format.html { redirect_to @veiculo_motorista, notice: 'Veiculo motorista was successfully updated.' }
format.json { render :show, status: :ok, location: @veiculo_motorista }
else
format.html { render :edit }
format.json { render json: @veiculo_motorista.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @motorista.update(motorista_params)\n format.html { redirect_to @motorista, notice: 'Motorista was successfully updated.' }\n format.json { render :show, status: :ok, location: @motorista }\n else\n format.html { render :edit }\n for... | [
"0.6697531",
"0.64190316",
"0.6380966",
"0.63192177",
"0.62720495",
"0.61819303",
"0.61576074",
"0.61467355",
"0.6096365",
"0.6069864",
"0.6065608",
"0.60617673",
"0.60515505",
"0.6050087",
"0.6042295",
"0.60370535",
"0.60250884",
"0.6024544",
"0.6024063",
"0.6011435",
"0.600... | 0.6876356 | 0 |
DELETE /veiculo_motoristas/1 DELETE /veiculo_motoristas/1.json | def destroy
@veiculo_motorista.destroy
respond_to do |format|
format.html { redirect_to veiculo_motoristas_url, notice: 'Veiculo motorista was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @motorista.destroy\n respond_to do |format|\n format.html { redirect_to motoristas_url, notice: 'Motorista was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @motoristum.destroy\n respond_to do |format|\n format.html { redir... | [
"0.7443823",
"0.7443297",
"0.72892845",
"0.7154575",
"0.71507543",
"0.7120174",
"0.71023834",
"0.70814943",
"0.70771194",
"0.7076857",
"0.7065652",
"0.7059782",
"0.70542973",
"0.70409906",
"0.7026376",
"0.6993293",
"0.69803995",
"0.6974884",
"0.69677144",
"0.69633025",
"0.694... | 0.7515056 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.