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 |
|---|---|---|---|---|---|---|
image methods for easy api calls | def mobile_poster_image_url
self.show_images.poster.any? ? self.show_images.poster.first.avatar.url(:mobile_poster) : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image\n\n end",
"def image; end",
"def image\n end",
"def image\n end",
"def images; end",
"def image\n end",
"def image\n end",
"def images\n end",
"def image\n #__log_activity\n # __debug_route\n response = Faraday.get(params[:url]) # TODO: caching\n image_data = B... | [
"0.7716205",
"0.7702462",
"0.7645807",
"0.7645807",
"0.7557929",
"0.7446073",
"0.7446073",
"0.74273276",
"0.70037615",
"0.6795638",
"0.672484",
"0.66604847",
"0.6659207",
"0.66583914",
"0.6654267",
"0.66532654",
"0.6641657",
"0.66397923",
"0.6634986",
"0.6625283",
"0.6625004"... | 0.0 | -1 |
rocks and gold, something like this: [ ['R', 'R', 'G'], ['R', 'G', 'R'], ['R', 'G', 'G'] ] | def pick_up_the_gold(grid)
gold_sachel = []
x, y = 0, 0
while y < grid.length
current_sq = grid[y][x]
if current_sq == 'G'
gold_sachel.push 'G'
grid[y][x] = 'R'
end
if x == (grid[y].length - 1)
x = 0
y += 1
else
x += 1
end
end
raise "Oops, looks like we missed one" if grid.include? 'G'
puts "You picked up #{gold_sachel.count} pieces of gold!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def second_challenge\n groceries = {\n dairy: [\"milk\", \"yogurt\", \"cheese\"],\n vegetable: [\"carrots\", \"broccoli\", \"cucumbers\"],\n meat: [\"chicken\", \"steak\", \"salmon\"],\n grains: [\"rice\", \"pasta\"]\n }\n\n groceries.values.flatten\n\n\nend",
"def skittle_combos(skittles)\n array = ... | [
"0.629131",
"0.6111802",
"0.60970443",
"0.60818183",
"0.6028822",
"0.5893935",
"0.58764905",
"0.58362335",
"0.5831098",
"0.5789968",
"0.57704693",
"0.5763978",
"0.5763026",
"0.5753572",
"0.5745396",
"0.57448995",
"0.57391024",
"0.5734377",
"0.5733186",
"0.5729222",
"0.5716541... | 0.5610471 | 32 |
Push a record onto the records | def << (record)
raise "Obj should be a Record" unless record.class == Record
@entries << record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def <<(record)\n @records << record\n end",
"def <<(record)\n @records << record\n end",
"def addRecord(rec); @records[rec.key] = rec end",
"def push_record(record)\n params = TogglRecord.new(record, config).push\n record[:id]\n end",
"def addRecords(recs); recs.each { |r| addR... | [
"0.7778802",
"0.7778802",
"0.7679838",
"0.74537224",
"0.7308447",
"0.723168",
"0.71305203",
"0.71200836",
"0.7061831",
"0.69934124",
"0.6942726",
"0.6927854",
"0.6855094",
"0.66557133",
"0.66419643",
"0.656446",
"0.64771014",
"0.6455133",
"0.64538145",
"0.63954437",
"0.638989... | 0.7076533 | 8 |
Sorts the records by DOB, ASC | def sort_by_dob!
@entries.sort! { |a,b| a.dob <=> b.dob }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n # @birthdays = Birthday.order(month: :asc)\n # ここでまた @birthdays を order するけど、普通のルビーコードで\n # @birthdays.each do 〜 みたいな文\n # @birthdays = Birthday.order(day: :asc).reorder(month: :asc)\n # @birthdays = Birthday.order(month: :asc)\n @birthdays = Birthday.order(month: :asc, day: :asc)\n\n... | [
"0.63921434",
"0.61869264",
"0.61537546",
"0.6141651",
"0.6085773",
"0.60281",
"0.600521",
"0.60012716",
"0.59593576",
"0.59437484",
"0.59166485",
"0.5883935",
"0.58783615",
"0.5875312",
"0.58738977",
"0.58227134",
"0.57979995",
"0.5793642",
"0.5790312",
"0.57856715",
"0.5783... | 0.83023405 | 0 |
Sorts the records by LN, DESC | def sort_by_ln!
@entries.sort! { |a,b| a.ln <=> b.ln }
@entries.reverse!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_entries; end",
"def ja_sort\n [{ :created_at => :desc }]\n end",
"def sort_by_sex_then_ln!\n @entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] }\n end",
"def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data... | [
"0.62844336",
"0.6161671",
"0.61378556",
"0.61363196",
"0.5888436",
"0.5872766",
"0.584869",
"0.579978",
"0.5787683",
"0.5783197",
"0.5757387",
"0.5727465",
"0.5717788",
"0.5716454",
"0.57148445",
"0.57148445",
"0.5711713",
"0.57022476",
"0.56722003",
"0.5665171",
"0.56640685... | 0.7389627 | 0 |
Sorts the records by sex (female > male), then by ln, ASC | def sort_by_sex_then_ln!
@entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_ln!\n @entries.sort! { |a,b| a.ln <=> b.ln }\n @entries.reverse!\n end",
"def sort_by_gender_then_last_name \n sorted = final_array.sort_by {|k,v| [k[:gender], k[:last_name]] }\n hash_values = sorted.map {|element| element.values}\n with_line_breaks = add_line_breaks(hash_values)\n with_li... | [
"0.6245048",
"0.61611944",
"0.6150194",
"0.6099462",
"0.6033164",
"0.5955961",
"0.5931184",
"0.5784812",
"0.57658637",
"0.5750996",
"0.57198244",
"0.5713558",
"0.57113975",
"0.571085",
"0.56654686",
"0.56370765",
"0.5619122",
"0.56006646",
"0.5599366",
"0.5567647",
"0.5562838... | 0.8604584 | 0 |
Formats the contents of the data structure to be output to the screen. | def to_s
lines = []
@entries.each do |e|
# I would prefer to use e.dob.strftime("%m/%d/%Y") here, but can't find an
# easy way to ditch the leading zeros for months/days < 10...so we have this ugliness
lines << %{#{e.ln} #{e.fn} #{e.sex} #{e.dob.month}/#{e.dob.day}/#{e.dob.year} #{e.fav_color}\n}
end
lines.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format\n output = @sum.to_s\n\n if @verbose\n @raw.each do |h|\n @display << \"#{h.keys[0]}:#{h.values[0]} \"\n end\n\n output << \" -- #{@display.strip}\"\n end\n\n output\n end",
"def format data\n data\n end",
"def format\n text = \"[#{na... | [
"0.65562123",
"0.65229595",
"0.6448225",
"0.6366006",
"0.6366006",
"0.6366006",
"0.6366006",
"0.6366006",
"0.6366006",
"0.6366006",
"0.6366006",
"0.63358295",
"0.6300172",
"0.6289767",
"0.6289767",
"0.6289767",
"0.6286952",
"0.6276543",
"0.62709177",
"0.62561464",
"0.62172157... | 0.0 | -1 |
Returns a symbol got from final section (after the last ::) of the given class name. If no :: found the full name is returned | def class_moniker
self.class.moniker
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name\n self.fullname[/\\A(.*)([\\.\\#])([^\\.\\#]+)\\z/, 1]\n end",
"def name_from_object(class_name)\n class_name.split('::').last\n end",
"def name\n klass.name.split('::').last\n end",
"def class_unqualified_name(clazz)\n name = clazz.name\n if name =~ /... | [
"0.7341725",
"0.7125613",
"0.6937897",
"0.69312894",
"0.6731252",
"0.6708073",
"0.66831684",
"0.66581696",
"0.6657768",
"0.6636355",
"0.6629037",
"0.6621426",
"0.6604565",
"0.6596603",
"0.658169",
"0.6558837",
"0.6526801",
"0.642873",
"0.6418992",
"0.63701445",
"0.6333579",
... | 0.0 | -1 |
Name of the ISO file by the given staging project tracked on openqa | def openqa_iso(project)
ending = project_iso(project)
return if ending.nil?
ending.gsub!(/.*-Build/, '')
"SLE-15-Staging:#{project.letter}-Installer-DVD-#{arch}-Build#{project.letter}.#{ending}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openqa_iso(project)\n ending = project_iso(project)\n \"SLE12-SP1-Staging:#{project.letter}-#{ending}\"\n end",
"def openqa_iso(project)\n ending = project_iso(project)\n \"SLE12-#{sp_version}-Staging:#{project.letter}-#{ending}\"\n end",
"def iso_file\n resource[:iso_file].fir... | [
"0.7687124",
"0.7661618",
"0.6555441",
"0.6227549",
"0.61912704",
"0.6129656",
"0.6069429",
"0.60249615",
"0.600626",
"0.6004811",
"0.5976688",
"0.58867466",
"0.5886088",
"0.58679813",
"0.5866906",
"0.58123213",
"0.5811506",
"0.5798067",
"0.57360667",
"0.5723885",
"0.57183987... | 0.74954957 | 2 |
Lazy loads and yields the data when evaluating | def load(serializer_instance, load_for, &block)
record = if load_for.present?
serializer_instance.object.public_send(load_for)
else
serializer_instance.object
end
BatchLoader.for(record).batch(key: cache_key(record)) do |records, loader|
data = []
records.each do |r|
value = calculate_value(r)
data << value
loader.call(r, value)
end
data = data.flatten.compact.uniq
block&.call(data)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result\n if not_already_loaded? && any_to_load?\n lazy_results.merge!(block_results)\n lazy_values.clear\n end\n lazy_results[value]\n end",
"def eval\n yield self\n end",
"def lazy\n yield\n yield\nend",
"def evaluate(&block)\n instance_eval(&block)\n ... | [
"0.6682949",
"0.65320414",
"0.61216915",
"0.6116302",
"0.60013926",
"0.59971803",
"0.59923756",
"0.5962693",
"0.5895884",
"0.5894882",
"0.5885427",
"0.5861535",
"0.5797292",
"0.57912785",
"0.57319814",
"0.57319814",
"0.57319814",
"0.56762177",
"0.5659655",
"0.56537145",
"0.56... | 0.0 | -1 |
Public: Returns if the high score podium, and high score list, should be displayed to the user. | def scores_enabled?
session[:show_scores] != false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def judge_scores?\n standard_skill_score_entries.any?\n end",
"def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end",
"def enough_scores?\n self.scores.count > 2 \n end",
"def has_scores?\n @user.personal_scores.published.any?\n end",
"def overall_draw?(score)\... | [
"0.66911125",
"0.6429269",
"0.6407012",
"0.6293705",
"0.6146136",
"0.60757124",
"0.6049819",
"0.59835166",
"0.59547895",
"0.59404993",
"0.5918795",
"0.59092087",
"0.5896555",
"0.587732",
"0.5867047",
"0.5859357",
"0.58472526",
"0.5832752",
"0.5822404",
"0.5817523",
"0.5796817... | 0.6657101 | 1 |
Shows or hides scores depending on the +score+ query param. | def enable_or_disable_scores
if params[:scores].present?
session[:show_scores] = ! SCORE_OFF_VALUES.include?(params[:scores])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_score score, rank\r\n\r\n end",
"def display_score score, rank\r\n if score == nil\r\n puts \"There is no #{rank} score\"\r\n else\r\n puts \"The #{rank} score is #{score}\"\r\n end\r\n end",
"def display_score score, rank\n\tif score == nil\n\t return\n\tend\n\t\n\tif rank > ... | [
"0.6743665",
"0.650048",
"0.648773",
"0.6368426",
"0.6328055",
"0.6276015",
"0.6263041",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.62412524",
"0.60781765",
"0.6073044",
"0.606... | 0.66982275 | 1 |
TODO: deserves to be moved elswhere | def format_lines(lines)
prev = lines[0]
slices = lines.slice_before do |e|
(prev + 1 != e).tap { prev = e }
end
slices.map { |slice_first, *, slice_last| slice_last ? (slice_first..slice_last) : slice_first }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def weber; end",
"def refutal()\n end",
"def wrapper; end",
"def suivre; end",
"def isolated; e... | [
"0.77427375",
"0.6600724",
"0.65973717",
"0.65973717",
"0.65973717",
"0.65973717",
"0.6567165",
"0.6323523",
"0.6323523",
"0.63145137",
"0.631329",
"0.6142819",
"0.6112921",
"0.60382855",
"0.60382855",
"0.6016837",
"0.5996183",
"0.5947805",
"0.5947805",
"0.59409153",
"0.59409... | 0.0 | -1 |
TODO: can be updated to read directly from `run.nodes` instead of passing `undercover_report` | def warnings_to_annotations
results = @undercover_report.flagged_results
log "posting warnings: #{results}"
results.map do |result|
# TODO: duplicates pronto-undercover logic, move to Undercover::Result
lines = result.coverage.map { |ln, *| ln if result.uncovered?(ln) }.compact.uniq
message = "#{result.node.human_name.capitalize} `#{result.node.name}` is missing" \
" coverage for line#{'s' if lines.size > 1} #{format_lines(lines).join(',')}" \
" (node coverage: #{result.coverage_f})."
lines_missing_branch_cov = result.coverage.map do |ln, _block, _branch, cov|
ln if cov&.zero?
end.compact.uniq
if lines_missing_branch_cov.any?
message += "\nMissing branch coverage found in line#{'s' if lines_missing_branch_cov.size > 1} " \
"#{format_lines(lines_missing_branch_cov).join(',')}."
end
{
path: result.file_path,
start_line: result.first_line,
end_line: result.last_line,
annotation_level: "warning",
title: "Untested #{result.node.human_name}",
message:,
raw_details: result.pretty_print
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_moab_nodes\n self.report('moab_nodes_report')\n end",
"def parse_output(_report, _result, _targets); end",
"def get_test_run_summary_report(test_report, test_summary)\n file_data = test_report\n file_lines = file_data.split(\"\\n\")\n\n=begin\n #Remove the duplicate headings\n title ... | [
"0.5779997",
"0.5373228",
"0.52066165",
"0.5200856",
"0.514599",
"0.5082208",
"0.50282973",
"0.49819762",
"0.4909435",
"0.49082386",
"0.49082386",
"0.49082386",
"0.49019468",
"0.49018583",
"0.48720074",
"0.48349997",
"0.48325175",
"0.48231134",
"0.4823081",
"0.47887096",
"0.4... | 0.50412476 | 6 |
=begin Here is another solution I developed, it is almost identical to my original solution just that we rearrange the string by splitting it into an array of characters, then we use the rotate method to shift every element 1 index position to the left. Rotate with no number passed in is the same as rotate(1) so the element in position 1 becomes the first element, and the first element becomes the last element, we join this back then add "ay" to the end. =end | def pig_it_ms_two(str)
pig = []
str.split.each do |w|
pig << w.chars.rotate.join + "ay" if w =~ /\w/
pig << w if w =~ /\W/
end
pig.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_string(string)\n return nil if string.empty?\n array = string.split('')\n result = array[1..-1] + [array[0]]\n result.join # to convert array back to 'string'\nend",
"def rotate_string(string)\n array = string.split('')\n rotate_array(array).join\nend",
"def rotate_stri... | [
"0.8420863",
"0.83757365",
"0.8354062",
"0.8354062",
"0.8325349",
"0.82930464",
"0.82857203",
"0.8282977",
"0.8261854",
"0.8261854",
"0.8261854",
"0.8261854",
"0.8261854",
"0.8257434",
"0.82502234",
"0.82138014",
"0.8213407",
"0.8213407",
"0.8213407",
"0.7922199",
"0.77572376... | 0.6484085 | 94 |
=begin Here is a better solution, taken from a Codewars user. It is the highest clever rated solution on Codewars. 1) gsub returns a copy of the given string with all (global) occurrences of the pattern substituted for the second argument. 2) (\w) captures the first letter of every word, this is the first capture group. 3) (\w+) captures the rest of the letters of every word, this is the second capture group. 4) '\2\1ay' essentially says put the capture group 1 (first letter) after capture group 2 (the rest of letters) and after capture group 1 (first letter), put ay. This rearranges the string. Single quotation marks '' must be used instead of "" to make this substitution work. =end | def pig_it(str)
str.gsub(/(\w)(\w+)*/, '\2\1ay')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pig_it text\n text.gsub(/(\\w)(\\w+)*/, '\\2\\1ay')\nend",
"def pig_it text\n text.gsub(/(\\w)(\\w+)*/, '\\2\\1ay')\nend",
"def kacokadekame(word)\n 'ka' + word.gsub(/([aeiouy])(?=[^aeiouy])/i, '\\1ka')\nend",
"def swap(string)\n array = string.scan(/\\w+/)\n array.map! { |word| word.scan(/(.)/) }\n... | [
"0.7943445",
"0.7943445",
"0.72666585",
"0.7099973",
"0.70572203",
"0.6905169",
"0.6904118",
"0.6852544",
"0.6840252",
"0.6836425",
"0.681228",
"0.67991066",
"0.6756529",
"0.67484653",
"0.6705733",
"0.66861564",
"0.6662058",
"0.6649415",
"0.6639252",
"0.6636886",
"0.6636351",... | 0.8108457 | 0 |
FIXME! how to get access to the controller? | def controller
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller\n @controller\n end",
"def controller(controller); end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def contr... | [
"0.79640883",
"0.7880399",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.77943367",
"0.7691605",
"0.7683049",
"0.7621862",
"0.75697213",
"0.7569223",
"0.7551087",
"0.75317776",
"0.7479696",
"0.... | 0.778965 | 13 |
FIXME remove ActionController::Request dependency | def generic_url_rewriter
env = Request.env_for('http://localhost')
UrlRewriter.new(ActionController::Request.new(env), {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def set_request; end",
"def request; return @request end",
"def call(... | [
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.7229971",
"0.71342325",
"0.70124894",
"0.699485",
"0.69773716",
"0.69773716",
"0.69773716",
"0.6955372",
"0.69097394",
"0.69030946",
"0.6860935... | 0.0 | -1 |
send message about record change to all subscribers of this record | def publish_record(record)
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}")
time_now = Time.now.to_f
scrub_time = time_now - 24.hours.to_f
message = {
record_type: record.class.to_s,
id: record.id,
updated_at: record.updated_at
}
message[:destroyed] = true if record.destroyed?
Rails.logger.debug "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
Rails.logger.debug "========================================== SUBSCRIBERS ================ #{subscribers}"
Rails.logger.debug "=========================================== SUBSCRIBERS SIZE =============== #{subscribers.size}"
# can only trigger to max 10 channels at once on pusher
subscribers.each_slice(10) do |slice|
Rails.logger.debug "========================================================== EACH SLICE !"
Rails.logger.debug "=============================================SLICE============= #{slice}"
Rails.logger.debug "=============================================SLICE SIZE============= #{slice.size}"
channel_array = []
slice.each do |session_id, last_requested|
if last_requested.to_f < scrub_time
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}", session_id)
next
end
Rails.logger.debug "========================================================== SESSION ID : #{session_id} !"
Rails.logger.debug "========================================================== RECORD CLASS : #{record.class} !"
Rails.logger.debug "========================================================== RECORD ID : #{record.id} !"
channel_array << "hyper-record-update-channel-#{session_id}"
end
Rails.logger.debug "========================================================== CHANNEL ARRAY #{channel_array} !"
if channel_array.size > 0
if Hyperloop.resource_transport == :pusher
_pusher_client.trigger_async(channel_array, 'update', message)
Rails.logger.debug "========================================================== PUSHER #{channel_array} !"
elsif Hyperloop.resource_transport == :action_cable
channel_array.each do |channel|
Rails.logger.debug "========================================================== BROADCAST #{channel} !"
ActionCable.server.broadcast(channel, message)
end
end
end
end
Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end",
"def send_update\n changed\n notify_observers(self)\n end",
"def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end",
"def pub_sub_record(record)\n subscribe_record(record)\n p... | [
"0.70791966",
"0.666697",
"0.6509179",
"0.62848705",
"0.62453055",
"0.6182195",
"0.61139494",
"0.60994095",
"0.60753155",
"0.6047617",
"0.603326",
"0.59629095",
"0.59436476",
"0.5918301",
"0.5908037",
"0.5871527",
"0.58531755",
"0.58511245",
"0.5805142",
"0.5795377",
"0.57846... | 0.62218195 | 5 |
send message about relation change to all subscribers of this record | def publish_relation(base_record, relation_name, record = nil)
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}")
time_now = Time.now.to_f
scrub_time = time_now - 24.hours.to_f
message = {
record_type: base_record.class.to_s,
id: base_record.id,
updated_at: base_record.updated_at,
relation: relation_name
}
if record
message[:cause] = {}
message[:cause][:record_type] = record.class.to_s
message[:cause][:id] = record.id
message[:cause][:updated_at] = record.updated_at
message[:cause][:destroyed] = true if record.destroyed?
end
subscribers.each_slice(10) do |slice|
channel_array = []
slice.each do |session_id, last_requested|
if last_requested.to_f < scrub_time
Hyperloop.redis_instance.hdel("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id)
next
end
channel_array << "hyper-record-update-channel-#{session_id}"
end
if Hyperloop.resource_transport == :pusher
_pusher_client.trigger_async(channel_array, 'update', message)
elsif Hyperloop.resource_transport == :action_cable
channel_array.each do |channel|
ActionCable.server.broadcast(channel, message)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end",
"def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end",
"def notify_subscribers\n NotificationSubscription.notify(self)\n end",
"def pub_sub_relation(relation, base_record, relation_name, causing_record = ... | [
"0.66124755",
"0.61680496",
"0.61637944",
"0.61364126",
"0.61346143",
"0.60502297",
"0.6005926",
"0.5998482",
"0.5987814",
"0.5902612",
"0.58898187",
"0.5778486",
"0.57216686",
"0.57216686",
"0.57216686",
"0.5693455",
"0.56650513",
"0.56645656",
"0.566012",
"0.5646806",
"0.56... | 0.57590413 | 12 |
send message to notify clients that they should call the rest_class_method again | def publish_rest_class_method(record_class, rest_class_method_name)
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
time_now = Time.now.to_f
scrub_time = time_now - 24.hours.to_f
message = {
record_type: record_class.to_s,
rest_class_method: rest_class_method_name
}
subscribers.each_slice(10) do |slice|
channel_array = []
slice.each do |session_id, last_requested|
if last_requested.to_f < scrub_time
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id)
next
end
channel_array << "hyper-record-update-channel-#{session_id}"
end
if Hyperloop.resource_transport == :pusher
_pusher_client.trigger_async(channel_array, 'update', message)
elsif Hyperloop.resource_transport == :action_cable
channel_array.each do |channel|
ActionCable.server.broadcast(channel, message)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end",
"def subscribe_rest_class_method(record_class, rest_class_method_name)\n retu... | [
"0.6370434",
"0.61913794",
"0.61048335",
"0.5896762",
"0.58278847",
"0.5817641",
"0.5775535",
"0.5696426",
"0.5692046",
"0.55505234",
"0.55505234",
"0.5517397",
"0.55170935",
"0.55004454",
"0.54606736",
"0.54507464",
"0.5434953",
"0.5429647",
"0.54267377",
"0.5408788",
"0.538... | 0.6812041 | 0 |
send message to notify clients that they should call the rest_method again | def publish_rest_method(record, rest_method_name)
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}")
time_now = Time.now.to_f
scrub_time = time_now - 24.hours.to_f
message = {
record_type: record.class.to_s,
id: record.id,
rest_method: rest_method_name
}
subscribers.each_slice(10) do |slice|
channel_array = []
slice.each do |session_id, last_requested|
if last_requested.to_f < scrub_time
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id)
next
end
channel_array << "hyper-record-update-channel-#{session_id}"
end
if Hyperloop.resource_transport == :pusher
_pusher_client.trigger_async(channel_array, 'update', message)
elsif Hyperloop.resource_transport == :action_cable
channel_array.each do |channel|
ActionCable.server.broadcast(channel, message)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call\n context.response ||= notify\n end",
"def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end",
"def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end",
"def publi... | [
"0.61973923",
"0.6140131",
"0.5967415",
"0.5911174",
"0.5888645",
"0.5872892",
"0.5854032",
"0.5854032",
"0.581641",
"0.581641",
"0.5782182",
"0.57259923",
"0.5702955",
"0.5629774",
"0.55910534",
"0.5578763",
"0.55683357",
"0.5568055",
"0.5568055",
"0.5555822",
"0.5528968",
... | 0.6347894 | 0 |
send message about scope change to all subscribers | def publish_scope(record_class, scope_name)
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__scope__#{scope_name}")
time_now = Time.now.to_f
scrub_time = time_now - 24.hours.to_f
message = {
record_type: record_class.to_s,
scope: scope_name
}
subscribers.each_slice(10) do |slice|
channel_array = []
slice.each do |session_id, last_requested|
if last_requested.to_f < scrub_time
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__scope__#{scope_name}", session_id)
next
end
channel_array << "hyper-record-update-channel-#{session_id}"
end
if Hyperloop.resource_transport == :pusher
_pusher_client.trigger_async(channel_array, 'update', message)
elsif Hyperloop.resource_transport == :action_cable
channel_array.each do |channel|
ActionCable.server.broadcast(channel, message)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end",
"def notification_recipient_scope=(value)\n @notification_recipient_scope = value\n end",
"def subscribed; end",
"def send_update\n changed\n notify_observers(self)\n end",
"def subscribed\n ... | [
"0.6172533",
"0.6017756",
"0.58801055",
"0.57497996",
"0.56288785",
"0.56122017",
"0.56122017",
"0.56122017",
"0.5602712",
"0.560242",
"0.5525237",
"0.55160236",
"0.5479672",
"0.54576564",
"0.54550016",
"0.54522467",
"0.5431061",
"0.54008865",
"0.5395308",
"0.5381413",
"0.538... | 0.6065538 | 1 |
subscribe to record changes | def subscribe_record(record)
return unless session.id
Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pub_sub_record(record)\n subscribe_record(record)\n publish_record(record)\n end",
"def set_record_updates_event(record)\n # Decide if this is a new or updated record. Check both id_changed? and save_change_to_id? since we can't be sure\n # if we'll be in an after_save or after_commi... | [
"0.66672933",
"0.64204484",
"0.63560516",
"0.63188434",
"0.63057363",
"0.60260856",
"0.6025094",
"0.60176605",
"0.59979624",
"0.59496295",
"0.59261155",
"0.5910179",
"0.5892779",
"0.5877025",
"0.58698833",
"0.5866101",
"0.58280426",
"0.58155584",
"0.578312",
"0.5760717",
"0.5... | 0.67444456 | 0 |
subscribe to relation changes | def subscribe_relation(relation, base_record = nil, relation_name = nil)
return unless session.id
time_now = Time.now.to_f.to_s
session_id = session.id.to_s
Hyperloop.redis_instance.pipelined do
if relation.is_a?(Enumerable)
# has_many
relation.each do |record|
Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}", session_id, time_now)
end
elsif !relation.nil?
# has_one, belongs_to
Hyperloop.redis_instance.hset("HRPS__#{relation.class}__#{relation.id}", session_id, time_now)
end
Hyperloop.redis_instance.hset("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id, time_now) if base_record && relation_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribed; end",
"def subscribed # :doc:\n # Override in subclasses\n end",
"def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)\n subscribe_relation(relation, base_record, relation_name)\n publish_relation(base_record, relation_name, causing_reco... | [
"0.6452602",
"0.63099724",
"0.6271999",
"0.62322664",
"0.60561633",
"0.60561633",
"0.60561633",
"0.59896386",
"0.5831739",
"0.57834697",
"0.57805717",
"0.57313323",
"0.5665741",
"0.5652396",
"0.562503",
"0.5591842",
"0.55822545",
"0.5582072",
"0.55687624",
"0.5521885",
"0.549... | 0.60393786 | 7 |
subscribe to rest_class_method updates | def subscribe_rest_class_method(record_class, rest_class_method_name)
return unless session.id
time_now = Time.now.to_f.to_s
session_id = session.id.to_s
Hyperloop.redis_instance.pipelined do
Hyperloop.redis_instance.hset("HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}", session_id, time_now)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end",
"def publish_rest_class_method(record_class, rest_class_method_name)\n subscr... | [
"0.72033644",
"0.69221956",
"0.67598283",
"0.6544552",
"0.64317316",
"0.62116086",
"0.6026355",
"0.5926975",
"0.5906476",
"0.5815818",
"0.579933",
"0.5780975",
"0.5679477",
"0.5677518",
"0.5677518",
"0.5677518",
"0.5666928",
"0.56605464",
"0.5579463",
"0.5573429",
"0.5549983"... | 0.68422437 | 2 |
subscribe to rest_method updates | def subscribe_rest_method(record, rest_method_name)
return unless session.id
time_now = Time.now.to_f.to_s
session_id = session.id.to_s
Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id, time_now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end",
"def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{reco... | [
"0.7105133",
"0.6579582",
"0.63768786",
"0.6216438",
"0.61687917",
"0.6116977",
"0.6067221",
"0.60581565",
"0.59867567",
"0.593846",
"0.59278405",
"0.59278405",
"0.59278405",
"0.5892552",
"0.5880831",
"0.5803589",
"0.5726174",
"0.56889856",
"0.5674444",
"0.56697875",
"0.56413... | 0.66870373 | 1 |
subscribe to scope updates | def subscribe_scope(collection, record_class = nil, scope_name = nil)
return unless session.id
time_now = Time.now.to_f.to_s
session_id = session.id.to_s
Hyperloop.redis_instance.pipelined do
if collection.is_a?(Enumerable)
collection.each do |record|
Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}", session_id, time_now)
end
end
Hyperloop.redis_instance.hset("HRPS__#{record_class}__scope__#{scope_name}", session_id, time_now) if record_class && scope_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribed; end",
"def send_update\n changed\n notify_observers(self)\n end",
"def subscribe\n self.subscribed = true\n end",
"def scopeChanged\n pp [:got_scopeChanged] if $DEBUG\n end",
"def subscribe!\n # TODO: Implement\n end",
"def subscribed # :doc:\n # Override i... | [
"0.63665754",
"0.6141811",
"0.60926044",
"0.60675323",
"0.60510194",
"0.59879136",
"0.59664476",
"0.59514904",
"0.59514904",
"0.59514904",
"0.5779719",
"0.5707332",
"0.56540954",
"0.5653643",
"0.56420255",
"0.5630628",
"0.5593789",
"0.55473745",
"0.55442375",
"0.5535873",
"0.... | 0.52470285 | 44 |
subscribe to record and then publish | def pub_sub_record(record)
subscribe_record(record)
publish_record(record)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe!\n # TODO: Implement\n end",
"def subscribe_record(record)\n return unless session.id\n Hyperloop.redis_instance.hset \"HRPS__#{record.class}__#{record.id}\", session.id.to_s, Time.now.to_f.to_s\n end",
"def subscribe\n \nend",
"def publish_record(record)\n subscr... | [
"0.7155365",
"0.7118702",
"0.6906086",
"0.68943745",
"0.6888428",
"0.6870245",
"0.67870426",
"0.66193604",
"0.65513426",
"0.6480246",
"0.64794236",
"0.6462708",
"0.645849",
"0.6396674",
"0.627759",
"0.6269025",
"0.6254639",
"0.62454885",
"0.6225504",
"0.6210253",
"0.6206394",... | 0.84695905 | 0 |
subscribe to relation changes and then publish them | def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
subscribe_relation(relation, base_record, relation_name)
publish_relation(base_record, relation_name, causing_record)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribed; end",
"def subscribe\n self.subscribed = true\n end",
"def subscribed # :doc:\n # Override in subclasses\n end",
"def subscribe!\n # TODO: Implement\n end",
"def subscriptions; end",
"def subscriptions; end",
"def subscriptions; end",
"def subscribed\n super... | [
"0.6788774",
"0.6597455",
"0.6526561",
"0.62998605",
"0.62750715",
"0.62750715",
"0.62750715",
"0.61798525",
"0.6133517",
"0.6056338",
"0.5970647",
"0.590864",
"0.5888758",
"0.5885154",
"0.58544546",
"0.58249015",
"0.58121973",
"0.5762711",
"0.572511",
"0.57030565",
"0.569744... | 0.69037145 | 0 |
subscribe to rest_class_method and then send message to notify clients that they should call the rest_class_method again | def pub_sub_rest_class_method(record_class, rest_class_method_name)
subscribe_rest_class_method(record_class, rest_class_method_name)
publish_rest_class_method(record_class, rest_class_method_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n recor... | [
"0.7280258",
"0.701402",
"0.69165057",
"0.66378623",
"0.65532345",
"0.6181606",
"0.61627847",
"0.6101013",
"0.5899211",
"0.5891438",
"0.5869018",
"0.57853174",
"0.5780493",
"0.57291096",
"0.5660718",
"0.5625182",
"0.56130886",
"0.5559812",
"0.5550139",
"0.55158293",
"0.551422... | 0.74487114 | 0 |
subscribe to rest_method and then send message to notify clients that they should call the rest_method again | def pub_sub_rest_method(record, rest_method_name)
subscribe_rest_method(record, rest_method_name)
publish_rest_method(record, rest_method_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.c... | [
"0.6859852",
"0.67546505",
"0.6643123",
"0.65063757",
"0.6396501",
"0.6371607",
"0.62836903",
"0.626599",
"0.6175847",
"0.60430044",
"0.6018183",
"0.5981468",
"0.5972004",
"0.5847349",
"0.58340645",
"0.5801273",
"0.578398",
"0.57807577",
"0.56387025",
"0.5578157",
"0.5568382"... | 0.7372814 | 0 |
subscribe to scope changes and send message about scope change to all subscribers | def pub_sub_scope(collection, record_class, scope_name)
subscribe_scope(collection, record_class, scope_name)
publish_scope(record_class, scope_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish_scope(record_class, scope_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__scope__#{scope_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n scope: sco... | [
"0.6338729",
"0.61815774",
"0.5970382",
"0.5954858",
"0.58622986",
"0.58119786",
"0.58119786",
"0.58119786",
"0.57888234",
"0.57743937",
"0.5731783",
"0.5716293",
"0.56978613",
"0.56176114",
"0.56116176",
"0.5606647",
"0.5595493",
"0.5589765",
"0.5569349",
"0.5501265",
"0.546... | 0.59766364 | 2 |
Use ODBC format, not Microsoft format, as the ODBC layer does some translation, but allow for millisecond precision. | def default_timestamp_format
"{ts '%Y-%m-%d %H:%M:%S%N'}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quoted_date(value)\n @logger.unknown(\"ODBCAdapter#quoted_date (MS SQL)>\") if @trace\n @logger.unknown(\"args=[#{value}]\") if @trace\n # MS SQL DBTIME and DBDATE environment variables should be set to:\n # DBTIME=%d.%m.%Y %H:%M:%S\n # DBDATE=%d.%m.%Y\n if value.acts_like?(:time) # Time, Dat... | [
"0.6193917",
"0.6027293",
"0.60185945",
"0.5974096",
"0.58190393",
"0.5744007",
"0.5625299",
"0.5606582",
"0.55727845",
"0.54956925",
"0.54899985",
"0.5469331",
"0.54488885",
"0.5445127",
"0.53989637",
"0.5317874",
"0.5275467",
"0.5264983",
"0.5264983",
"0.5245957",
"0.522432... | 0.5402206 | 14 |
Use ODBC format, not Microsoft format, as the ODBC layer does some translation. | def literal_date(v)
v.strftime("{d '%Y-%m-%d'}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{... | [
"0.6067609",
"0.5955339",
"0.5916529",
"0.59145594",
"0.5631123",
"0.5609314",
"0.55505466",
"0.54980963",
"0.5419187",
"0.54061157",
"0.5389631",
"0.5345905",
"0.52913034",
"0.5215306",
"0.5214778",
"0.52143836",
"0.5112817",
"0.50917166",
"0.5089373",
"0.50670135",
"0.50471... | 0.0 | -1 |
tests whethere an integer is even or odd | def is_even?(n)
true if n%2==0 else false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd2?(int) \n if int < 0\n int = int * -1\n end\n int % 2 == 1\nend",
"def is_odd?(integer)\n integer % 2 != 0\nend",
"def is_odd?(int)\n (int % 2).abs != 0\nend",
"def is_odd?(int)\n int % 2 == 1\nend",
"def is_it_odd?(int)\n int.abs % 2 != 0\nend",
"def is_odd?(integer)\n\tinteger.abs ... | [
"0.84689146",
"0.8466157",
"0.846187",
"0.84572583",
"0.84379417",
"0.84278005",
"0.8426993",
"0.8409027",
"0.83983904",
"0.83983904",
"0.83983904",
"0.8381239",
"0.8378729",
"0.82809865",
"0.82592034",
"0.825356",
"0.8228626",
"0.8228557",
"0.81828874",
"0.8126947",
"0.81248... | 0.78785306 | 76 |
In the previous exercise, we wrote a method that emulates Enumerableeach_cons, but limited our method to handling 2 elements at a time. Enumerableeach_cons can actually handle any number of elements at a time: 1, 2, 3, or more. Update your each_cons method so it takes an argument that specifies how many elements should be processed at a time. Your method may use each, each_index, each_with_object, inject, loop, for, while, or until to iterate through the Array passed in as an argument, but must not use any other methods that iterate through an Array or any other collection. | def each_cons(arr, num_cons_elems)
num_yields = arr.size - num_cons_elems + 1
puts "arr.size = #{arr.size} num_cons_elems = #{num_cons_elems} num_yields = #{num_yields}"
num_yields.times do |index|
p *arr[index..(index + num_cons_elems - 1)]
yield(*arr[index..(index + num_cons_elems - 1)])
index += 1
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_cons(array, cons_elements)\n array.each_with_index do |value, index|\n if index <= array.size - cons_elements\n yield(value, *array[(index + 1)...(index + cons_elements)])\n end\n end\n nil\nend",
"def each_cons(array)\n array.each_with_index do |item, index|\n break if index + 1 >= ar... | [
"0.8156945",
"0.8142903",
"0.8129785",
"0.81081074",
"0.8091964",
"0.80225486",
"0.80110407",
"0.7953092",
"0.78244764",
"0.77529466",
"0.7731859",
"0.7730933",
"0.7721244",
"0.7707085",
"0.7532563",
"0.7391682",
"0.6293397",
"0.62558365",
"0.6183258",
"0.618119",
"0.6128222"... | 0.7987888 | 7 |
assert_equal( expected, actual, failure_message = nil ) String > Integer produce integer of roman String I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 IV = 4 IX = 9 XL = 40 XC = 90 CD = 400 CM = 900 | def roman_to_integer str
result = 0
idx = 0
# thousands
while true
if str[idx, 1].downcase != 'm'
break
end
result += 1000
idx += 1
end
# 900 or 400 or 500
if str[idx, 2].downcase == 'cm'
result += 900
idx += 2
elsif str[idx, 2].downcase == 'cd'
result += 400
idx += 2
elsif str[idx, 1].downcase == 'd'
result += 500
idx += 1
end
# hundreds
while true
if str[idx, 1].downcase != 'c'
break
end
result += 100
idx += 1
end
# 90 or 50 or 40
if str[idx, 2].downcase == 'xc'
result += 90
idx += 2
elsif str[idx, 2].downcase == 'xl'
result += 40
idx += 2
elsif str[idx, 1].downcase == 'l'
result += 50
idx += 1
end
# tens
while true
if str[idx, 1].downcase != 'x'
break
end
result += 10
idx += 1
end
# 9 or 4 or 5
if str[idx, 2].downcase == 'ix'
result += 9
idx += 2
elsif str[idx, 2].downcase == 'iv'
result += 4
idx += 2
elsif str[idx, 1].downcase == 'v'
result += 5
idx += 1
end
# ones
while true
if str[idx, 1].downcase != 'i'
break
end
result += 1
idx += 1
end
if idx == str.length
return result
else
puts "#{str} is not a valid roman number"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_number_true\n #Arrange\n input = '2'\n #Act\n result = @roman.is_number?(input)\n #Assert\n assert_equal(true, result)\n end",
"def test_for_bigger_numbers\n\t\tassert_equal(\"MCXCI\", roman_converter(1191))\n\t\tassert_equal(\"MLXVI\", roman_converter(1066))\n\t\tassert_equal(\"XL... | [
"0.7028638",
"0.6797572",
"0.6614056",
"0.6476273",
"0.6420921",
"0.63896435",
"0.6305983",
"0.623505",
"0.62034744",
"0.6154641",
"0.612793",
"0.612069",
"0.61133176",
"0.60989296",
"0.6058061",
"0.6017317",
"0.6004574",
"0.59982455",
"0.5955311",
"0.5943512",
"0.59403926",
... | 0.6210751 | 8 |
Copy a ActiveModel::Model errors | def copy_errors(model)
model.errors.each do |key, value|
self.errors[key] = value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_errors(source)\n source.errors.each do |key, error|\n self.errors.add(key, error)\n end\n end",
"def errors\n @errors ||= ActiveModel::Errors.new(self)\n end",
"def result_errors_to_active_model(key, result)\n unless result.success?\n if result.errors.is_a? Array\n ... | [
"0.68175197",
"0.68134886",
"0.6707112",
"0.6671951",
"0.65738714",
"0.6559467",
"0.65437853",
"0.65335274",
"0.64072406",
"0.6406935",
"0.6382663",
"0.62255937",
"0.6166828",
"0.61540055",
"0.614228",
"0.614228",
"0.6132323",
"0.61243135",
"0.6114986",
"0.6104908",
"0.609882... | 0.8457919 | 0 |
Generalizes the constructor of ActiveModel::Model to make it work with an array argument. When an array argument is passed, it calls formatted_hash method to generate a Hash and then pass it to the ActiveModel::Model constructor == Parameters: arr_or_hash:: Array or Hash of values which represents an excel column. | def initialize(arr_or_hash = {})
if arr_or_hash.is_a?(Array)
super(self.class.formatted_hash(arr_or_hash))
else
super(arr_or_hash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(arr_or_hash = {})\n self.copied_errors = ActiveModel::Errors.new(self)\n if arr_or_hash.is_a?(Array)\n super(self.class.formatted_hash(arr_or_hash))\n else\n super(arr_or_hash)\n end\n end",
"def initialize(columns, size_or_array=nil)\n size_or_array ||... | [
"0.7286811",
"0.56759477",
"0.5553372",
"0.55328107",
"0.54705304",
"0.5394304",
"0.531762",
"0.5198018",
"0.5183628",
"0.5109349",
"0.50992733",
"0.5073423",
"0.5071204",
"0.50398135",
"0.5032002",
"0.5027121",
"0.50114876",
"0.50032616",
"0.4999988",
"0.49855044",
"0.497281... | 0.67429686 | 1 |
Action to take on every line of csv file with header row | def process(report)
puts "Code to process csv goes here for #{report}"
CSV.foreach(report, headers: true) do |row|
# **** actions here are operated on every row in the csv ****
puts row['Site Name']
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header\n @header ||= csv_rows.first\n end",
"def header\n @header ||= csv_rows.first\n end",
"def collect_row_headers\n @row_headers = []\n CSV.foreach('testdata.csv') {|row| @row_headers << row[1].to_i}\n @row_headers = @row_headers.uniq.sort[0..-1] # ==> [0, 734638, 734639, 734640, 734... | [
"0.68843275",
"0.68843275",
"0.67756444",
"0.67494935",
"0.67436343",
"0.67245203",
"0.67109495",
"0.66968113",
"0.66968113",
"0.6678946",
"0.6670517",
"0.65253526",
"0.65163213",
"0.64949095",
"0.64844567",
"0.6441023",
"0.6405447",
"0.6278036",
"0.62325144",
"0.62098587",
"... | 0.6164836 | 23 |
Where the magic is. You've got report naming, sql query, & time monitoring. | def adhoc_report(site)
start_time = Time.now
report_name = "reports/#{site.name}.csv"
puts "Generating #{report_name}. Be patient. Get some coffee."
query = %q{WITH
vuln_urls AS (
SELECT vulnerability_id, array_to_string(array_agg(reference), ' , ') AS references
FROM dim_vulnerability_reference
GROUP BY vulnerability_id
)
select da.ip_address, da.host_name, dos.description as operating_system, dv.title as vuln_title, round(dv.riskscore::numeric,0) as vuln_riskscore,
CASE
WHEN (dv.riskscore >= 800) then 'Very High'
WHEN (dv.riskscore >= 600 AND dv.riskscore <= 799) then 'High'
WHEN (dv.riskscore >= 400 AND dv.riskscore <= 599) then 'Medium'
WHEN (dv.riskscore >= 200 AND dv.riskscore <= 399) then 'Low'
WHEN (dv.riskscore <= 199) then 'Very Low'
END AS vuln_severity,
proofastext(dv.description) as vuln_description,
proofastext(favi.proof) as vuln_proof, vu.references, favi.port as "port", dv.date_added as vuln_date_into_nexpose,
to_char(favi.date, 'YYYY-mm-dd') as asset_last_scan
FROM fact_asset_vulnerability_instance favi
JOIN dim_vulnerability dv USING (vulnerability_id)
JOIN dim_asset da USING (asset_id)
JOIN dim_operating_system dos USING (operating_system_id)
JOIN dim_vulnerability_reference dvr USING (vulnerability_id)
JOIN vuln_urls vu USING (vulnerability_id)
WHERE dv.riskscore >= 600
ORDER BY dv.riskscore DESC}
report_config = Nexpose::AdhocReportConfig.new(nil, 'sql', site.id)
report_config.add_filter('version', '2.3.0')
report_config.add_filter('query', query)
report_output = report_config.generate(@nsc)
end_time = Time.now
File.open(report_name, "w+") do |file|
file.write report_output
end
csv_output = CSV.parse(report_output.chomp, { :headers => :first_row })
file_length = csv_output.entries.count
#calculates duration for file creation
ttg = ( (end_time - start_time) / 60).round(1)
puts "\t. . . Complete after #{ttg} minutes and is #{file_length} lines long!"
report_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_lister\n \"Name: #{@name}\\nType: #{@type}\\nRate: #{@rate}\\nCategory: #{@category}\"\n # \"Report run on: \" + Time.now.to_s\n end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def reporting\n # STUB\n end",
"def report_title... | [
"0.69006",
"0.6844597",
"0.6844597",
"0.6844597",
"0.6844597",
"0.6844597",
"0.6657424",
"0.6475766",
"0.6475766",
"0.6461063",
"0.644856",
"0.64197797",
"0.63552904",
"0.63552904",
"0.63552904",
"0.63552904",
"0.63552904",
"0.62652844",
"0.62374854",
"0.6209558",
"0.6192845"... | 0.5475512 | 90 |
TODO: Refactor with chef_clone_repo method | def git_clone_repo(repo_path, repo = git.remote_git_repo, type = {'branch' => 'master'} , deep_clone = true)
in_dir do
pth = Pathname(repo_path).expand_path
gritty = ::Grit::Git.new((pth + '.git').to_s)
announce_or_puts gritty.inspect
clone_opts = {:quiet => false, :verbose => true, :progress => true}
clone_opts[:depth] = 1 unless deep_clone
type['branch'] = type['branch'].nil? ? '' : type['branch']
type['tag'] = type['tag'].nil? ? '' : type['tag']
type['ref'] = type['ref'].nil? ? '' : type['ref']
if pth.directory?
announce_or_puts "Pulling: #{repo} into #{pth}"
FileUtils.cd(pth.to_s) do
res = gritty.pull(clone_opts, repo)
end
clone_opts[:branch] = type['branch'].empty? ? 'master' : type['branch']
else
clone_opts[:branch] = type['branch'].empty? ? 'master' : type['branch']
announce_or_puts "Cloning: #{repo} into #{pth}"
res = gritty.clone(clone_opts, repo, pth.to_s)
end
clone_pull_error_check(res) if res
grotty = ::Grit::Git.new((pth + '.git').to_s)
grotty.checkout( { :B => clone_opts[:branch]||'master' } )
if !type['tag'].empty? || !type['ref'].empty?
grotty.checkout( { :B => true }, 'cuken', type['tag']||type['ref'] )
else
grotty.checkout( { :B => true }, 'cuken' )
end
pth
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_repo(root, repo)\n begin \n destination = \"#{root}/#{repo[\"destination\"]}\"\n rm_rf destination\n sh \"git clone https://github.com/rethinkdb/#{repo[\"repo\"]}.git #{destination}\"\n cd destination\n sh \"git checkout #{repo[\"branch\"]}\"\n rescue Exception\n ... | [
"0.7670641",
"0.76172906",
"0.74792695",
"0.7458879",
"0.74219006",
"0.7401429",
"0.7334391",
"0.7257985",
"0.7220069",
"0.715019",
"0.6993517",
"0.6969926",
"0.6916874",
"0.6895242",
"0.68552864",
"0.6853401",
"0.68142575",
"0.6811783",
"0.68096775",
"0.6799639",
"0.67562395... | 0.70112795 | 10 |
Empty action just a wait and a callback | def delayed_action(wait, repeat=1, &block)
new_action({}, wait, :linear, :round, repeat, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def waiting; end",
"def waiting; end",
"def wait; end",
"def wait; end",
"def wait; end",
"def wait\n\tend",
"def action_callback(options)\n # Wait until the calling thread goes to sleep.\n while options[:thread].status == \"run\"\n sleep 0.1\n end\n\n # Run the block.\n if options[... | [
"0.67175",
"0.67175",
"0.6684758",
"0.6684758",
"0.6684758",
"0.64825755",
"0.6454294",
"0.64399797",
"0.6278872",
"0.61987394",
"0.61979276",
"0.61863536",
"0.6174544",
"0.6166935",
"0.6091581",
"0.6079799",
"0.60047877",
"0.59817475",
"0.59708583",
"0.59698886",
"0.59010524... | 0.0 | -1 |
Write a method that returns an Array that contains every other element of an Array that is passed in as an argument. The values in the returned list should be those values that are in the 1st, 3rd, 5th, and so on elements of the argument Array. Examples: oddities([2, 3, 4, 5, 6]) == [2, 4, 6] oddities([1, 2, 3, 4, 5, 6]) == [1, 3, 5] oddities(['abc', 'def']) == ['abc'] oddities([123]) == [123] oddities([]) == [] Answer: | def even_index_nums(array)
even_index_array = []
array.each_with_index do |element, index|
if index.even?
even_index_array << element
end
end
even_index_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend",
"def oddities(array)\n\n result = [] # empty array to push each item in the array to.\n index = 0 ... | [
"0.8365474",
"0.8301856",
"0.83014846",
"0.83006966",
"0.82734734",
"0.8236041",
"0.8226449",
"0.8203163",
"0.8202177",
"0.8184364",
"0.81677264",
"0.8148469",
"0.81305015",
"0.8124606",
"0.81222236",
"0.8121219",
"0.812029",
"0.80923206",
"0.80799174",
"0.8073462",
"0.806324... | 0.7278168 | 81 |
=> true or this way | def even_index_nums(array)
counter = 0
even_index_array = []
loop do
break if counter == array.length
current_element = array[counter]
if counter % 2 == 0
even_index_array << current_element
end
counter += 1
end
even_index_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def true?\n self == true\n end",
"def to_bool() true end",
"def conditionally_true\n\t\t!!self\n\tend",
"def true \n \"true\" \n end",
"def true?\n self.eql?(true)\n end",
"def true(_argvs)\n return nil\n end",
"def result?\n true\n end",
"def qwerty\n\t\tf... | [
"0.7231769",
"0.7095801",
"0.7051262",
"0.7042259",
"0.69669193",
"0.6882134",
"0.6846522",
"0.6778649",
"0.67663944",
"0.6745763",
"0.6745388",
"0.67389166",
"0.6734261",
"0.6734261",
"0.673201",
"0.6730588",
"0.6723103",
"0.6703069",
"0.6694369",
"0.6689606",
"0.6683062",
... | 0.0 | -1 |
=> true Further Exploration: Write a companion method that returns the 2nd, 4th, 6th, and so on elements of an array. Try to solve this exercise in at least 2 additional ways. 1st way: | def odd_index_nums(array)
odd_index_array = []
array.each_with_index do |element, index|
if index.odd?
odd_index_array << element
end
end
odd_index_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fifth_of_array(array)\nend",
"def second_great_low(arr)\r\n\r\nend",
"def odd_indexed_integers(array)\n\nend",
"def return_edinburgh(array)\n return array[1]\nend",
"def q7_other_arr(arry)\n arry_out = []\n arry.each_index { |i| arry_out << arry[i] if i.even? }\n arry_out\nend",
"def oddities(arr... | [
"0.7151113",
"0.68980896",
"0.65920633",
"0.6547472",
"0.6538001",
"0.65055406",
"0.6490328",
"0.6488265",
"0.6488265",
"0.6480371",
"0.64637697",
"0.6453169",
"0.6447818",
"0.6446534",
"0.64377147",
"0.6430218",
"0.6419768",
"0.64142853",
"0.6382456",
"0.6381374",
"0.6378092... | 0.0 | -1 |
=> true 2nd way: | def odd_index_nums(array)
array.select do |num|
current_index = array.index(num)
if current_index % 2 == 1
num
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bool() true end",
"def check ; true ; end",
"def test?\n false\n end",
"def ==(*)\n true\n end",
"def true?\n self == true\n end",
"def to_bool() false end",
"def nd?\n true\n end",
"def aye?\n true\n end",
"def result?\n true\n end",
"de... | [
"0.6989526",
"0.69693667",
"0.6743636",
"0.6725762",
"0.6703968",
"0.6672206",
"0.66494733",
"0.66469765",
"0.66291654",
"0.6627751",
"0.6624861",
"0.6598645",
"0.6589213",
"0.65876704",
"0.65842736",
"0.65562344",
"0.65394616",
"0.65304446",
"0.652744",
"0.6525513",
"0.65253... | 0.0 | -1 |
finds all stops from first_stop to last_stop on a single line. excludes first_stop | def get_stops (line, first_stop, last_stop)
# puts "line #{ line } stop #{ first_stop } -> stop #{ last_stop }"
first_index = lines[line.to_sym].index(first_stop)
last_index = lines[line.to_sym].index(last_stop)
if first_index <= last_index
trip = lines[line.to_sym][first_index..last_index]
else
trip = lines[line.to_sym][last_index..first_index].reverse
end
trip.shift # remove first stop
return trip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n ... | [
"0.63357574",
"0.6192202",
"0.6184756",
"0.61638033",
"0.60248387",
"0.59344727",
"0.59344727",
"0.58625984",
"0.58625984",
"0.5849838",
"0.57943946",
"0.57723165",
"0.5752128",
"0.5701853",
"0.5661415",
"0.5562728",
"0.55192155",
"0.55192155",
"0.55192155",
"0.5507625",
"0.5... | 0.7444937 | 0 |
You were given a natural number 'number'. Return all its digits one by one in reverse order separating them by spaces or new lines You should not use string, array or loops. Use only recursion and arithmetic operators. 961 = 169 | def reverse_digits(num)
num_array = num.to_s.chars
return num_array[0] if num_array.length == 1
"#{num_array.pop} " + reverse_digits(num_array.join.to_i)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse(number)\n digits = number.to_s.chars\n reversed = []\n if digits.length <= 1\n number\n else\n reversed << digits.pop\n reversed << reverse(digits.join.to_i)\n reversed.join.to_i\n end\nend",
"def reverse(number)\n return number if number < 10\n array = number.to_s.split(//)\n\n t... | [
"0.7983433",
"0.7924465",
"0.7897425",
"0.78974044",
"0.7748002",
"0.7695915",
"0.7676868",
"0.7644665",
"0.7576181",
"0.7562105",
"0.7555308",
"0.7548733",
"0.7544453",
"0.7520428",
"0.74918747",
"0.745448",
"0.7442109",
"0.74349946",
"0.7390438",
"0.73695767",
"0.73675334",... | 0.72806966 | 23 |
This method compares the users response to the list of valid responses and outputs an error and main menu return if not valid. LOVE THIS!!! | def verified_answer(user_response, list_of_responses)
if list_of_responses.include? user_response
user_response
else
invalid_return_mm
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_valid_response(resp)\n if resp == 'exit!'\n game_data.save\n elsif game_data.chosen_letters.include?(resp)\n repeat_response_query('repeat')\n elsif resp.length > 1\n repeat_response_query('multiple')\n else\n action(resp)\n end\n end",
"def validate_user_respons... | [
"0.71117836",
"0.680651",
"0.6579025",
"0.63688767",
"0.6296479",
"0.62316084",
"0.6231399",
"0.6179783",
"0.6156473",
"0.6141003",
"0.6056366",
"0.60482544",
"0.6031552",
"0.60153294",
"0.6012729",
"0.5986018",
"0.5982685",
"0.5978555",
"0.5967713",
"0.59655213",
"0.59247553... | 0.65853333 | 2 |
This method stores whole words for politicians political affiliation. | def whole_affil (new_party_affiliation)
if new_party_affiliation == "d"
"Democrat"
else new_party_affiliation == "r"
"Republican"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cryptic_dictionary(words)\nend",
"def add_adjective!(word)\n new_word = Unicode.downcase(word)\n new_word[-2..-1] = \"ая\"\n @redis.rpush(\"store:adjectives\", new_word) \n end",
"def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end",
"def add_word wor... | [
"0.5727451",
"0.5593518",
"0.55619323",
"0.5515267",
"0.54821146",
"0.5475592",
"0.5460208",
"0.54224265",
"0.5398076",
"0.5379724",
"0.53557044",
"0.53491235",
"0.5321153",
"0.52687573",
"0.52671456",
"0.5242141",
"0.52264255",
"0.52238184",
"0.5209235",
"0.5204786",
"0.5204... | 0.5241604 | 16 |
This method stores whole words for voters political view. | def whole_views(new_political_view)
case new_political_view
when "l"
"Liberal"
when "c"
"Conservative"
when "t"
"Tea Party"
when "s"
"Socialist"
when "n"
"Neutral"
else
"Liberal"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_pose_words\n\n # Step 1: get an array of all words for the current object.\n search_text = instance_eval &(self.class.pose_content)\n new_words = Query.new([], search_text.to_s).query_words\n\n # Step 2: Add new words to the search index.\n Helpers.get_words_to_add(self.pose_wor... | [
"0.64821327",
"0.60820365",
"0.605837",
"0.6032767",
"0.5932973",
"0.5908903",
"0.58927476",
"0.58840084",
"0.5870585",
"0.5862464",
"0.58551824",
"0.58437544",
"0.58405465",
"0.5830367",
"0.5804689",
"0.57679665",
"0.57364255",
"0.57329744",
"0.5729428",
"0.5729428",
"0.5727... | 0.0 | -1 |
This slows down the text, all spy like. ;) | def slow_r_down(text)
text.to_s.each_char do |x|
print x
case x
when ".", "!", "?"
sleep(0.35)
else
sleep(0.03)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_line_speed\n @line_show_fast = CP::CMS::TEXT_TYPE_OR_SKIP\n end",
"def slow_scroll()\r\n 10.times do\r\n sleep 0.05\r\n puts \"\"\r\n end\r\nend",
"def animate(text: 'Downloading')\n\tt = Thread.new {\n\t\ti = 0\n\t\tlen = text.length\n\t\tchars = %W(\\u2802 \\u2812 \\u2832 \\u2... | [
"0.65833825",
"0.6523232",
"0.64904755",
"0.64749813",
"0.6376131",
"0.6254747",
"0.62546295",
"0.6189177",
"0.61624795",
"0.60285467",
"0.60163164",
"0.59184855",
"0.5898979",
"0.5821023",
"0.5798578",
"0.57925904",
"0.5767543",
"0.5766939",
"0.57489055",
"0.5728405",
"0.572... | 0.70689255 | 0 |
If user selects an invalid option it takes them back to main menu. | def invalid_return_mm
puts "Invalid option : No match found. Returning to the main menu.".center(80)
main_menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_wrong_option\n print \"Option not available. \".red\n determine_action(get_entry(\"Select option: \"))\n end",
"def invalid_option\n\t\t\t\talert_menu \"Invalid option!\"\n\t\t\tend",
"def main_menu\n\tputs \"Welcome to Roy Bank!\"\n\tputs\"Please make a selection:\"\n\tputs \"_________... | [
"0.7783703",
"0.75411755",
"0.6689158",
"0.66183287",
"0.64742786",
"0.6465329",
"0.64648294",
"0.6400918",
"0.638639",
"0.63639075",
"0.6319928",
"0.6272095",
"0.6263153",
"0.62389815",
"0.62364393",
"0.6224212",
"0.62218475",
"0.62150705",
"0.61905396",
"0.60984504",
"0.609... | 0.7325123 | 2 |
The following methods update a voter or politician in the directory. | def update_option
puts "Would you like to Update a (V)oter or (P)olitician record?".center(80)
update_type = verified_answer(gets.chomp.downcase, ["p", "v"])
if update_type == "p"
update_politician
list_politicians
else
update_voter
list_voters
end
puts "Record successfully updated.".center(80).green
puts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @voter = Voter.find(params[:id])\n\n respond_to do |format|\n if @voter.update_attributes(params[:voter])\n format.html { redirect_to @voter, notice: 'Voter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.7033077",
"0.6857245",
"0.6857245",
"0.65347373",
"0.6312179",
"0.6284006",
"0.62395316",
"0.620653",
"0.6136139",
"0.6128933",
"0.6108235",
"0.6079499",
"0.6053282",
"0.6053282",
"0.6053282",
"0.6053282",
"0.6047056",
"0.6047056",
"0.6047056",
"0.6047056",
"0.6047056",
... | 0.0 | -1 |
These methods create a new voter or politician. | def create_option
puts "Create new (P)olitician or (V)oter?".center(80)
creation_type = verified_answer(gets.chomp.downcase, ["p", "v"])
if creation_type.downcase == "p"
puts "Enter new politician details.".center(80)
puts "NAME:".center(80)
new_name = gets.chomp.downcase
puts "PARTY AFFILIATION: (R)epublican or (D)emocrat?".center(80)
new_party_affiliation = verified_answer(gets.chomp.downcase, ["d", "r"])
@politician_directory << Politician.new(new_name, whole_affil(new_party_affiliation))
list_politicians
else
puts "Enter new voter details.".center(80)
puts "NAME:".center(80)
new_name = gets.chomp.downcase
puts """
POLITICAL VIEW:
(L)iberal, (C)onservative, (T)ea Party,
(S)ocialist, or (N)eutral.""".center(80)
new_political_view = verified_answer(gets.chomp.downcase, ["l", "c", "t", "s", "n"])
@voter_directory << Voter.new(new_name, whole_views(new_political_view))
list_voters
end
puts "New record created.".center(80).green
puts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voter_politician_create(person)\n case person.downcase\n when \"v\"\n ask_name()\n name = gets.chomp\n ask_politics()\n politics = pick_politics()\n @world.create_voter(name, politics)\n restart()\n when \"p\"\n a... | [
"0.79145575",
"0.7381869",
"0.7296676",
"0.6968626",
"0.69597816",
"0.69418776",
"0.6602408",
"0.65851545",
"0.6567758",
"0.6473178",
"0.637075",
"0.6336152",
"0.6316188",
"0.63089055",
"0.63049763",
"0.6303649",
"0.6271796",
"0.6271324",
"0.62332004",
"0.62214303",
"0.621109... | 0.6240167 | 18 |
These methods list records in the directory. | def list_option
list_politicians
list_voters
puts
puts "(R)eturn to the main menu?".center(80).green
menu_return = gets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @file_records = FileRecord.all\n end",
"def index\n @file_records = FileRecord.all\n end",
"def list\n call(:get, path)\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def list(path='ro... | [
"0.69430274",
"0.69430274",
"0.67232615",
"0.65175796",
"0.64744735",
"0.6373912",
"0.63653886",
"0.6316174",
"0.6303739",
"0.62991416",
"0.626525",
"0.6252788",
"0.6237202",
"0.6208921",
"0.6205405",
"0.61729693",
"0.6140949",
"0.6131978",
"0.61298907",
"0.61233455",
"0.6120... | 0.0 | -1 |
These methods delete records from the directory. | def delete_option
puts "PROCEED WITH CAUTION".center(80).red
puts "Delete (P)olitician or (V)oter record?".center(80)
delete_type = verified_answer(gets.chomp.downcase, ["p", "v"])
if delete_type == "p"
delete_politician
list_politicians
else
delete_voter
list_voters
end
puts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all\n records.clear\n end",
"def deleteAll\n Record.destroy_all()\n redirect_to(records_path)\n end",
"def delete(*records)\n records.each do |record|\n target.delete(record)\n end\n end",
"def delete\n Modeles::File.delete @f... | [
"0.71038073",
"0.7043321",
"0.6852107",
"0.68262476",
"0.67966056",
"0.6752839",
"0.6752663",
"0.67201227",
"0.6692268",
"0.6676397",
"0.66696036",
"0.66558874",
"0.6616819",
"0.66001105",
"0.65852606",
"0.65490115",
"0.64989024",
"0.6414904",
"0.6413997",
"0.6392567",
"0.636... | 0.0 | -1 |
Call back to index action and render on index.html.erb | def search
index
render :index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render\n end",
"def index\n render\n end",
"def index\n render_index\n end",
"def index\n\t\tlist\n\t\trender('list')\n\tend",
"def index\n\t\tlist\n\t\trender('list')\n\tend",
"def index\n render 'index'\n\n end",
"def index\n list\n render(\"list\")\n end",
"d... | [
"0.868087",
"0.8500112",
"0.8499079",
"0.82721514",
"0.82721514",
"0.8257826",
"0.8201098",
"0.8182875",
"0.806883",
"0.806812",
"0.80245614",
"0.8024383",
"0.8024383",
"0.8024383",
"0.8024383",
"0.8024383",
"0.8024383",
"0.8024383",
"0.7962438",
"0.7921645",
"0.79107165",
... | 0.0 | -1 |
Paramaters that can be changed in the web forms | def resource_params
params.require(:contact).permit(:name, :company, :position, :birth)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_params\n raise 'Sovrascrivi in figli'\n end",
"def params=(value); end",
"def params() request.params end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def par... | [
"0.6702531",
"0.6601398",
"0.64557844",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.6426045",
"0.64106864",
... | 0.0 | -1 |
Provide a humanfriendly refresh process | def recall_item
if is_downloadable?
if is_viewable?
respond_to do |format|
format.html { render 'recall_item', status: :see_other }
format.json { json_delegate_response }
end
else
respond_to do |format|
format.html { render unauthorized_template, status: :unauthorized }
format.json { json_unauthorized_response }
end
end
else
respond_to do |format|
format.html { render 'item_not_found', status: :not_found }
format.json { json_not_found_response }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh!; end",
"def refresh\n do_refresh\n end",
"def refresh\n do_refresh\n end",
"def refresh\n send_cmd \"refresh\"\n nil\n end",
"def refresh\r\n end",
"def refresh; schedule_update end",
"def refresh\n end",
"def refresh; end",
"def refresh\n end",
"def refre... | [
"0.80257064",
"0.7986451",
"0.7986451",
"0.78527427",
"0.7835058",
"0.7789048",
"0.77886134",
"0.77767205",
"0.7774065",
"0.7774065",
"0.75796705",
"0.75768477",
"0.75768477",
"0.7533585",
"0.75304383",
"0.73102164",
"0.71657956",
"0.6979179",
"0.6946377",
"0.6922163",
"0.692... | 0.0 | -1 |
JSON API requests & noscript fallback HTML responses | def request_item
if is_downloadable?
if is_viewable?
respond_to do |format|
format.html do
flash[:notice] = 'File retrieval request received.'
redirect_to(
recall_bendo_item_path(id: noid),
status: :found
)
end
format.json { json_api_response }
end
else
respond_to do |format|
format.html do
flash[:alert] = "You are not permitted to view the item with ID: #{noid}"
redirect_to recall_bendo_item_path(id: noid)
end
format.json { json_unauthorized_response }
end
end
else
respond_to do |format|
format.html do
flash[:alert] = "No files can be downloaded for ID: #{noid}"
redirect_to recall_bendo_item_path(id: noid)
end
format.json { json_not_found_response }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_xhrml\n if get? || !has_errors? || response_overridden?\n to_html\n else\n render action: default_action, status: :unprocessable_entity\n end\n end",
"def json_get\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n ... | [
"0.63856804",
"0.62497216",
"0.59970534",
"0.58837616",
"0.58267385",
"0.58155936",
"0.57989675",
"0.5788801",
"0.5761254",
"0.5701413",
"0.5698152",
"0.5696378",
"0.5694431",
"0.5647853",
"0.5647008",
"0.56408644",
"0.56280583",
"0.56280583",
"0.56191885",
"0.5619025",
"0.56... | 0.0 | -1 |
GET /messages GET /messages.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def messages\n get_json('messages.json')\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @mess... | [
"0.8394855",
"0.75543094",
"0.7462283",
"0.7462283",
"0.7439893",
"0.7431661",
"0.7429978",
"0.74292123",
"0.7412184",
"0.73673457",
"0.73555905",
"0.73495036",
"0.72967225",
"0.72900546",
"0.7289403",
"0.7268556",
"0.7183999",
"0.71553916",
"0.7153012",
"0.71380496",
"0.7102... | 0.0 | -1 |
POST /messages POST /messages.json | def create
@message = Message.new(message_params)
respond_to do |format|
if @message.save
format.html { redirect_to messages_url, notice: 'Message was successfully created.' }
else
format.html { render :new }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end",
"def create\n @messag... | [
"0.7465461",
"0.71704835",
"0.71130985",
"0.70958537",
"0.7068939",
"0.7020135",
"0.6939461",
"0.68449193",
"0.68354475",
"0.68308204",
"0.6830379",
"0.6830379",
"0.67848176",
"0.6765744",
"0.67015487",
"0.67001784",
"0.66719586",
"0.6634068",
"0.6625937",
"0.6624979",
"0.661... | 0.6227605 | 86 |
PATCH/PUT /messages/1 PATCH/PUT /messages/1.json | def update
respond_to do |format|
if @message.update(message_params)
format.html { redirect_to messages_url, notice: 'Message was successfully updated.' }
else
format.html { render :edit }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @v1_message = V1::Message.find(params[:id])\n\n if @v1_message.update(message_params)\n render json: @v1_message, status: :ok\n else\n render json: @v1_message.errors, status: :unprocessable_entity\n end\n end",
"def update\n message = Message.find(params[:id])\n message... | [
"0.708431",
"0.6978376",
"0.690778",
"0.6854797",
"0.6815956",
"0.6795405",
"0.6790936",
"0.67612135",
"0.675905",
"0.67395717",
"0.67395717",
"0.66698396",
"0.66626984",
"0.665636",
"0.66526294",
"0.6645645",
"0.66447604",
"0.66447604",
"0.66447604",
"0.66447604",
"0.6644760... | 0.0 | -1 |
DELETE /messages/1 DELETE /messages/1.json | def destroy
@message.destroy
respond_to do |format|
format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end",
"def delete\n @client.post('/api/del_msg', id: get_attribute(:name))\n end",
"def destroy\n # delete a specific message\n end",
"def destroy\n @message.destroy\n \n ... | [
"0.7959872",
"0.7747524",
"0.77164423",
"0.7661726",
"0.76382256",
"0.76306146",
"0.76271677",
"0.7610772",
"0.76048714",
"0.7604346",
"0.7604346",
"0.7591631",
"0.7588635",
"0.7588635",
"0.7588635",
"0.7588635",
"0.7551851",
"0.75501",
"0.75501",
"0.75501",
"0.75501",
"0.7... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def message_params
params.require(:message).permit(:text, :start_at, :end_at, :library, :request_type)
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
Returns the unit of the dimension node. | def dimension
@unit.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit\n return @unit\n end",
"def get_units(dimension)\n nil\n end",
"def si_unit\n return self if self.dimensions.is_dimensionless?\n @dimensions.si_unit\n end",
"def units\n return @units\n end",
"def units\n a... | [
"0.73316276",
"0.73153585",
"0.7066636",
"0.69787794",
"0.67842335",
"0.6745625",
"0.6684465",
"0.6684465",
"0.6653205",
"0.6606556",
"0.6606248",
"0.6522029",
"0.6455677",
"0.63878477",
"0.6315979",
"0.6314739",
"0.6244463",
"0.62125117",
"0.61903274",
"0.6174105",
"0.616577... | 0.8101753 | 0 |
Update one or more. | def update record, resources
result = [resources].flatten.map do |resource|
resource = record.new(resource) unless resource.kind_of?(record)
keys = resource.tuple.values_at(*record.header.keys)
# TODO: Name the key field(s) missing.
raise ArgumentError, "#{record} resource has incomplete key: #{resource.inspect}" \
unless keys.select(&:nil?).empty?
execute(command_update(record), *resource.tuple.values_at(*record.header.updatable), *keys)
resource
end
resources.kind_of?(Array) ? result : result.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(*args)\n each{|r| r.update(*args)}\n end",
"def update\n update_all\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def update!(**args)\n end",
"def update!(**args)\n end",
"def update!(**args)\n ... | [
"0.8030889",
"0.74449974",
"0.73343164",
"0.73343164",
"0.719129",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
"0.7190003",
... | 0.0 | -1 |
Delete one or more. | def delete record, resources
result = [resources].flatten.map do |resource|
resource = record.new(resource) unless resource.kind_of?(record)
keys = resource.tuple.values_at(*record.header.keys)
# TODO: Name the key field(s) missing.
raise ArgumentError, "#{record} resource has incomplete key: #{resource.inspect}" \
unless keys.select(&:nil?).empty?
if result = execute(command_delete(record), *keys)
resource.freeze
end
result
end
resources.kind_of?(Array) ? result : result.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(*args)\n execute(:delete, *args)\n end",
"def delete(*rest) end",
"def delete!(*rest) end",
"def delete(*ids)\n ids.flatten!\n @write_connection.delete_by_id(ids)\n end",
"def delete_multiple(keys = [])\n verify_connection_url\n\n keys.each { |key| delete key }... | [
"0.7796597",
"0.7616567",
"0.7540228",
"0.73775",
"0.7331829",
"0.7253921",
"0.7207253",
"0.71927065",
"0.7171126",
"0.7170078",
"0.7156719",
"0.71288824",
"0.7098882",
"0.7079333",
"0.7079333",
"0.7046401",
"0.7033728",
"0.70301384",
"0.70279235",
"0.7010921",
"0.70014495",
... | 0.0 | -1 |
Create a server side prepared statement | def prepare record = nil, command
record ? Statement.new(record, command) : db.prepare(command)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_prepared_statement_server(ps)\n if @server\n ps.server(@server)\n else\n ps\n end\n end",
"def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end",
"def prepare(type, name=nil, *values)\n ... | [
"0.6981347",
"0.6837139",
"0.6787886",
"0.6705023",
"0.6595554",
"0.65277636",
"0.6479592",
"0.6463498",
"0.64207697",
"0.6383033",
"0.6373859",
"0.63402313",
"0.6266532",
"0.62571156",
"0.62253773",
"0.60758793",
"0.60536516",
"0.6025458",
"0.5980238",
"0.5975573",
"0.596831... | 0.61603105 | 15 |
Check if the adapter commands are being traced. | def trace?
!!@trace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traced?\n NewRelic::Agent.is_execution_traced?\n end",
"def check_for_running_transaction\n # ignore this command when within transaction block\n # as this command is started at the begining of transaction\n return false if @transaction\n response = script_mode do\n ... | [
"0.6743287",
"0.6211449",
"0.6119923",
"0.5899874",
"0.5892366",
"0.58054614",
"0.5732865",
"0.5731314",
"0.57288957",
"0.5662789",
"0.5643164",
"0.56370234",
"0.5635921",
"0.5632394",
"0.5628458",
"0.55960745",
"0.55379957",
"0.5531343",
"0.553097",
"0.5522248",
"0.5509487",... | 0.58926874 | 4 |
Execute a command using the underlying concrete adapter. | def execute command, *bind
start = Time.now
record, command = command, bind.shift if command.kind_of?(Class) && command < Record
record ? Result.new(record, db.execute(command, *bind)) : db.execute(command, *bind)
ensure
log_command(start, command, bind) if @trace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n raise NotImplementedError, 'Define `execute` in Command subclass'\n end",
"def execute(command, opts=nil)\n end",
"def command(*params)\n raise ErrorParams, \"command missing method name\" if params.empty?\n\n transp.adapter_request(*params)\n .then { |args... | [
"0.72119004",
"0.68694115",
"0.68215925",
"0.6781732",
"0.6762745",
"0.6761597",
"0.6761597",
"0.6737964",
"0.6734464",
"0.6719598",
"0.670818",
"0.66809684",
"0.6673869",
"0.6651498",
"0.66461736",
"0.663981",
"0.6638179",
"0.6600325",
"0.6596317",
"0.6558964",
"0.6502242",
... | 0.59950155 | 63 |
assumes x.y.z all digit version | def next_version
# x.y.z
v = version.split '.'
# bump z
v[-1] = v[-1].to_i + 1
v.join '.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def osgi_version_for(version)\n parts = version.split(/[\\.,-]/)\n result = Array.new(3, 0)\n parts.each_index { |i|\n if (result.size == 3) then\n if (parts[i] =~ /\\d+/) then result[i] = parts[i] else result = result << parts[i] end\n else\n result[3] = [result[3], parts[i]].join(\"-\")\n e... | [
"0.67268604",
"0.67082983",
"0.652006",
"0.6492646",
"0.6435036",
"0.6413361",
"0.64100623",
"0.6325298",
"0.629826",
"0.62875336",
"0.62479377",
"0.62161833",
"0.6209893",
"0.6197964",
"0.6139305",
"0.6121343",
"0.61207163",
"0.610822",
"0.60709566",
"0.6014099",
"0.6005496"... | 0.6655396 | 2 |
Actually builds the HTML file from the entry (actually from any composite entries) | def build
@layout_path = bundle.layout_path
# Render each filename. By default, the output goes to the resources
# string
@content_for_resources = ''
entries.each { |fn| _render_one(fn) }
# Finally, render the layout. This should produce the final output to
# return
input = File.read(@layout_path)
# render using either erb or haml
case File.extname(@layout_path)
when /\.rhtml$/, /\.html.erb$/
return eval(Erubis::Eruby.new.convert(input))
when /\.haml$/, /\.html.haml$/
require 'haml'
return Haml::Engine.new(input).to_html(self)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vc... | [
"0.689124",
"0.6867437",
"0.67406434",
"0.6359123",
"0.63519",
"0.6223772",
"0.6172329",
"0.6166777",
"0.6166777",
"0.6140824",
"0.6120351",
"0.60728174",
"0.5949518",
"0.5903462",
"0.5878804",
"0.5872136",
"0.5856295",
"0.58351064",
"0.5831087",
"0.58272076",
"0.58025324",
... | 0.5749229 | 27 |
render a single entry | def _render_one(entry)
@entry = entry
@filename = @entry.filename
# avoid double render of layout path
return if @entry.source_path == @layout_path
# render. Result goes into @content_for_resources
input = File.read(@entry.source_path)
# render using either erb or haml
case File.extname(@entry.source_path)
when /\.rhtml$/, /\.html.erb$/
@content_for_resources += eval(Erubis::Eruby.new.convert(input))
when /\.haml$/, /\.html.haml$/
require 'haml'
@content_for_resources += Haml::Engine.new(input).to_html(self)
end
@filename =nil
@entry = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vc... | [
"0.73900396",
"0.71054995",
"0.71054995",
"0.6949827",
"0.6887951",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.68305993",
"0.67296773",
"0.67144156",
"0.6655709",
"0.6655709",
"0.6510501",
"0.64979804",
"... | 0.64620817 | 20 |
Returns the current bundle name. Often useful for generating titles, etc. | def bundle_name; bundle.bundle_name; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bundle_name\n info_plist[\"CFBundleDisplayName\"] || info_plist[\"CFBundleName\"]\n end",
"def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end",
"def app_name\n @data['CFBundleExecutable'].to_s\n end",
"def bundle_id\n read('bundle_id')\n end",
"def cfB... | [
"0.79277426",
"0.6981337",
"0.67999613",
"0.6788858",
"0.67024314",
"0.6643769",
"0.6607597",
"0.65547097",
"0.6517105",
"0.63893884",
"0.6364047",
"0.6359927",
"0.63173026",
"0.630701",
"0.6297408",
"0.62890816",
"0.6267021",
"0.626352",
"0.62465334",
"0.6233625",
"0.6225294... | 0.82866037 | 0 |
For Rails Compatibility. render() does not do anything useful since the new build system is nice about putting things into the right place for output. | def render; ''; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render\n perform(Environment.new).to_s\n end",
"def build_html\n ApplicationController.render(partial: partial, locals: locals)\n end",
"def render\n App.out.render\nend",
"def render\n end",
"def render( render_state )\n\t\treturn nil\n\tend",
"def render; end",
"... | [
"0.71758294",
"0.6982254",
"0.69216454",
"0.6897247",
"0.6892187",
"0.6874957",
"0.6874957",
"0.6874957",
"0.6874957",
"0.6874957",
"0.6836229",
"0.6834731",
"0.6834731",
"0.6834731",
"0.6834661",
"0.6754122",
"0.67250836",
"0.6720979",
"0.6703739",
"0.66666704",
"0.66666704"... | 0.63399833 | 52 |
e.x.) "tasksindex" => "task" e.x.) "RailsAdmin::Engine" => "rails_amin/engine" | def to_tag_name
tag_name = if @is_route_engine
@request.gsub('::', '/').underscore
else
@request.split('#').first.singularize
end
tag_name = tag_name.split('/').last unless use_tag_namespace
tag_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_template\n :index\n end",
"def index_template\n :index\n end",
"def setting_index\n end",
"def index_admin\n @events = Event.all.order('start_at ASC')\n end",
"def index\n @admin_admins = Admin.all\n\n @grid = grid_class.new(grid_params) do |scope|\n scope.page(params[:pag... | [
"0.60740155",
"0.60740155",
"0.59443456",
"0.59009147",
"0.5796762",
"0.5791534",
"0.5790433",
"0.5785003",
"0.5777919",
"0.5754115",
"0.57011503",
"0.56744",
"0.5641266",
"0.56237626",
"0.5613647",
"0.5605421",
"0.5600719",
"0.5600719",
"0.5583787",
"0.55728",
"0.55494463",
... | 0.0 | -1 |
GET /periods GET /periods.json | def index
@periods = @organism.periods.order(:close_date)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @periods }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_periods\n @periods = current_user.periods.all.order(created_at: :desc)\n render json: @periods\n end",
"def index\n @periods = Period.all\n end",
"def index\n periods = current_user.school.periods.all\n\n render json: periods\n end",
"def periods\n @periods ||= @data['properties'... | [
"0.7931133",
"0.75391394",
"0.7499614",
"0.7338183",
"0.73185486",
"0.7263721",
"0.72523004",
"0.7083454",
"0.6967688",
"0.691698",
"0.6834991",
"0.6755399",
"0.6590099",
"0.65424144",
"0.6511148",
"0.6462379",
"0.6462379",
"0.6404114",
"0.6399585",
"0.63783365",
"0.63536614"... | 0.6983398 | 8 |
GET /periods/new GET /periods/new.json | def new
if @organism.periods.any?
@disable_start_date = true
start_date = (@organism.periods.order(:close_date).last.close_date) +1
# begin_year and end_year limit the select in the the view
@begin_year = start_date.year
@end_year = @begin_year + 2 #
else
@disable_start_date = false
@begin_year = @end_year = nil
start_date = Date.today.beginning_of_year # on propose une date d'ouverture par défaut
end
close_date = start_date.years_since(1)-1 # et une date de clôture probable
@period = @organism.periods.new(:start_date=>start_date, :close_date=>close_date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @resource_period }\n end\n end",
"def new\n @tb_period = TbPeriod.new\n\n respond_to do |format|\n format... | [
"0.74636674",
"0.72604084",
"0.7087081",
"0.69765055",
"0.6967836",
"0.694958",
"0.68680185",
"0.6729341",
"0.66939074",
"0.6691118",
"0.6603186",
"0.65806526",
"0.6570101",
"0.65423864",
"0.6514642",
"0.651029",
"0.650848",
"0.6495663",
"0.6461202",
"0.6446872",
"0.6403545",... | 0.0 | -1 |
DELETE /periods/1 DELETE /periods/1.json | def destroy
@period = Period.find(params[:id])
if @period.destroy
session[:period] = @organism.periods.any? ? @organism.periods.order(:close_date).last.id : nil
flash[:notice] = 'L\'exercice a été détruit ; vous avez changé d\'exercice'
end
respond_to do |format|
format.html do
redirect_to admin_organism_periods_url(@organism)
end
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @time_period.destroy\n format.json { head :no_content }\n end",
"def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n head :no_content\n end",
"def destroy\n @tb_period = TbPeriod.find(params[:id])\n @tb_period.destroy\n\n respond_to do |format|\n ... | [
"0.7818458",
"0.7555096",
"0.74889266",
"0.7486217",
"0.74291295",
"0.7370233",
"0.73162484",
"0.7293146",
"0.7238291",
"0.7164498",
"0.700519",
"0.6993836",
"0.6993655",
"0.6932407",
"0.6929588",
"0.6929204",
"0.6921115",
"0.6902328",
"0.6872384",
"0.68497676",
"0.6844296",
... | 0.6689559 | 30 |
OpenSSL verify callback used by initialize when optional callback argument isn't set. | def verify_callback(_, cert)
pem = cert.current_cert.public_key.to_pem
sha256 = OpenSSL::Digest::SHA256.new
hash = sha256.digest(pem).unpack("H*")
hash[0].casecmp(@hash).zero?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_callback=(verify_callback); end",
"def verify_callback=(verify_callback); end",
"def verify_callback; end",
"def verify_callback; end",
"def register_verify_callback(connection)\n connection.verify_callback = self\n end",
"def verify_callback= verify_callback\n @agent.verify_callback = ... | [
"0.7699949",
"0.7699949",
"0.73474926",
"0.73474926",
"0.7141537",
"0.70659053",
"0.70443606",
"0.6714693",
"0.6688273",
"0.65700954",
"0.65411067",
"0.6484199",
"0.6443551",
"0.6388104",
"0.62961584",
"0.61143875",
"0.60836494",
"0.59283555",
"0.59283555",
"0.59283555",
"0.5... | 0.63852626 | 14 |
Sends the login packet with specific password. Read the result with `read`. Warning: Strongly disencouraged. Use tokens instead, when possible. | def login_with_password(bot, name, password)
send Common::Login.new(bot, name, password, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login(options, password = nil) # :yield: recvdata\n login_prompt = /[Ll]ogin[: ]*\\z/n\n password_prompt = /[Pp]ass(?:word|phrase)[: ]*\\z/n\n if options.kind_of?(Hash)\n username = options[\"Name\"]\n password = options[\"Password\"]\n login_prompt = options[\"LoginPrompt\"... | [
"0.70112157",
"0.6982452",
"0.6946723",
"0.68269336",
"0.6819371",
"0.65334004",
"0.65069985",
"0.64677",
"0.643293",
"0.6368533",
"0.6353334",
"0.6335806",
"0.6329706",
"0.6308235",
"0.6294756",
"0.6272615",
"0.6231189",
"0.62282807",
"0.6228104",
"0.6175945",
"0.61559194",
... | 0.68922913 | 3 |
Sends the login packet with specific token. Read the result with `read`. | def login_with_token(bot, name, token)
send Common::Login.new(bot, name, nil, token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n receive_until_token(@login_token)\n enter_login unless @logged_in\n if @password # if password was passed, else try without password\n receive_until_token(@password_token)\n enter_password unless @logged_in\n end\n receive_until_token(@prompt)\n @logger.info(... | [
"0.69553477",
"0.6641722",
"0.6189487",
"0.616265",
"0.614956",
"0.6052216",
"0.6050336",
"0.60495996",
"0.60450184",
"0.604339",
"0.60205793",
"0.6011686",
"0.5973795",
"0.59722173",
"0.59708863",
"0.5964438",
"0.595205",
"0.59301025",
"0.59217465",
"0.5916443",
"0.59118",
... | 0.66610795 | 1 |
Transmit a packet over the connection | def send(packet)
id = Common.packet_to_id(packet)
data = [id, [packet.to_a]].to_msgpack
@stream.write Common.encode_u16(data.length)
@stream.write data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_tcp packet, destination_address\n\t\t\ttcp = TCPSocket.new(destination_address, @tcp_port)\n\t\t\ttcp.write(packet.to_str)\n\t\t\ttcp.close\n\t\tend",
"def send(eiscp_packet)\n sock = TCPSocket.new @host, @port\n sock.puts eiscp_packet\n sock.close\n end",
"def push packet\n beg... | [
"0.6931033",
"0.6879451",
"0.6878823",
"0.68696177",
"0.6833697",
"0.6794317",
"0.6688148",
"0.6671266",
"0.6655429",
"0.6640634",
"0.66332614",
"0.66228616",
"0.65831417",
"0.6357997",
"0.63476944",
"0.6291733",
"0.6265326",
"0.62641543",
"0.6235007",
"0.6228221",
"0.6206566... | 0.7017103 | 0 |
Read a packet from the connection | def read()
size_a = @stream.read 2
size = Common.decode_u16(size_a)
data = @stream.read size
data = MessagePack.unpack data
class_ = Common.packet_from_id data[0]
class_.new *data[1][0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_packet\n length = @socket.read( 4 ).unpack( \"N\" ).first - 1\n type = @socket.read( 1 ).unpack( \"C\" ).first\n reader = @buffers.reader( @socket.read( length ) )\n return type, reader\n end",
"def read_packet; end",
"def read\n\n raise \"Interface not ... | [
"0.81583774",
"0.8128841",
"0.79864657",
"0.718664",
"0.7078291",
"0.70767456",
"0.69758976",
"0.684859",
"0.68352664",
"0.67587477",
"0.67497087",
"0.6661749",
"0.64809483",
"0.64631426",
"0.6461521",
"0.6394127",
"0.6344144",
"0.6285171",
"0.6279428",
"0.6259725",
"0.623159... | 0.67256093 | 11 |
Fires up the gateway session's event loop within a thread, so that it can run in the background. The loop will run for as long as the gateway remains active. | def initiate_event_loop!
@active = true
@thread = Thread.new do
while @active
@session_mutex.synchronize do
@session.process(@loop_wait)
end
Thread.pass
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initiate_event_loop!\n @active = true\n\n @thread = Thread.new do\n while @active\n @session_mutex.synchronize do\n @session.process(@loop_wait)\n end\n Thread.pass\n end\n end\n end",
"def serving_loop\n Thread.new { socket_loop }\n ... | [
"0.7530425",
"0.67786705",
"0.67746305",
"0.6593444",
"0.6338033",
"0.63141614",
"0.6270804",
"0.6237769",
"0.6219712",
"0.6219712",
"0.61897856",
"0.6167689",
"0.61242604",
"0.60722846",
"0.60667753",
"0.6065734",
"0.6058754",
"0.6052629",
"0.60506123",
"0.6041582",
"0.60415... | 0.7528908 | 1 |
===================== Complex validations: ===================== | def validate
# first check whether combo fields have been selected
is_valid = true
if is_valid
is_valid = set_drench_concentrate_status
end
# if is_valid
# is_valid = ModelHelper::Validations.validate_combos([{:drench_line_type_code => self.drench_line_type_code}],self)
# end
# #now check whether fk combos combine to form valid foreign keys
# if is_valid
# is_valid = set_drench_station
# end
# if is_valid
# is_valid = ModelHelper::Validations.validate_combos([{:concentrate_code => self.concentrate_code}],self)
# end
# #now check whether fk combos combine to form valid foreign keys
# if is_valid
# is_valid = set_concentrate_product
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validation; end",
"def validation; end",
"def is_valid; end",
"def validate\n \n \n end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def valid?\n \n \n \n \n \n \n ... | [
"0.7434267",
"0.7434267",
"0.7371285",
"0.7352238",
"0.7347254",
"0.7347254",
"0.731587",
"0.731587",
"0.731587",
"0.731587",
"0.73144066",
"0.7277695",
"0.7239673",
"0.72192556",
"0.7208198",
"0.71626127",
"0.71588725",
"0.71588725",
"0.712312",
"0.7085555",
"0.7085555",
"... | 0.0 | -1 |
=========================== foreign key validations: =========================== | def set_concentrate_product
concentrate_product = ConcentrateProduct.find_by_concentrate_code(self.concentrate_code)
if concentrate_product != nil
self.concentrate_product = concentrate_product
return true
else
errors.add_to_base("value of field: 'concentrate_code' is invalid- it must be unique")
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_all_foreign_keys_valid!\n end",
"def check_foreign_key(field)\n val = self.send(field)\n if val.is_a? ForeignKey\n add_foreign_key_message_to_errors(val)\n end\n end",
"def check_add_foreign_key(*args); end",
"def foreign_key_present?\n false\n end",
"def forei... | [
"0.7600098",
"0.7280537",
"0.72237355",
"0.72103435",
"0.72103435",
"0.71699786",
"0.70691454",
"0.70154715",
"0.6979766",
"0.69792753",
"0.6944212",
"0.6933209",
"0.6933209",
"0.6887509",
"0.6855989",
"0.68030375",
"0.6676975",
"0.6676975",
"0.66574645",
"0.65902704",
"0.657... | 0.0 | -1 |
POST /batches/phs POST /batches/phs.xml | def update
@batch = Batch.find(params[:id])
@batch.phing = true
if @batch.update(batch_params)
flash[:notice] = 'Batch was successfully updated.'
redirect_to(no_experiment_batches_phs_path)
else
render :action => "edit"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_xml(xml) \r\n xml.batch(:ID => 1) do\r\n xml.tag!(:bat_date, date)\r\n xml.tag!(:bat_id, batchid)\r\n xml.tag!(:site_num, facility.sitecode.rjust(5, '0'))\r\n xml.tag!(:bat_time, (batch_time.strftime(\"%H:%M:%S\") unless batch_time.blank?))\r\n xml.tag!(:chk_vol, (correspon... | [
"0.54971373",
"0.5490543",
"0.5472339",
"0.54272944",
"0.53963995",
"0.5368414",
"0.5368102",
"0.5344969",
"0.5323923",
"0.5308458",
"0.5262487",
"0.5259461",
"0.52356464",
"0.5234911",
"0.5226616",
"0.5196725",
"0.5195663",
"0.5183887",
"0.5179823",
"0.5136382",
"0.5106146",... | 0.5362797 | 7 |
Returns the desired medium | def find_medium(id)
self.class.get("/media/#{id}.json?apikey=#{apikey}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def medium\n return @medium\n end",
"def medium=(value)\n @medium = value\n end",
"def primary_medium\n primary_source_medium = source_media.select{ |sm| sm.main }.compact.first\n primary_source_medium.medium if primary_source_medium\n end",
"def med... | [
"0.84721154",
"0.7718283",
"0.7604308",
"0.7036388",
"0.6958076",
"0.6820252",
"0.67902035",
"0.67851937",
"0.6578693",
"0.65340817",
"0.65340817",
"0.65340817",
"0.653344",
"0.6506953",
"0.646823",
"0.646823",
"0.6459873",
"0.64381135",
"0.64381135",
"0.6429245",
"0.6358977"... | 0.5717418 | 60 |
Returns the desired oauth | def find_oauth_by_medium(id)
self.class.get("/media/#{id}/oauth.json?apikey=#{apikey}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_oauth\n @attributes[:auth_oauth]\n end",
"def oauth_consumer\n @oauth_consumer\n end",
"def oauth_authentication; end",
"def auth\r\n OAuth2\r\n end",
"def find_oauth_access_token\n end",
"def oauth?\n type == 'OAuth'\n end",
"def oauth_version\n ... | [
"0.81503874",
"0.77859336",
"0.77722704",
"0.7691317",
"0.7483402",
"0.7400398",
"0.734623",
"0.73410296",
"0.72678876",
"0.7202432",
"0.7202432",
"0.7197423",
"0.71471417",
"0.7140177",
"0.7138968",
"0.71261394",
"0.7121639",
"0.7121254",
"0.70985574",
"0.70602036",
"0.70337... | 0.0 | -1 |
Returns the oauthcallbacks related to the medium | def find_oauth_callback_by_medium(*args)
raise ArgumentError.new('The method `find_oauth_callback_by_medium` requires 2 arguments(medium-id and oauth-token)') if args.size != 2
self.class.get("/media/#{args[0]}/oauth_callback.json?apikey=#{apikey}", :query => {:oauth_verifier => args[-1]})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oauth_consumer\n @oauth_consumer\n end",
"def oauth_authentication; end",
"def oauth2callback\n @g_cal_api.oauth2callback\n end",
"def oauth_callback_url\n end",
"def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end",
"def find_oauth_access_token\n end"... | [
"0.6826894",
"0.62099934",
"0.6203541",
"0.6184351",
"0.61107403",
"0.6026236",
"0.60022473",
"0.59500957",
"0.58422506",
"0.5841418",
"0.57753676",
"0.5766988",
"0.5646613",
"0.5638174",
"0.5589162",
"0.55856544",
"0.5574597",
"0.5561552",
"0.5557374",
"0.55456096",
"0.55452... | 0.6446529 | 1 |
Creates a new medium | def create_medium(options={})
self.class.post("/media.json?apikey=#{apikey}", :query => { :medium => options })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @medium = Medium.new(medium_params)\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render :show, status: :created, location: @medium }\n else\n format.html { render :new... | [
"0.7795342",
"0.7795342",
"0.77414906",
"0.7645764",
"0.7528351",
"0.74472284",
"0.7328954",
"0.73088735",
"0.7297219",
"0.72354144",
"0.72110885",
"0.7087005",
"0.6997907",
"0.6957633",
"0.68900746",
"0.68021196",
"0.675453",
"0.6712656",
"0.66928697",
"0.6653775",
"0.658510... | 0.7259082 | 9 |
Updates the desired medium | def update_medium(id, options={})
self.class.put("/media/#{id}.json?apikey=#{apikey}", :query => {:medium => options}, :body => {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end",
"def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end",
"def update\n update_medium\n end",
"def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7968474",
"0.7968474",
"0.77928287",
"0.75788325",
"0.743611",
"0.74160534",
"0.7362387",
"0.7362387",
"0.73233086",
"0.72820574",
"0.72622573",
"0.71883327",
"0.7176715",
"0.71720606",
"0.71720606",
"0.71720606",
"0.7123768",
"0.7064551",
"0.7056599",
"0.7056599",
"0.7008... | 0.68427664 | 22 |
GET /critical_success_factors GET /critical_success_factors.json | def index
@critical_success_factors = CriticalSuccessFactor.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @critical_success_factors }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end",
"def show\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n fo... | [
"0.7542314",
"0.7035276",
"0.68878484",
"0.68253",
"0.67529523",
"0.6357071",
"0.6354711",
"0.6312489",
"0.6142595",
"0.61006904",
"0.5948285",
"0.5894403",
"0.5838905",
"0.57365304",
"0.57193136",
"0.56475127",
"0.56422484",
"0.5605748",
"0.5488379",
"0.546513",
"0.5338059",... | 0.7713718 | 0 |
GET /critical_success_factors/1 GET /critical_success_factors/1.json | def show
@critical_success_factor = CriticalSuccessFactor.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @critical_success_factor }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\n @critical_success_factors = CriticalSuccessFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factors }\n end\n end",
"def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n form... | [
"0.7760992",
"0.7490721",
"0.71550596",
"0.70704776",
"0.6976947",
"0.681886",
"0.6579742",
"0.6507896",
"0.6408299",
"0.6123977",
"0.6086433",
"0.60767424",
"0.59294486",
"0.57923096",
"0.5729273",
"0.56938595",
"0.56392246",
"0.56218475",
"0.5566322",
"0.55270743",
"0.55025... | 0.74050236 | 2 |
GET /critical_success_factors/new GET /critical_success_factors/new.json | def new
@critical_success_factor = CriticalSuccessFactor.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @critical_success_factor }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end",
"def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # ... | [
"0.8038973",
"0.7913525",
"0.74515563",
"0.7220769",
"0.69315344",
"0.6803707",
"0.6773709",
"0.6693067",
"0.6659558",
"0.6656785",
"0.6559581",
"0.6552675",
"0.6540636",
"0.65270823",
"0.6507469",
"0.64759463",
"0.64443916",
"0.6435019",
"0.6427685",
"0.64134604",
"0.6408607... | 0.8251769 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.