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 |
|---|---|---|---|---|---|---|
Waits until searchbar loading starts and stops Signalize that search results finished loading Wrapped with rescue as initial loading may not appear | def wait_for_results_to_load
wait_until { searchbar_element.attribute('class').include?(Constants::SEARCHING_CLASS) }
rescue StandardError
puts 'Loading in search modal didn\'t appear!'
ensure
wait_until { !searchbar_element.attribute('class').include?(Constants::SEARCHING_CLASS) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(string)\n sleep 1\n search_input_element.when_visible Utils.short_wait\n self.search_input = string\n search_input_element.send_keys :enter\n wait_for_spinner\n end",
"def search_for_proffesional()\r\n @search_dropdown.is_element_present_with_wait?()\r\n @search_dropdown.clic... | [
"0.62525296",
"0.61154616",
"0.6077972",
"0.5962887",
"0.59597766",
"0.5923339",
"0.58947",
"0.58914787",
"0.58825445",
"0.5837245",
"0.5789094",
"0.5769237",
"0.5683382",
"0.56525195",
"0.562325",
"0.55705905",
"0.5569441",
"0.55615795",
"0.5532746",
"0.5531461",
"0.5495205"... | 0.7829461 | 0 |
Get price from search result | def price(result)
tmp = /(?<price>\d+,\d+)/.match(result.div(Selectors::FAST_SEARCH_MODAL[:result][:price]).text)
!tmp.nil? ? tmp[:price].to_f : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price\n response[\"price\"]\n end",
"def get_price\n @price = @contents[/(?<=(\"priceLarge\">)).*?(?=<)/]\n if @price == nil\n @price =@contents[/(?<=(\"rentPrice\">)).*?(?=<)/]\n end\n @price\n end",
"def car_price(price_text)\n\tprice = price_text.css('span.result-price').te... | [
"0.6936209",
"0.68720925",
"0.6727956",
"0.6590178",
"0.6546238",
"0.65108395",
"0.64137745",
"0.63936573",
"0.63936573",
"0.63826746",
"0.6382372",
"0.6374913",
"0.6362033",
"0.6332329",
"0.6313836",
"0.627887",
"0.62327904",
"0.6217092",
"0.6214473",
"0.6188919",
"0.6185502... | 0.8018943 | 0 |
Get title from search result | def title(result)
result.link(Selectors::FAST_SEARCH_MODAL[:result][:title]).text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title_for_search\n (title || \"\").strip.sub(/\\Athe\\s+/i, \"\").sub(/\\Aan?\\s+/i, \"\")\n end",
"def searchtitle\n end",
"def to_search_string\n\t\tself.title\n\tend",
"def result_title(**options)\n css('.search-results--title a', options)\n end",
"def get_search_results_title\n sear... | [
"0.76551443",
"0.7646485",
"0.75188863",
"0.74139285",
"0.73980516",
"0.7352759",
"0.73513365",
"0.7343886",
"0.7138289",
"0.71213794",
"0.7089628",
"0.7045777",
"0.68526286",
"0.6848109",
"0.6848109",
"0.6794248",
"0.67793995",
"0.6774228",
"0.6773584",
"0.67644274",
"0.6762... | 0.82685584 | 0 |
scope :overlaps, >(date, date_ended) do where "(DATEDIFF(date, ?) DATEDIFF(?, date_ended)) >= 0", date_ended, date end | def overlaps?
overlaps.exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlaps?(another)\n (start_date - another.end_date) * (another.start_date - end_date) >= 0\n end",
"def overlaps\n siblings.overlaps date, date_ended\n end",
"def overlaps?(other)\n \t((start_date - other.end_date) * (other.start_date - end_date)) >= 0\n \tend",
"def overlap(dates)\n (out... | [
"0.67826855",
"0.67357945",
"0.6612544",
"0.6422833",
"0.6341004",
"0.62248033",
"0.6174983",
"0.6118773",
"0.6111059",
"0.61016095",
"0.5994801",
"0.59860134",
"0.59666723",
"0.58857554",
"0.5881931",
"0.5866888",
"0.58338815",
"0.57931453",
"0.57796234",
"0.57746744",
"0.57... | 0.0 | -1 |
Others are models to be compared with your current model you can get these with a where for example | def overlaps
siblings.overlaps date, date_ended
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model\n @filtered_rset.model\n end",
"def models\n Model.all.select {|model| model.make_id == id}\n end",
"def related_models\n via_assay = assays.collect(&:models).flatten.uniq.compact\n via_assay | models\n end",
"def query(model, hash)\n conditions = conditions(model, hash)\n ... | [
"0.61702764",
"0.60615283",
"0.5865445",
"0.58603716",
"0.58412534",
"0.5831614",
"0.58086485",
"0.58035094",
"0.5783998",
"0.57544917",
"0.5702722",
"0.56948155",
"0.56699",
"0.5667824",
"0.56615156",
"0.5599025",
"0.5588426",
"0.5584257",
"0.5583446",
"0.5581444",
"0.557704... | 0.0 | -1 |
1 is when you have a nil id, so you will get all persisted user absences | def siblings
#user = User.find_by_id(:user_id)
#user = absence.user
user.absences.where('id != ?', id || -1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_ids\n self.class.where(id: id).user_ids\n end",
"def user_ids\n self.users.collect{|ud| ud.id}\n end",
"def household_user_ids\n @household_user_ids || household.users.where.not(id: id).pluck(:id)\n end",
"def household_user_ids\n @household_user_ids || household.users.where.not(id: i... | [
"0.6428475",
"0.60213995",
"0.59401715",
"0.59401715",
"0.5917502",
"0.5905259",
"0.59042656",
"0.5837193",
"0.57562447",
"0.5709405",
"0.5680225",
"0.5602214",
"0.5587055",
"0.55841714",
"0.5573449",
"0.55592895",
"0.5557196",
"0.5551972",
"0.5551808",
"0.5531821",
"0.552883... | 0.61666864 | 1 |
its elements in place; that is, mutate the Array passed into this method. The return value should be the same Array object. You may not use Arrayreverse or Arrayreverse!. | def reverse!(array)
reversed_array = []
array.size.times { reversed_array << array.pop }
reversed_array.size.times { array << reversed_array.shift }
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse!(array)\n copy = array.clone\n index = -1\n\n copy.each do |element|\n array[index] = element\n index -= 1\n end\n\n array\nend",
"def mutate(arr)\n arr.pop\n end",
"def mutate(arr)\n arr.pop # (no bang! here) mutates\nend",
"def mutate(array)\n array.pop \nend",
"def rever... | [
"0.77208924",
"0.7538553",
"0.7481637",
"0.74581176",
"0.7454486",
"0.7443002",
"0.74161816",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73866385",
"0.73725986",
"0.7337862",
"0.7331521",
"0... | 0.68545127 | 78 |
workaround for situation when touching input field is required | def enter_text_to_field(text, field)
puts "I'm going to touch #{field} label"
field.to_s.start_with?("UI") ? touch("#{field}") : touch("* marked:'#{field}'")
wait_for_keyboard
keyboard_enter_text text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_required?\n false\nend",
"def has_required?; end",
"def has_required?\n false\n end",
"def validated?; end",
"def test_mandatory_field(field, fieldname)\n if field.nil?\n show_usage\n ui.fatal(\"You must specify a #{fieldname}\")\n exit 1\n end\n end",
"de... | [
"0.67806154",
"0.66981375",
"0.66720337",
"0.6203933",
"0.61913556",
"0.6144857",
"0.6056195",
"0.60541815",
"0.60541296",
"0.60419923",
"0.60091436",
"0.59767044",
"0.5965775",
"0.5960355",
"0.59601814",
"0.59601814",
"0.5958413",
"0.5951747",
"0.59500873",
"0.59451765",
"0.... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
current_min_val = nil
current_key_min_val = nil
name_hash.each do |key, value|
if current_min_val == nil
current_min_val = value
current_key_min_val = key
else
if current_min_val> value
current_min_val = value
current_key_min_val = key
end
end
end
current_key_min_val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
returns hello name, returns buddy if no name | def hello(name="buddy")
puts "Hey #{name}!!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hello(name)\n\tif name == \"John\"\n\t\t\"Hello #{name}!\"\n\telsif name == \"Kevin\"\n\t\t\"Hey there #{name}!\"\n\telse\n\t\t\"I don't know you!\"\n\tend\nend",
"def greeting(name)\n if name[-1] == '!'\n name.chop!\n return \"HELLO #{name.upcase}. WHY ARE WE SCREAMING?\"\n else\n return \"Hello ... | [
"0.7412608",
"0.73702824",
"0.7182078",
"0.7144414",
"0.699603",
"0.6921822",
"0.6899804",
"0.68931115",
"0.6888826",
"0.68612283",
"0.68606126",
"0.6856712",
"0.68457985",
"0.6839507",
"0.68218535",
"0.67942",
"0.6760889",
"0.6743272",
"0.673024",
"0.67288435",
"0.6721489",
... | 0.0 | -1 |
creates madlib from input | def madlib(name,subject)
puts "#{name}\'s favorite subject is #{subject}!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def madlib_inputs\n print \"Enter a noun: \" \n noun = gets.chomp\n print \"Enter a verb: \" \n verb = gets.chomp\n print \"Enter an adjective: \" \n adjective = gets.chomp\n print \"Enter an adverb: \" \n adverb = gets.chomp\n madlib_line(noun, verb, adjective, adverb)\nend",
"def initialize a... | [
"0.61428154",
"0.57829887",
"0.5695304",
"0.5635148",
"0.56347096",
"0.5472786",
"0.5452885",
"0.54521567",
"0.5444938",
"0.54325706",
"0.5413763",
"0.5355913",
"0.53158",
"0.5295541",
"0.52633554",
"0.52633554",
"0.52633554",
"0.5257244",
"0.52327573",
"0.523213",
"0.5203886... | 0.0 | -1 |
calculates total bill amount | def totalAmount(bill,service)
case service
when "good"
puts bill*0.20+bill
when "fair"
puts bill*0.15+bill
when "bad"
puts bill*0.10+bill
else
puts "bad input!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total(bill)\n sum=0.0\n bill.items.each do |i|\n sum += i.price\n end\n return sum\n end",
"def total \n\t\t@Total_bill = @bill_amount + @tip_rate_calc\t\n\t \tputs \"The total bill is £#{@Total_bill}\"\n\tend",
"def total_amount(bill_tip)\n\treturn tip_amount(bill_amount) + bill_tip\nend... | [
"0.8124346",
"0.7952016",
"0.7876717",
"0.7612508",
"0.7498274",
"0.7405199",
"0.7366001",
"0.73318535",
"0.73318535",
"0.7288157",
"0.7252242",
"0.7248589",
"0.72283494",
"0.71230793",
"0.7119002",
"0.7098384",
"0.7094702",
"0.7081555",
"0.7071782",
"0.70641285",
"0.7062959"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
try to find any factor (not necessarily a prime) | def try_find_factor
return @trivial_factor if defined?(@trivial_factor)
catch(:factor_found) do
while true
p :foo
select_q
solve_roots
sieve
@ws.each_with_index do |w, i|
check_relation(i - @m) if w > @test_value
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_factors(num)\n factors(num).select { |factor| prime?(factor) }\nend",
"def prime_factors(num)\n factors(num).select {|n| prime?(n)}\nend",
"def prime_factors(num)\n facs = (1..num).select {|x| num % x == 0 }\n facs.select {|x| prime?(x)}\nend",
"def factors(num)\n prime?(num) ? [1, num].uniq ... | [
"0.7907756",
"0.78749526",
"0.77887976",
"0.76656526",
"0.7663699",
"0.76551443",
"0.7645461",
"0.7634891",
"0.76120263",
"0.75596136",
"0.7558131",
"0.75569403",
"0.75283796",
"0.74987954",
"0.7427347",
"0.7422791",
"0.7391821",
"0.7383362",
"0.7359156",
"0.73374987",
"0.732... | 0.70116395 | 62 |
Selects Q(x) = Ax^2 + Bx + C for quadratic sieve | def select_q
# find a prime D such that (kN | D) = 1 and D = 3 mod 4
begin
@d = @base_d + @diff_d
@diff_d = @diff_d > 0 ? -@diff_d : 4 - @diff_d
end until Utils.kronecker(@kn, @d) == 1 && PrimalityTest.probable_prime?(@d) != false && !@ps.include?(@d)
# select coefficients (see the paper)
@a = @d * @d
h0 = Utils.mod_pow(@kn, @d / 4, @d)
h1 = (@kn * h0) % @d
# assert: h1*h1 = kN mod D
# assert: h0*h1 = 1 mod D
h2 = (Utils.mod_inv(2, @d) * h0 * ((@kn - h1 * h1) / @d)) % @d
# assert: kN - h1^2 = 0 mod D
@b = (h1 + h2 * @d) % @a
@b -= @a if @b[0] == 0
# assert: B^2 = kN mod 4A
#@c = (@b * @b - @kn) / (4 * @a) # not needed
# compute real roots of Q(x) = 0
s = Utils.integer_square_root(@kn)
@real_root_1 = (-@b - s) / (2 * @a)
@real_root_2 = (-@b + s) / (2 * @a)
# x is between real roots if @real_root_1 <= x && x <= @real_root_2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sieve(limit)\n bound = Math.sqrt(limit).ceil\n sieve = (0..limit+1).collect{ true }\n p = 2\n while !p.nil? && p <= bound\n q = p*p\n while q <= limit\n sieve[q] = false\n q = q + p\n end\n p =(p+1 .. limit).find{ |n| sieve[n] }\n end\n (2..limit).select{ |n| sieve[n]}\nend",
"def... | [
"0.64264363",
"0.6386215",
"0.62180555",
"0.61750746",
"0.60805523",
"0.59970003",
"0.5952082",
"0.59482574",
"0.59405094",
"0.5887926",
"0.58816886",
"0.5842701",
"0.5812809",
"0.57628536",
"0.5756248",
"0.5725705",
"0.57030004",
"0.5688545",
"0.56599027",
"0.5649688",
"0.56... | 0.65918964 | 0 |
Computes the roots of Q(x) = 0 mod p (p in the factor base) | def solve_roots
@roots = []
@ps.zip(@sqrts) do |p, s|
a_inv = Utils.mod_inv(2 * @a, p)
x1 = (-@b + s) * a_inv % p
x2 = (-@b - s) * a_inv % p
@roots << [x1, x2]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primitive_root(p)\r\n\t\tp_m1 = p - 1\r\n\t\tcheck_order = factorize(p_m1)\r\n\t\tcheck_order.shift\r\n\t\thalf_p_m1 = p_m1 >> 1\r\n\t\tcheck_order.map!{|f| half_p_m1 / f.first}\r\n\r\n\t\ta = 1\r\n\t\tloop do\r\n\t\t\ta += 1\r\n\r\n\t\t\tnext unless -1 == kronecker_symbol(a, p)\r\n\t\t\tcheck = true\r\n\t\t\t... | [
"0.6456768",
"0.63651526",
"0.6210536",
"0.5785191",
"0.5782372",
"0.573949",
"0.5645935",
"0.5573314",
"0.55305463",
"0.54439163",
"0.5437956",
"0.5387495",
"0.53729135",
"0.53715765",
"0.53381264",
"0.52762336",
"0.52762336",
"0.52762336",
"0.52694935",
"0.5268611",
"0.5244... | 0.57353777 | 6 |
Performs the quadratic sieve | def sieve
@ws.fill(0)
@ps.zip(@log_ps, @roots) do |p, lp, (s1, s2)|
((@m + s1) % p).step(2 * @m, p) {|i| @ws[i] += lp }
((@m + s2) % p).step(2 * @m, p) {|j| @ws[j] += lp }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sieve_of_e(n)\n a = (0...n).to_a\n a[0] = nil\n a[1] = nil\n (2..Math.sqrt(n)).each do |i|\n if a[i]\n it = 0\n j = i * i\n while j <= n\n a[j] = nil\n it += 1\n j = i * i + i * it\n end\n end\n end\n a.select{|i| i}\nend",
"def sieve(limit)\n bound = Mat... | [
"0.7099432",
"0.66923326",
"0.66884094",
"0.6681364",
"0.66439176",
"0.6533286",
"0.6528946",
"0.64790267",
"0.64559245",
"0.64559245",
"0.64559245",
"0.6431844",
"0.6423487",
"0.63935995",
"0.6385537",
"0.63393414",
"0.63242906",
"0.6294681",
"0.6292484",
"0.6264476",
"0.624... | 0.7190201 | 0 |
Tests whether Q(x) is actually a product of factor bases | def check_relation(x)
h, qx = compute_q(x)
return if qx == 0
es, l = exponent_bitvector(qx)
# discard this x if the residue L is too big
return if l > @pmax ** @t
if l == 1
# complete relation found:
# Q(x) = p0^e0 * p1^e1 * ... * pk^ek (pi in the factor base)
qx_vec = Hash.new(0)
PrimeFactorization.prime_factorization(qx) {|p, e| qx_vec[p] += e }
collect_relation(es, h, qx_vec)
elsif @incomplete_relations[l]
# large prime procedure:
# make a complete relation by multiplying two incomplete relations
es2, h2, qx2 = @incomplete_relations[l]
# XXX: use FactoredInteger
qx_vec = Hash.new(0)
PrimeFactorization.prime_factorization(qx) {|p, e| qx_vec[p] += e }
PrimeFactorization.prime_factorization(qx2) {|p, e| qx_vec[p] += e }
collect_relation(es ^ es2, h * h2 % @kn, qx_vec)
else
@incomplete_relations[l] = [es, h, qx]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_base?\n base_quantities.size == 1 &&\n @base_quantity_hash[base_quantities.first] == 1 ? true : false\n end",
"def factor?(other)\n s = self.base.unit.map{ |u| [u.type] * u.power }.flatten\n o = other.base.unit.map{ |u| [u.type] * u.power }.faltten\n (s - o).empty?\n en... | [
"0.61770433",
"0.6041318",
"0.59042805",
"0.5884969",
"0.58818233",
"0.5714439",
"0.56896925",
"0.5650013",
"0.56462157",
"0.5617125",
"0.55486",
"0.5522384",
"0.55212104",
"0.546149",
"0.544762",
"0.53752816",
"0.5339599",
"0.5318485",
"0.5311138",
"0.5301445",
"0.52998525",... | 0.5604554 | 10 |
Adds a complete relation found to gaussian elimination list | def collect_relation(es, h, q)
#p "%0#{ @ps.size + 1 }b" % es
@elim[es] = [h, q]
if @elim.size > 0.9 * @f && @elim.size % [1, @f / 100].max == 0
@elim.eliminate do |relations|
# factor candidate found
check_factor_candidate(relations)
end
end
if @elim.size > @f * 1.5
raise Failed, "failed to find a factor: #{ @n }"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_elimination(ary)\n lead = 0\n rows = ary.size\n cols = ary[0].size\n rary = convert_to(ary, :to_r) # use rational arithmetic\n rows.times do |r|\n i = r\n # swap rows i and r \n rary[i], rary[r] = rary[r], rary[i]\n # normalize row r\n v = rary[r][lead]\n ... | [
"0.5549202",
"0.52431583",
"0.5224222",
"0.4864728",
"0.48095772",
"0.4726258",
"0.46909428",
"0.46570796",
"0.46179083",
"0.4585003",
"0.45579606",
"0.4547078",
"0.45445237",
"0.4529236",
"0.45256144",
"0.45239824",
"0.45224762",
"0.45168054",
"0.4515235",
"0.4500817",
"0.45... | 0.5014946 | 3 |
Computes and checks a factor candidate | def check_factor_candidate(relations)
# computes the factor candidate
p1 = 1
p2_vec = Hash.new(0) # XXX: use FactoredInteger
relations.each do |h, qx_vec|
p1 = p1 * h % @kn
qx_vec.each {|p, e| p2_vec[p] += e }
end
p2 = 1
p2_vec.each {|p, e| p2 = (p2 * Utils.mod_pow(p, e / 2, @kn)) % @kn }
return if p1 == p2 || (p1 + p2) % @kn == 0
factor = (p1 + p2).gcd(@n)
# check the factor candidate
if factor != 1 && factor != @n
throw :factor_found, factor
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factor\n @factor if valid?\n end",
"def to_be_a_factor?\n return false if @factor_percentage.nil? || @factor_of.nil?\n Random.new().rand(1..100) <= @factor_percentage\n end",
"def isFactor?(num, target)\n if target % num == 0\n return true\n else\n return false\n end\nend"... | [
"0.7037866",
"0.65970784",
"0.6473576",
"0.6292703",
"0.6191828",
"0.6113283",
"0.6079283",
"0.5977127",
"0.5970577",
"0.5952343",
"0.59196603",
"0.58988565",
"0.5880088",
"0.5867919",
"0.5862294",
"0.576431",
"0.5747403",
"0.5724541",
"0.5690276",
"0.56676096",
"0.5636937",
... | 0.73447615 | 0 |
Factorizes n in factor base and returns an exponent bitvector | def exponent_bitvector(n)
vec = 0
if n < 0
vec = 1
n = -n
end
bit = 2
([2] + @ps).each do |p|
e = false
while n % p == 0
n /= p
e = !e
end
vec |= bit if e
bit <<= 1
end
return vec, n
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exponent(b, n)\n\nend",
"def exponent(b, n)\n\nend",
"def exponent(b, n)\n\nend",
"def power_of_n(num, exponent)\n num ** exponent\nend",
"def exponent(b, n)\n return 1 if n == 0\n\n if n > 0\n b * exponent(b, n - 1)\n else\n 1.0/b * exponent(b, n + 1)\n end\nend",
"def prime_factorisation... | [
"0.7324851",
"0.7324851",
"0.7324851",
"0.7195784",
"0.69613457",
"0.69559914",
"0.6952771",
"0.6952771",
"0.6944746",
"0.68444556",
"0.6821498",
"0.68045324",
"0.67849773",
"0.6771909",
"0.66627616",
"0.6653572",
"0.6637049",
"0.6636685",
"0.6617645",
"0.6608884",
"0.6595477... | 0.78779083 | 0 |
This sweeper is going to keep an eye on the Category model If our sweeper detects that a Category was created call this | def after_create(category)
expire_cache_for(category)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_category\n @category = TestCategory.new(params[:category])\n @category.save\n @categories = TestCategory.find(:all)\n redraw 'categories'\n end",
"def new\n @category = Category.new(position: Category.current.count + 1)\n end",
"def new\n # category instance\n @category = Cate... | [
"0.6434752",
"0.64302254",
"0.6348334",
"0.63263035",
"0.6301574",
"0.62874866",
"0.6228496",
"0.6183822",
"0.61329085",
"0.6115172",
"0.6105295",
"0.6093534",
"0.6083053",
"0.6059685",
"0.60528916",
"0.60528916",
"0.60354364",
"0.60265356",
"0.6021348",
"0.60167027",
"0.6010... | 0.0 | -1 |
If our sweeper detects that a Category was updated call this | def after_update(category)
expire_cache_for(category)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_category_counter\r\n end",
"def after_update(category)\r\n expire_cache_for(category)\r\n end",
"def cat_update_item_count\n self.categories.each do |category|\n if (category.displayed_items.count - 1) == category.item_count\n category.inc_item_count\n end\n if (c... | [
"0.71063584",
"0.67674506",
"0.6566556",
"0.64799625",
"0.6321847",
"0.62881196",
"0.62468964",
"0.62468964",
"0.62421495",
"0.62371606",
"0.6225743",
"0.62139785",
"0.62107503",
"0.6206931",
"0.61951864",
"0.616668",
"0.6097255",
"0.6059393",
"0.60291725",
"0.5981489",
"0.59... | 0.66931516 | 2 |
If our sweeper detects that a Category was deleted call this | def after_destroy(category)
expire_cache_for(category)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_category\n if self.foods.empty?\n self.destroy\n else\n false\n end\n end",
"def destroy_updated_orphaned_category\n old_category_id = self.exercise_category_id\n yield\n if old_category_id == self.exercise_category_id\n return true\n else\n exercisesArray = E... | [
"0.71466005",
"0.69843566",
"0.681704",
"0.66492707",
"0.66260225",
"0.6591367",
"0.65554804",
"0.6465815",
"0.64519006",
"0.6445815",
"0.642819",
"0.6427577",
"0.64275306",
"0.6402867",
"0.6401622",
"0.63345635",
"0.6327304",
"0.6303341",
"0.63018674",
"0.629787",
"0.6292007... | 0.6296222 | 20 |
Get locale from toplevel domain or return nil if such locale is not available You have to put something like: 127.0.0.1 application.com 127.0.0.1 application.it 127.0.0.1 application.pl in your /etc/hosts file to try this out locally | def extract_locale_from_tld
parsed_locale = request.host.split('.').last
I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_locale_from_subdomain\n locale = @rh.match( /(.+)\\.demowatch\\.[a-z]{2,3}$/i)[1]\n return locale if ( I18N_ALL_LANGUAGES.include?( locale))\n return nil\n end",
"def extract_locale_from_tld\n parsed_locale = request.host.split('.').last\n (I18n.available_locales.include? parsed_locale) ?... | [
"0.82068807",
"0.77737135",
"0.7769094",
"0.7708247",
"0.76755786",
"0.76623964",
"0.76347065",
"0.7607036",
"0.75849897",
"0.7579934",
"0.7548153",
"0.75360245",
"0.7528092",
"0.7517102",
"0.7460089",
"0.74036855",
"0.7392892",
"0.7380483",
"0.7354874",
"0.7297215",
"0.72219... | 0.771984 | 4 |
Register a win in the Pokemon League for the player | def register_victory(mode = :league)
pokemon_array = []
$actors.each { |pkm| pokemon_array << pkm.clone }
victory = {
mode: mode,
team: pokemon_array,
play_time: $pokemon_party.trainer.play_time_text,
entry_date: Time.new
}
@player_victory << victory
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register\n show_dialog_waiting(Vocab.registration_processing, true)\n Graphics.update\n begin\n handle_response Online.register_new_player(@info_window.name, @info_window.avatar, @info_window.title.id)\n rescue InternetConnectionException\n Logger.error $!.message\n show_dialog(Vocab... | [
"0.69485605",
"0.6705696",
"0.6684012",
"0.6611631",
"0.6597581",
"0.65439767",
"0.6469806",
"0.64631414",
"0.64258885",
"0.62425584",
"0.6219855",
"0.61914814",
"0.61720973",
"0.61553144",
"0.61082315",
"0.61067194",
"0.60344046",
"0.6033177",
"0.6032962",
"0.6030123",
"0.60... | 0.7029927 | 0 |
url: author: clov year: 2022 | def partOne(file_path)
File.read(file_path)
.split("\n\n")
.map { |calories_per_elf| calories_per_elf.split("\n").map(&:to_i).sum }
.max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publication_year\n end",
"def url\n \"/announcements/#{self.year}/#{self.id}\"\n end",
"def author() headers['author'] end",
"def author; end",
"def derive_authors_year\n add_author_year(author_year_string) \n end",
"def authors(library)\nend",
"def author; @author; end",
"def author... | [
"0.679713",
"0.6492366",
"0.6420468",
"0.6354588",
"0.6210473",
"0.61228585",
"0.6055262",
"0.6055262",
"0.6049253",
"0.60018563",
"0.5995638",
"0.59931624",
"0.592023",
"0.5845166",
"0.58434236",
"0.57993644",
"0.5798268",
"0.5792699",
"0.5791047",
"0.57760316",
"0.5769867",... | 0.0 | -1 |
16 => 10000 15 => 01111 & 00000 n & (n1) == 0 | def power_of_two?(num)
return true if num == 1
(1..num).each do |n|
if 2**n == num
return true
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(n)\n n & 15\nend",
"def from_binary(n)\n# puts \"\\n\\n#{n} => #{n && n!=0}\\n\\n\"\n n && n!=0\nend",
"def from_binary(n)\n# puts \"\\n\\n#{n} => #{n && n!=0}\\n\\n\"\n n && n!=0\nend",
"def calc(n,k)\n # the expressions '(1<<n)-1' and '2**n-1' are equivalent\n (k & ((1<<n)-1)) =... | [
"0.76764286",
"0.74317914",
"0.74317914",
"0.71132433",
"0.69920576",
"0.6971657",
"0.6964527",
"0.6896667",
"0.6866177",
"0.67724335",
"0.66744107",
"0.66701025",
"0.6606582",
"0.6586756",
"0.65383935",
"0.6474958",
"0.64304423",
"0.641471",
"0.6405302",
"0.64044714",
"0.637... | 0.5692042 | 84 |
A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array. Example: Input: ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"] Output: ["catsdogcats","dogcatsdog","ratcatdogcat"] Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats"; "dogcatsdog" can be concatenated by "dog", "cats" and "dog"; "ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat". Note: The number of elements of the given array will not exceed 10,000 The length sum of elements in the given array will not exceed 600,000. All the input string will only include lower case letters. The returned elements order does not matter. | def find_all_concatenated_words_in_a_dict(words)
res = []
words.each do |original_word|
smaller_words = words.select { |word| word.length < original_word.length }
next if smaller_words.count < 2
permutations = create_permutations(smaller_words).map { |perm| perm.join }
p permutations
res << original_word if permutations.include?(original_word)
end
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_off_words(str,word_list)\n result = []\n better_list = word_list.select{|word| word.size == str.size}\n better_list.each do |word|\n i = 0\n count = 0\n while i < word.size\n count += 1 if word[i] == str[i]\n i += 1\n end\n result << word if word.size - count == 1\n end\n resu... | [
"0.6963589",
"0.6833551",
"0.6754303",
"0.6722626",
"0.6656487",
"0.656295",
"0.6530269",
"0.6476462",
"0.6417313",
"0.64155114",
"0.63479346",
"0.63423496",
"0.6340612",
"0.6334659",
"0.6331583",
"0.6331495",
"0.6329661",
"0.6323953",
"0.63137925",
"0.62690926",
"0.6259903",... | 0.63181674 | 18 |
Use callbacks to share common setup or constraints between actions. | def set_track_record
begin
@track_record = TrackRecord.find(params[:id])
rescue StandardError => e
render json: e.message , status: :Record_not_found
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def track_record_params
params.require(:track_record).permit(:description, :track_for, :created_by)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
This method spawns a thread | def answer_pings
@ping_thread = Thread.new do
begin
loop do
pkt = @tap.recv
p pkt
=begin
icmp = icmp_offset(pkt)
if icmp and pkt[icmp] == "\x08" #type == Echo Request
pkt[icmp, 1] = "\x00"
pkt[26, 4], pkt[30, 4] = pkt[30, 4], pkt[26, 4]
@tap.inject(pkt)
end
=end
end
rescue Object
$stderr.puts $!
$stderr.puts $@
Kernel.exit(1)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_thread #does this need to be its own thread?\n @@thread = Thread.new do\n self.run\n end\n end",
"def spawn_thread\n Thread.new{ run_thread }.tap do |t|\n t.abort_on_exception = true\n end\n end",
"def start_new_thread(username, params = {})\n $LOG.i \"running... | [
"0.7642397",
"0.72957313",
"0.70700276",
"0.68847656",
"0.68847656",
"0.68847656",
"0.68306917",
"0.6752685",
"0.6743945",
"0.6741217",
"0.66230565",
"0.66000235",
"0.65595585",
"0.64939696",
"0.64429706",
"0.6423834",
"0.6374436",
"0.6365108",
"0.63413334",
"0.63369906",
"0.... | 0.0 | -1 |
Return the MAC address of the tap device | def tap_mac
@sock.local_address.to_sockaddr[-6,6]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tap_mac\n @sock.local_address.to_sockaddr[-6, 6]\n end",
"def mac_addr\n if (mac_addr = @host.at('tag[name=mac-addr]'))\n mac_addr.inner_text\n end\n end",
"def mac_eth0\n eth0.mac_address\n end",
"def mac_address\n if NicView.empty_mac?(self[\"CurrentMACAddress... | [
"0.83977723",
"0.80760634",
"0.79051703",
"0.77710897",
"0.771872",
"0.7564563",
"0.74767035",
"0.7467397",
"0.74206096",
"0.74033487",
"0.73618954",
"0.73484516",
"0.7312582",
"0.7185115",
"0.7120693",
"0.7052921",
"0.70509046",
"0.6993652",
"0.6991944",
"0.6963051",
"0.6939... | 0.83929074 | 1 |
Wait for and return the next ping reply on the raw socket up to timeout | def ping_reply(timeout = 1.0)
loop do
st = Time.now.to_f
act = select([@sock], [], [@sock], timeout)
return nil if !act or act.first.empty?
pkt = @sock.recv(1514)
icmp = icmp_offset(pkt)
return pkt if icmp and pkt[icmp] == "\x00"
timeout = timeout - Time.now.to_f + st
return nil if timeout <= 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ping_reply(timeout = 1.0)\n loop do\n st = Time.now.to_f\n act = select([@sock], [], [@sock], timeout)\n return nil if !act or act.first.empty?\n pkt = @sock.recv(1514)\n icmp = icmp_offset(pkt)\n return pkt if icmp and pkt[icmp] == \"\\x00\" # type = Echo Reply\n timeou... | [
"0.79250467",
"0.6660202",
"0.6586769",
"0.6468295",
"0.64587885",
"0.64013356",
"0.63444674",
"0.63264894",
"0.6318368",
"0.6280331",
"0.62644374",
"0.62076694",
"0.6180209",
"0.6175194",
"0.61723536",
"0.6128659",
"0.60897255",
"0.60853463",
"0.6075624",
"0.60594916",
"0.60... | 0.78139144 | 1 |
Send the given raw layer2 packet to the tap | def inject(frame)
@sock.send(frame, 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_packet(payload); end",
"def send_packet(type, *args); end",
"def send(packet)\n id = Common.packet_to_id(packet)\n data = [id, [packet.to_a]].to_msgpack\n\n @stream.write Common.encode_u16(data.length)\n @stream.write data\n end",
"def send_packet(o... | [
"0.6778079",
"0.62881994",
"0.595831",
"0.5956806",
"0.5904392",
"0.5901166",
"0.57756746",
"0.5741143",
"0.57393867",
"0.56616384",
"0.56149364",
"0.55102456",
"0.55090064",
"0.55030715",
"0.5498355",
"0.54973173",
"0.5458583",
"0.5452441",
"0.54344827",
"0.54260266",
"0.540... | 0.0 | -1 |
Inject the ping, wait for a reply | def test_ping
@tt.sock.send(@ping, 0)
=begin
pong = @tt.ping_reply
assert_equal(42, pong.length)
assert_equal(pong[0, 6], @tt.tap_mac)
assert_equal(pong[30, 4], @ping[26, 4])
assert_equal(pong[26, 4], @ping[30, 4])
=end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_ping\n done\n end",
"def answer_pings\n\t\t@ping_thread = Thread.new do \n\t\t\tbegin\n\t\t\t\tloop do \n\t\t\t\t\tpkt = @tap.recv\n\t\t\t\t\ticmp = icmp_offset(pkt)\n\t\t\t\t\tif icmp and pkt[icmp] == \"\\x08\" #type == Echo Request\n\t\t\t\t\t\tpkt[icmp, 1] = \"\\x00\"\n\t\t\t\t\t\tpkt[26,... | [
"0.7021026",
"0.6859055",
"0.6825523",
"0.6821041",
"0.67719823",
"0.67679584",
"0.6755358",
"0.6702995",
"0.66381335",
"0.6636855",
"0.6563121",
"0.6555176",
"0.6546835",
"0.653526",
"0.6516619",
"0.6499136",
"0.6424626",
"0.6418448",
"0.6381148",
"0.63515",
"0.6339035",
"... | 0.6390251 | 18 |
Deletes recent rows based on timestamp, but also allows filtering by an auxilary timestamp column for the case where the primary one is not indexed on the target (such as the DFR reports, where imported_at is not indexed, but reporting date is). | def delete_recent(plan, since)
ensure_connection
query = db[plan.table_name].
filter("#{plan.timestamp} > ?", since)
if plan.aux_timestamp_column
query = query.filter(
"#{plan.aux_timestamp_column} > ?",
since - AUX_TIME_BUFFER
)
end
query.delete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_timestamps(schema)\n schema.reject { |item| ['created_at', 'updated_at'].include?(item[0]) }\n end",
"def delete_outdated_record(original_record)\n ETL::Engine.logger.debug \"deleting old row\"\n \n q = \"DELETE FROM #{dimension_table} WHERE #{primary_key} = #{original_record[... | [
"0.5907368",
"0.58840424",
"0.5818382",
"0.5658127",
"0.5587995",
"0.5566594",
"0.5367402",
"0.5334664",
"0.53298265",
"0.5285832",
"0.527302",
"0.51833034",
"0.51687795",
"0.515253",
"0.5148569",
"0.513192",
"0.5122776",
"0.5119667",
"0.5059042",
"0.5019429",
"0.50160223",
... | 0.632187 | 0 |
==== INPUT ==== two_way, from, to, departure_date, return_date, passengers, time ==== OUTPUT ==== listing jets (type, free slots, image) with estimate flight hours, price | def index
if search_params[:passengers]
@jets = Jet.where('seats > ?', search_params[:passengers])
else
@jets = Jet.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plane(origin, destination, date)\n\tparam_date = date[0,2] + \"%2f\" + date[2,2] + \"%2f20\" + date[4,2]\n\turl = \"http://www.tripsta.co.uk/airline-tickets/results?dep=#{origin}&arr=#{destination}&passengersAdult=1&passengersChild=0&passengersInfant=0&class=&airlineCode=&directFlightsOnly=0&extendedDates=0&is... | [
"0.60901016",
"0.59596014",
"0.5706287",
"0.5682865",
"0.5677658",
"0.5675675",
"0.5663752",
"0.5653522",
"0.5590477",
"0.5518671",
"0.5487704",
"0.54685456",
"0.5467955",
"0.5446345",
"0.53821707",
"0.53763455",
"0.53721124",
"0.53619343",
"0.535041",
"0.53464115",
"0.534106... | 0.0 | -1 |
GET /questionnaires GET /questionnaires.json | def index
@questionnaires = Questionnaire.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @questionnaires }
format.csv {
csv_string = CSV.generate do |csv|
csv << ["id", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13",
"q14", "q15", "q16", "q17", "q18", "q19", "q20", "q21", "q22", "q23", "q24", "q25", "q26", "q27",
"q28", "q29", "q30", "q31", "q32", "q33", "q34", "q35", "q36", "q37", "q38", "q39", "q40", "q41",
"q42", "q43", "q44", "q45", "q46", "q47", "q48", "q49", "q50", "q51", "q52", "q53", "q54", "q55",
"q56", "q57", "q58", "q59", "q60", "q61", "q62", "q63", "q64", "q65", "q66", "q67", "q68", "q69",
"q70", "q71", "q72", "q73", "q74", "q75", "q76", "q77", "q78", "q79", "q80", "q81", "q82", "q83",
"q84", "q85", "context1", "context2", "created_at", "updated_at", "participant_id"]
@questionnaires.each do |q|
csv << [q.id, q.q0, q.q1, q.q2, q.q3, q.q4, q.q5, q.q6, q.q7, q.q8, q.q9, q.q10, q.q11, q.q12, q.q13,
q.q14, q.q15, q.q16, q.q17, q.q18, q.q19, q.q20, q.q21, q.q22, q.q23, q.q24, q.q25, q.q26, q.q27,
q.q28, q.q29, q.q30, q.q31, q.q32, q.q33, q.q34, q.q35, q.q36, q.q37, q.q38, q.q39, q.q40, q.q41,
q.q42, q.q43, q.q44, q.q45, q.q46, q.q47, q.q48, q.q49, q.q50, q.q51, q.q52, q.q53, q.q54, q.q55,
q.q56, q.q57, q.q58, q.q59, q.q60, q.q61, q.q62, q.q63, q.q64, q.q65, q.q66, q.q67, q.q68, q.q69,
q.q70, q.q71, q.q72, q.q73, q.q74, q.q75, q.q76, q.q77, q.q78, q.q79, q.q80, q.q81, q.q82, q.q83,
q.q84, q.q85, q.context1, q.context2, q.created_at, q.updated_at, q.participant_id]
end
end
send_data csv_string, :type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=questionnaires.csv"
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @questionnaires = @instance.questionnaires\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questionnaires }\n end\n end",
"def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n ... | [
"0.75763637",
"0.6953089",
"0.692888",
"0.6895143",
"0.6794665",
"0.6794665",
"0.6794665",
"0.6792777",
"0.6698487",
"0.6696715",
"0.6696715",
"0.6687998",
"0.667861",
"0.6629849",
"0.6621805",
"0.6575555",
"0.63936925",
"0.6362681",
"0.6336179",
"0.632804",
"0.63277745",
"... | 0.0 | -1 |
GET /questionnaires/1 GET /questionnaires/1.json | def show
@questionnaire = Questionnaire.find(params[:id])
respond_to do |format|
format.html
format.json { render json: @questionnaire }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @questionnaires = @instance.questionnaires\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questionnaires }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show... | [
"0.742471",
"0.7089278",
"0.7089278",
"0.6979919",
"0.68588394",
"0.68273973",
"0.670289",
"0.667116",
"0.6660555",
"0.6644325",
"0.662616",
"0.6584409",
"0.6584409",
"0.6584409",
"0.65730816",
"0.65534264",
"0.65438294",
"0.6525332",
"0.65009725",
"0.6489891",
"0.6481722",
... | 0.7290521 | 1 |
GET /questionnaires/new GET /questionnaires/new.json | def new
@questionnaire = current_questionnaire || Questionnaire.new
if @questionnaire.step > 13
redirect_to goodbye_path
return
end
respond_to do |format|
format.html { render "questionnaires/steps/step#{@questionnaire.step}" }
format.json { render json: @questionnaire }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @questionnaire = Questionnaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j... | [
"0.7891905",
"0.7651504",
"0.7651504",
"0.7651504",
"0.7651504",
"0.7651504",
"0.76292986",
"0.7617745",
"0.7588937",
"0.7588706",
"0.75829035",
"0.75256145",
"0.7442048",
"0.74219865",
"0.7404302",
"0.7374613",
"0.7363282",
"0.73619884",
"0.7351376",
"0.73320603",
"0.732945"... | 0.0 | -1 |
POST /questionnaires POST /questionnaires.json | def create
@questionnaire = @participant.build_questionnaire(params[:questionnaire])
@questionnaire.step = 1
respond_to do |format|
if @questionnaire.save
format.html { redirect_to new_questionnaire_path }
# format.json { render json: @questionnaire, status: :created, location: @questionnaire }
else
format.html { render "questionnaires/steps/step0" }
# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redire... | [
"0.6628127",
"0.6585721",
"0.6516484",
"0.6485117",
"0.6454647",
"0.6394063",
"0.6381477",
"0.63798666",
"0.63659567",
"0.63437366",
"0.63324606",
"0.62913746",
"0.6288558",
"0.6235486",
"0.6231012",
"0.6214164",
"0.6159615",
"0.614689",
"0.6143025",
"0.61364704",
"0.6117868"... | 0.6333206 | 10 |
PUT /questionnaires/1 PUT /questionnaires/1.json | def update
@questionnaire = current_questionnaire
@questionnaire.step += 1
respond_to do |format|
if @questionnaire.update_attributes(params[:questionnaire])
format.html { redirect_to new_questionnaire_path }
# format.json { head :no_content }
else
format.html { render "questionnaires/steps/step#{@questionnaire.step - 1}" }
# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\... | [
"0.70548403",
"0.6922357",
"0.69076097",
"0.6641856",
"0.6640088",
"0.66385585",
"0.6615531",
"0.6589103",
"0.65138954",
"0.65048677",
"0.64862674",
"0.64780194",
"0.64476",
"0.64303476",
"0.6428771",
"0.64139926",
"0.63959163",
"0.638628",
"0.63711643",
"0.6370006",
"0.63686... | 0.6572196 | 8 |
DELETE /questionnaires/1 DELETE /questionnaires/1.json | def destroy
@questionnaire = Questionnaire.find(params[:id])
@questionnaire.destroy
respond_to do |format|
format.html { redirect_to questionnaires_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url, notice: 'Те... | [
"0.78990173",
"0.7657406",
"0.75283194",
"0.7526599",
"0.749106",
"0.7443345",
"0.74232304",
"0.7396388",
"0.73805773",
"0.7351647",
"0.73419195",
"0.73237777",
"0.7314943",
"0.7314943",
"0.7314943",
"0.7314943",
"0.7314943",
"0.7314943",
"0.7313181",
"0.7301081",
"0.7289828"... | 0.7862867 | 2 |
before_action :find_user, only: [:show, :new, :create, :edit, :update, :delete] page unknown use | def index
@users = User.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n #@user = User.find(params[:id]) \n #replced by the before_action at the top\n end",
"def show\n unless @user\n render 'not_found_page'\n end\n end",
"def show \n find_user\n # if !session[:user_id] == params[:id]\n # flash[:message] = \"Restricte... | [
"0.68436456",
"0.66629696",
"0.65894073",
"0.6583309",
"0.65781015",
"0.6570633",
"0.6549285",
"0.65341115",
"0.6530316",
"0.6509543",
"0.65057176",
"0.6498933",
"0.6486125",
"0.6484376",
"0.6453525",
"0.63989234",
"0.6387465",
"0.6350284",
"0.63399345",
"0.6334026",
"0.63316... | 0.0 | -1 |
button to destroy on edit profile page | def destroy
@current_user.destroy
logout
redirect_to(login_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @profile.destroy\n redirect_to '/'\n end",
"def destroy\n @profile.destroy\n end",
"def destroy\n\t\t@profile.destroy\n\t\tset_flash_message :notice, :destroyed\n\t\tredirect_to admin_profiles_url\n\tend",
"def destroy\n @profile = Profile.find(params[:id])\n @profile.destroy\n... | [
"0.7585746",
"0.75826895",
"0.7468259",
"0.73922944",
"0.73619294",
"0.73583",
"0.735391",
"0.7352777",
"0.731435",
"0.72876596",
"0.72876596",
"0.72876596",
"0.72876596",
"0.72876596",
"0.72876596",
"0.72876596",
"0.72876596",
"0.71883357",
"0.7172197",
"0.7155352",
"0.71370... | 0.0 | -1 |
Get a list of all the memberships that a specific lifter has | def memberships
#Access membership => [memberships]
#Select all memberships for specific member
Membership.all.select do |m|
#compare whether or not lifter property == this lifter
m.lifter == self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lifter_memberships\n Membership.all.select {|membership| membership.lifter == self}\n end",
"def memberships\n Membership.all.select{|membership|\n membership.lifter == self\n }\n end",
"def memberships\n Membership.all.select {|membership| membership.lifter == self}\n end",
"def memb... | [
"0.79490685",
"0.75938153",
"0.75692666",
"0.7566288",
"0.7436554",
"0.73926985",
"0.7388171",
"0.7243017",
"0.71411103",
"0.69921845",
"0.6887212",
"0.6858434",
"0.6837517",
"0.68229085",
"0.68229085",
"0.68186027",
"0.6805353",
"0.678547",
"0.675285",
"0.6751467",
"0.673233... | 0.7751353 | 1 |
Get a list of all the gyms that a specific lifter has memberships to | def gyms
#Access the Memberships.all array
#Determine whether or not the memberships are mine/lifters
my_memberships = self.memberships
#create array of gyms from the memberships array
my_memberships.map do |m|
m.gym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gyms\n lifter_memberships.map {|membership| membership.gym }\n end",
"def gyms\n memberships.map{|membership|membership.gym}\n end",
"def gyms\n memberships.map{|membership|\n membership.gym\n }\n end",
"def gyms\n self.memberships.map {|membership| membership.gym}\n end",
"def ... | [
"0.8661892",
"0.8125294",
"0.8116532",
"0.8010619",
"0.79847777",
"0.7917569",
"0.78878015",
"0.75839126",
"0.75293916",
"0.75268286",
"0.75253475",
"0.74894047",
"0.74661136",
"0.740751",
"0.72994655",
"0.723168",
"0.71874833",
"0.6971293",
"0.69491106",
"0.6875576",
"0.6839... | 0.7975146 | 5 |
All values that are considered 'false' by Puppet internals | def false_values
[false, 'false', :false, :no, 'no', :undef, nil, :absent]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def false_true\n alternatives false, true\n end",
"def literal_false\n BOOL_FALSE\n end",
"def prologify\n \"false\"\n end",
"def to_bool() false end",
"def literal_false\n 'false'\n end",
"def parse_bool() false end",
"def parse_bool() false end",
"def fal... | [
"0.7119142",
"0.709481",
"0.70613474",
"0.7054836",
"0.7034332",
"0.70336825",
"0.70336825",
"0.7006136",
"0.69601125",
"0.69303286",
"0.69131136",
"0.6749135",
"0.6705906",
"0.6702212",
"0.66538316",
"0.65961826",
"0.65893316",
"0.65288895",
"0.65254265",
"0.65188307",
"0.64... | 0.7524184 | 0 |
user is person who looks at current object profile | def missed_answers_count(user)
answers.where('answers.created_at > ?', latest_profile_view(user))
.where.not(answers: { id: user.viewed_answers.ids }).count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n user_id.get_object\n end",
"def profile\n\t\t@user = current_user\n\tend",
"def user\n object.user\n end",
"def profile\n @user = current_user\n end",
"def profile\n @profile = current_user\n end",
"def profile\n\t\t@user = User.find(current_user)\n\tend",
"def user\n User... | [
"0.7654567",
"0.76367533",
"0.7625619",
"0.76110584",
"0.75337064",
"0.7444149",
"0.7321905",
"0.7292852",
"0.7185892",
"0.7160597",
"0.7094186",
"0.7088127",
"0.7079152",
"0.7073378",
"0.7046144",
"0.7038466",
"0.7032561",
"0.70100266",
"0.7006964",
"0.70038694",
"0.70038694... | 0.0 | -1 |
Internal: Initialize an Interactor::Failure. context An Interactor::Context to be stored within the Interactor::Failure instance. (default: nil) Examples Interactor::Failure.new => context = Interactor::Context.new(foo: "bar") => Interactor::Failure.new(context) => > raise Interactor::Failure, context => Interactor::Failure: | def initialize(context = nil)
@context = context
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure() Failure.new(id) end",
"def failure(msg)\n Detail::Fail.new(msg)\n end",
"def result(context = {}, **arguments)\n call(context, **arguments)\n rescue Actor::Failure => e\n e.context\n end",
"def initialize(*args, **opt)\n @http_response = @http_status = @cause = nil\n a... | [
"0.6096891",
"0.5903815",
"0.58335626",
"0.54351306",
"0.5429584",
"0.54120785",
"0.53992456",
"0.53745323",
"0.5298747",
"0.52798355",
"0.52313995",
"0.5223749",
"0.521762",
"0.5213619",
"0.5205226",
"0.52033967",
"0.52016324",
"0.5190698",
"0.5175133",
"0.5175133",
"0.51747... | 0.49978444 | 39 |
input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: [fill in any steps here] set default quantity print the list to the console [can you use one of your other methods here?] output: [what data type goes here, array or hash?] | def create_list(list_string)
list_array = list_string.split(" ")
list_hash = {}
list_array.each do |item|
list_hash[item] = 1
end
p list_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_list(list)\r\n# input: completed list\r\n# steps:\r\n # iterate over list and print formatted list\r\n puts \"Your Grocery List\"\r\n list.each do |item, quantity|\r\n puts \"#{item}, qty: #{quantity}\"\r\n end\r\n # format: each item with its own line\r\n # \"item - quantity\"\r\n# output: impl... | [
"0.7231452",
"0.72023386",
"0.71934855",
"0.71387064",
"0.71204257",
"0.7041832",
"0.697334",
"0.6881997",
"0.68359375",
"0.679803",
"0.67734873",
"0.67336565",
"0.6722252",
"0.6719973",
"0.670463",
"0.66628945",
"0.66536236",
"0.66433805",
"0.655933",
"0.6543102",
"0.6504786... | 0.0 | -1 |
Method to add an item to a list input: item name and optional quantity steps: output: | def add_item(list, name, qty=1)
list.has_key?(name) ? list[name] += qty : list[name] = qty
p list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity)... | [
"0.82759684",
"0.82759684",
"0.827574",
"0.82154036",
"0.82154036",
"0.8149736",
"0.8124112",
"0.7987406",
"0.79834765",
"0.7925276",
"0.79203105",
"0.7901779",
"0.78639835",
"0.784219",
"0.7810017",
"0.7762449",
"0.7726089",
"0.7716468",
"0.76990217",
"0.76837724",
"0.766833... | 0.0 | -1 |
Method to remove an item from the list input: my_list, item to remove steps: output: | def remove_item(list, item)
list.has_key?(item) ? list.delete(item) : (return puts "Sorry! That item doesn't exist.")
p list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_item(item, list)\n\t# steps: delete the item if it exists\n\tlist.delete_if {|list_item| list_item == item.to_sym}\n\t# output: updated list\n\tlist\nend",
"def remove_item(list, item_removed)\n list.delete(item_removed)\nend",
"def remove_item(list, item)\n\tlist.delete(item)\n\tlist\nend",
"def... | [
"0.83414805",
"0.82129395",
"0.8205271",
"0.81864095",
"0.81706583",
"0.81551635",
"0.813838",
"0.81331867",
"0.8130519",
"0.8127486",
"0.8127486",
"0.81266636",
"0.8103694",
"0.8086528",
"0.8070842",
"0.8049025",
"0.8047798",
"0.8047677",
"0.8036734",
"0.8033305",
"0.8033305... | 0.0 | -1 |
Method to update the quantity of an item input: my_list, the item, new quantity steps: output: new my_list | def update_qty(list, name, qty)
list[name] = qty
p list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend",
"def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"def update_item(list, item, ... | [
"0.8671853",
"0.8596223",
"0.8534531",
"0.8302651",
"0.8231571",
"0.82040787",
"0.81951267",
"0.8176369",
"0.8140729",
"0.81188095",
"0.8115089",
"0.8115089",
"0.80886394",
"0.8060748",
"0.80562985",
"0.80441135",
"0.80379343",
"0.801633",
"0.80082214",
"0.7946629",
"0.794285... | 0.0 | -1 |
Method to print a list and make it look pretty input: my_list steps: iterate over hash, for each pair, puts name : quantity output: a pretty list | def print_list(list)
list.each do |key,value|
puts "#{key}: #{value}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_print(list)\n list.each {|item, quantity| puts \"#{item} : #{quantity}\"}\nend",
"def pretty_list(list)\r\n\tlist.each { |item, quantity| puts \"Item: #{item.capitalize} - Amount: #{quantity}\" }\r\nend",
"def pretty_list(list)\n\tlist.each { |item_name, item_quantity|\n\t\tputs \"You will need t... | [
"0.84124523",
"0.81875545",
"0.81766",
"0.81028026",
"0.8102208",
"0.80934304",
"0.8066317",
"0.80511385",
"0.80511385",
"0.804689",
"0.80314046",
"0.8028447",
"0.79318386",
"0.78879476",
"0.78879476",
"0.7870881",
"0.78070223",
"0.7807015",
"0.78016645",
"0.779927",
"0.77931... | 0.0 | -1 |
do I want these? before_action :login_required, except [:new, :create, :home]any exceptions? before_action :authorize | def logged_in?
!!current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_login\n\t\tauthorize_request || render_unauthorized(\"Access Denied\")\n\tend",
"def login_required\n not_authorized unless current_user\n end",
"def login_required\nauthorized? || access_denied\nend",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def login_requir... | [
"0.7461963",
"0.730161",
"0.72761613",
"0.72698724",
"0.7250645",
"0.7197478",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71875334",
"0.71848255",
"0.71848255",
"0.71848255",
"0.7178348",
"0.7178348",
"0.7178348",
"0.7... | 0.0 | -1 |
The visitation methods We made an explicit choice to not dirty up the BookPart and Page classes, and instead put the visitation methods here. | def visit_book_part(book_part, visitors)
child_book_part_includes, page_includes = set_visitor_defined_includes(
book_part, visitors
)
# We use the `descend` / `ascend` hooks to explicitly tell visitors to move
# down / up a level if they are tracking levels.
visitors.each(&:descend)
visit_pages(book_part, page_includes, visitors)
visit_book_parts(book_part, child_book_part_includes, visitors)
visitors.each(&:ascend)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pages; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def pages\n end",
"def parse_book!\n # if not book\n unles... | [
"0.63274634",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.603931",
"0.59708595",
"0.5845104",
"0.578878",
"0.5759196",
"0.5755159",
"0.5629071",
"0.5573669",
"0.55418193",
"0.5539512"... | 0.6905476 | 0 |
Search for addresses, existing addresses, or POIs based on text string entered by the user | def geocode
# Populate the @traveler variable
get_traveler
@query = params[:query]
@target = params[:target]
if @target == "0"
icon_base = 'startCandidate'
key_base = 'start_candidate'
cache_key = CACHED_FROM_ADDRESSES_KEY
elsif @target == "1"
icon_base = 'stopCandidate'
key_base = 'stop_candidate'
cache_key = CACHED_TO_ADDRESSES_KEY
else
icon_base = "placeCandidate"
key_base = 'place_candidate'
cache_key = CACHED_PLACES_ADDRESSES_KEY
end
geocoder = OneclickGeocoder.new
geocoder.geocode(@query)
# cache the results
cache_addresses(cache_key, geocoder.results)
# This array will hold the list of candidate places
@matches = []
# We create a unique index for mapping etc for each place we find. Limited to 26 candidates as there are no letters past 'Z'
geocoder.results.each_with_index do |addr, index|
icon_style = icon_base + ALPHABET[index]
key = key_base + index.to_s
@matches << get_addr_marker(addr, key, icon_style) unless index > 25
end
respond_to do |format|
format.js { render "show_geocoding_results" }
format.json { render :json => @matches, :status => :created, :location => @matches }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\r\n @addresses = Address.find_by_address(params[:address])\r\n end",
"def address_search\n default_page_statuses\n\n populate_address_list_from_params\n\n # Pick the action based on the parameters\n # Search here is an initial search based on postcode\n return do_address_identifier_... | [
"0.66269165",
"0.65360254",
"0.6533441",
"0.6355207",
"0.633169",
"0.62919474",
"0.61345124",
"0.61121935",
"0.5985116",
"0.59699774",
"0.59476906",
"0.5929121",
"0.581741",
"0.5814708",
"0.5809614",
"0.57707906",
"0.57325596",
"0.57097816",
"0.57057524",
"0.57055444",
"0.569... | 0.0 | -1 |
Search for addresses, existing addresses, or POIs based on text string entered by the user | def search
# Populate the @traveler variable
get_traveler
query = params[:query]
query_str = query + "%"
Rails.logger.debug query_str
# This array will hold the list of matching places
matches = []
# We create a unique index for mapping etc for each place we find
counter = 0
# First search for matching names in my places
rel = Place.arel_table[:name].matches(query_str)
places = @traveler.places.active.where(rel)
places.each do |place|
matches << {
"index" => counter,
"type" => PLACES_TYPE,
"name" => place.name,
"id" => place.id,
"lat" => place.location.first,
"lon" => place.location.last,
"address" => place.address,
"description" => render_to_string(:partial => "/shared/map_popup", :locals => { :place => {:icon => 'icon-building', :name => place.name, :address => place.address} })
}
counter += 1
end
# Second search for matching address in trip_places. We manually filter these to find unique addresses
rel = TripPlace.arel_table[:raw_address].matches(query_str)
tps = @traveler.trip_places.where(rel).order("raw_address")
old_addr = ""
tps.each do |tp|
if old_addr != tp.raw_address
matches << {
"index" => counter,
"type" => CACHED_ADDRESS_TYPE,
"name" => tp.raw_address,
"id" => tp.id,
"lat" => tp.lat,
"lon" => tp.lon,
"address" => tp.raw_address,
"description" => render_to_string(:partial => "/shared/map_popup", :locals => { :place => {:icon => 'icon-building', :name => tp.name, :address => tp.raw_address} })
}
counter += 1
old_addr = tp.raw_address
end
end
# Lastly search for matching names in the POI table
rel = Poi.arel_table[:name].matches(query_str)
pois = Poi.where(rel).limit(MAX_POIS_FOR_SEARCH)
pois.each do |poi|
matches << {
"index" => counter,
"type" => POI_TYPE,
"name" => poi.name,
"id" => poi.id,
"lat" => poi.lat,
"lon" => poi.lon,
"address" => poi.address,
"description" => render_to_string(:partial => "/shared/map_popup", :locals => { :place => {:icon => 'icon-building', :name => poi.name, :address => poi.address} })
}
counter += 1
end
respond_to do |format|
format.js { render :json => matches.to_json }
format.json { render :json => matches.to_json }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\r\n @addresses = Address.find_by_address(params[:address])\r\n end",
"def address_search\n default_page_statuses\n\n populate_address_list_from_params\n\n # Pick the action based on the parameters\n # Search here is an initial search based on postcode\n return do_address_identifier_... | [
"0.6625722",
"0.6535906",
"0.6532651",
"0.6353805",
"0.6329839",
"0.62920773",
"0.6109965",
"0.59851795",
"0.5969803",
"0.5947542",
"0.59278184",
"0.5817022",
"0.5816072",
"0.58099276",
"0.57699645",
"0.573119",
"0.57083535",
"0.5705275",
"0.57025397",
"0.5699627",
"0.5674525... | 0.61341405 | 6 |
Cache an array of addresses | def cache_addresses(key, addresses, expires_in = ADDRESS_CACHE_EXPIRE_SECONDS)
Rails.logger.debug "PlaceSearchingController CACHE put for key #{get_cache_key(@traveler, key)}"
Rails.cache.write(get_cache_key(@traveler, key), addresses, :expires_in => expires_in)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cached_addresses(key)\n Rails.logger.debug \"PlaceSearchingController CACHE get for key #{get_cache_key(@traveler, key)}\"\n ret = Rails.cache.read(get_cache_key(@traveler, key))\n return ret.nil? ? [] : ret\n end",
"def get_uncached_addresses(addresses, suffix = '')\n ret = []\n addr... | [
"0.6864723",
"0.65623695",
"0.6522429",
"0.6432256",
"0.62235975",
"0.6158221",
"0.61450666",
"0.6056957",
"0.59894365",
"0.5968272",
"0.59237707",
"0.59031725",
"0.59031725",
"0.59031725",
"0.59031725",
"0.59031725",
"0.59031725",
"0.59031725",
"0.5893102",
"0.57996535",
"0.... | 0.65759665 | 1 |
Return an array of cached addresses | def get_cached_addresses(key)
Rails.logger.debug "PlaceSearchingController CACHE get for key #{get_cache_key(@traveler, key)}"
ret = Rails.cache.read(get_cache_key(@traveler, key))
return ret.nil? ? [] : ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uncached_addresses(addresses, suffix = '')\n ret = []\n addresses.each do |address|\n if cache_read(address + suffix) == nil\n ret << address\n end\n end\n return ret\n end",
"def list\n Enumerator.new do |y|\n @cache.each_value do |re|\n ... | [
"0.719686",
"0.7175076",
"0.6728604",
"0.6544057",
"0.6425204",
"0.6391677",
"0.63281614",
"0.63042265",
"0.6284097",
"0.6283977",
"0.62426525",
"0.61704504",
"0.6152796",
"0.606491",
"0.60490733",
"0.60292965",
"0.6005638",
"0.59969544",
"0.5983866",
"0.5977524",
"0.59159005... | 0.76229334 | 0 |
generates a cache key that is unique for a user and key name | def get_cache_key(user, key)
return "%06d:%s" % [user.id, key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_key(identifier)\n \"#{Gxapi.cache_namespace}#{self.user_key}_#{identifier.to_key}\"\n end",
"def generate_cache_key(record, namespace)\n \"#{namespace}-#{record.cache_key_with_version}\"\n end",
"def generate_key(*args)\n @cache_keys[args.join] ||= @key_generator.generate_key... | [
"0.814732",
"0.78635216",
"0.77286875",
"0.7656909",
"0.7589668",
"0.74475807",
"0.7342305",
"0.73196167",
"0.73125714",
"0.72521174",
"0.72457635",
"0.7232854",
"0.7211538",
"0.71898925",
"0.7171583",
"0.713823",
"0.712558",
"0.71111655",
"0.71081465",
"0.7103171",
"0.710043... | 0.8110305 | 1 |
Update the session variable | def set_traveler_id(id)
session[TRAVELER_USER_SESSION_KEY] = id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n return unless @session\n @session.data = @data\n @session.save\n end",
"def update_session(data)\n update_attribute('data', data) \n end",
"def update\n if @session\n @session.update_session(marshalize(@data))\n end\n end",
"def update #:nodoc:#\n ... | [
"0.7555396",
"0.74478036",
"0.74425703",
"0.7255247",
"0.7242379",
"0.70256716",
"0.7012974",
"0.69732565",
"0.6942297",
"0.6731014",
"0.6629655",
"0.6623012",
"0.65692806",
"0.6555252",
"0.65492994",
"0.65479296",
"0.65026855",
"0.6469879",
"0.6445534",
"0.6441985",
"0.64263... | 0.0 | -1 |
project Euler problem 24 Lexicographic permutations Created by Payam Behjat What is the first term in the Fibonacci sequence to contain 1000 digits? | def firstFibOfLength(limit)
fl, fc = 1,1
count = 2
while(fc < limit)
fl,fc,count = fc,fl+fc,count + 1
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euler020\n def fact(x)\n ans = x.downto(1).reduce(:*)\n end\n fact(100).to_s.split('').map { |x| x.to_i}.reduce(:+)\nend",
"def euler048\n (1..1000).each.reduce { |a,i| a + i**i }.to_s.slice(-10, 10).to_i\nend",
"def euler016\n (2 ** 1000).to_s.split('').map { |x| x.to_i }.reduce(:+)\nend",
"def ... | [
"0.72630894",
"0.70511246",
"0.701164",
"0.6999614",
"0.6930043",
"0.67943245",
"0.67915446",
"0.677762",
"0.67630833",
"0.6712661",
"0.6708817",
"0.66926616",
"0.6673235",
"0.6661161",
"0.66334784",
"0.6610341",
"0.6604663",
"0.65790653",
"0.65458024",
"0.6539584",
"0.652505... | 0.0 | -1 |
Returns beginning (notBefore) of certificate validity period | def not_before
@cert.not_before
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_before\n @cert.not_before\n end",
"def expires_on\n expiry_date = nil\n dates = %x{echo \"#{self.certificate}\" | openssl x509 -noout -dates}\n dates.each_line do |date_line|\n logger.debug(\"DEBUG >> Date line: #{date_line}\")\n if date_line =~ /^notAfter=/\n ... | [
"0.6605559",
"0.62357396",
"0.60203916",
"0.5966303",
"0.59291345",
"0.59291345",
"0.58015054",
"0.57348645",
"0.5680823",
"0.5664666",
"0.5664666",
"0.5586929",
"0.5556389",
"0.55299914",
"0.54878676",
"0.54469573",
"0.5376964",
"0.5342557",
"0.5312076",
"0.5303584",
"0.5291... | 0.6696145 | 1 |
Returns the serial number of the certificate in decimal form | def serial
@cert.serial.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial\n @cert.serial.to_i\n end",
"def cert_serial_get\n cert = certificate_get\n # Convert the base 10 serial number from the openssl cert to hexadecimal\n serial_number = cert.serial.to_s(16)\n # Add a colon every 2 characters to the returned serial number\n serial_number.... | [
"0.85640514",
"0.8064478",
"0.8048425",
"0.77703404",
"0.75999707",
"0.75557774",
"0.75557774",
"0.67834204",
"0.66486925",
"0.63753057",
"0.6243783",
"0.6238919",
"0.62128955",
"0.613806",
"0.60758805",
"0.60435",
"0.601839",
"0.59497476",
"0.5929629",
"0.5882265",
"0.586023... | 0.8620299 | 0 |
Returns the serial number of the certificate in hexadecimal form | def hexserial
@cert.serial.to_s(16)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial\n @cert.serial.to_i\n end",
"def serial\n @cert.serial.to_i\n end",
"def cert_serial_get\n cert = certificate_get\n # Convert the base 10 serial number from the openssl cert to hexadecimal\n serial_number = cert.serial.to_s(16)\n # Add a colon every 2 characters... | [
"0.859187",
"0.8501733",
"0.8283773",
"0.82110316",
"0.79278964",
"0.7912253",
"0.7912253",
"0.695732",
"0.6751001",
"0.6625452",
"0.6428307",
"0.635817",
"0.6292671",
"0.62022954",
"0.6143606",
"0.6113146",
"0.6060376",
"0.6056279",
"0.60529757",
"0.6021144",
"0.5935552",
... | 0.88110167 | 0 |
Returns ending (notAfter) of certificate validity period | def not_after
@cert.not_after
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expires_on\n expiry_date = nil\n dates = %x{echo \"#{self.certificate}\" | openssl x509 -noout -dates}\n dates.each_line do |date_line|\n logger.debug(\"DEBUG >> Date line: #{date_line}\")\n if date_line =~ /^notAfter=/\n expiry_date = date_line.gsub('notAfter=', '').to_time\n en... | [
"0.70354265",
"0.6959253",
"0.6553489",
"0.6219885",
"0.61557025",
"0.6136852",
"0.61143035",
"0.608588",
"0.6019158",
"0.59160155",
"0.5851116",
"0.5846415",
"0.58438957",
"0.58438957",
"0.582968",
"0.58284724",
"0.5813617",
"0.5787142",
"0.5767285",
"0.57640445",
"0.5760727... | 0.70482916 | 1 |
Returns the certificate public key | def public_key
@cert.public_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_key\n @cert.public_key\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n require_key\n... | [
"0.86203206",
"0.8321835",
"0.8075403",
"0.8075403",
"0.78837454",
"0.7819318",
"0.7676886",
"0.7657979",
"0.7657082",
"0.75140715",
"0.74593836",
"0.74110657",
"0.7360649",
"0.7318346",
"0.73042935",
"0.72108155",
"0.72108155",
"0.720705",
"0.71736276",
"0.7156537",
"0.71302... | 0.8649545 | 0 |
Returns the certificate fingerprint with the specified algorithm (default sha256) | def fingerprint(algorithm = 'sha256')
message_digest = R509::MessageDigest.new(algorithm)
md = message_digest.digest
md.update(@cert.to_der)
md.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fingerprint(algorithm='sha1')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end",
"def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filenam... | [
"0.80792123",
"0.678276",
"0.658051",
"0.65417063",
"0.6461934",
"0.64315736",
"0.64154804",
"0.62586755",
"0.6192254",
"0.60807127",
"0.6080643",
"0.6024947",
"0.59972",
"0.59972",
"0.5961664",
"0.5875379",
"0.58661705",
"0.574323",
"0.57153",
"0.56934786",
"0.56921434",
"... | 0.8403288 | 0 |
Returns whether the current time is between the notBefore and notAfter times in the certificate. | def valid?
valid_at?(Time.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?(time=Time.now.utc)\n time>not_before && time<self.not_after\n end",
"def valid_duration?(cert_obj)\n cert_obj.not_before < Time.now.utc && cert_obj.not_after > Time.now.utc\n end",
"def after?(time)\n start_time > time\n end",
"def after?(time)\n start_time > t... | [
"0.68878305",
"0.67963696",
"0.64275515",
"0.64275515",
"0.62843484",
"0.6275277",
"0.6271641",
"0.6252675",
"0.6252675",
"0.6237641",
"0.6230412",
"0.61694187",
"0.61361545",
"0.6135764",
"0.6135764",
"0.6117502",
"0.60972595",
"0.6052036",
"0.60455316",
"0.60252917",
"0.602... | 0.0 | -1 |
Returns whether the certificate was between its notBefore and notAfter at the time provided | def valid_at?(time)
if time.is_a?(Integer)
time = Time.at(time)
end
if (self.not_after < time) || (self.not_before > time)
false
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_duration?(cert_obj)\n cert_obj.not_before < Time.now.utc && cert_obj.not_after > Time.now.utc\n end",
"def valid?(time=Time.now.utc)\n time>not_before && time<self.not_after\n end",
"def after?(time)\n start_time > time\n end",
"def after?(time)\n start_time > t... | [
"0.69036394",
"0.6767775",
"0.6575401",
"0.6575401",
"0.65283805",
"0.65283805",
"0.6525152",
"0.62560016",
"0.62560016",
"0.61579025",
"0.61481255",
"0.6135637",
"0.612863",
"0.61192507",
"0.60703695",
"0.6050993",
"0.6014852",
"0.6008341",
"0.5996528",
"0.596692",
"0.596692... | 0.6015078 | 16 |
Return the CN, as well as all the subject alternative names (SANs). | def all_names
ret = []
ret << @subject.CN unless @subject.CN.nil?
ret.concat(self.san.names.map { |n| n.value }) unless self.san.nil?
ret.sort.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_names\n ret = []\n if cn = self.subject_component('CN')\n ret << cn\n end\n # Merge in san_names if we got anything.\n if sn = self.san_names\n ret.concat(sn)\n end\n\n return ret.sort.uniq\n ... | [
"0.75852215",
"0.72379917",
"0.703847",
"0.68885607",
"0.6824071",
"0.6658179",
"0.64220273",
"0.6252653",
"0.6057756",
"0.6057756",
"0.6020786",
"0.5899062",
"0.583954",
"0.5799111",
"0.57941115",
"0.5767765",
"0.571874",
"0.57132107",
"0.57113004",
"0.56840765",
"0.56688696... | 0.6871805 | 4 |
Writes cert and key into PKCS12 format using OpenSSL defaults for encryption (des3) | def write_pkcs12(filename_or_io, password, friendly_name = 'r509 pkcs12')
if @key.nil?
raise R509::R509Error, "Writing a PKCS12 requires both key and cert"
end
pkcs12 = OpenSSL::PKCS12.create(password, friendly_name, @key.key, @cert)
write_data(filename_or_io, pkcs12.to_der)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_pkcs12(filename_or_io,password,friendly_name='r509 pkcs12')\n if @key.nil?\n raise R509::R509Error, \"Writing a PKCS12 requires both key and cert\"\n end\n pkcs12 = OpenSSL::PKCS12.create(password,friendly_name,@key.key,@cert)\n write_data(filena... | [
"0.65906155",
"0.64304376",
"0.62321556",
"0.5982803",
"0.5951604",
"0.5915064",
"0.58576894",
"0.5821694",
"0.578776",
"0.57748294",
"0.5666401",
"0.5659121",
"0.5585478",
"0.5564225",
"0.54011935",
"0.5384",
"0.5377592",
"0.5369032",
"0.5350329",
"0.5339898",
"0.52856517",
... | 0.6485784 | 1 |
Checks the given CRL for this certificate's serial number. Note that this does NOT check to verify that the CRL you're checking is signed by the same CA as the cert so do that check yourself | def is_revoked_by_crl?(r509_crl)
r509_crl.revoked?(self.serial)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial_revoked?(crl, serial)\n raise TypeError, \"crl must be a Ruby OpenSSL::X509::CRL object\" unless crl.is_a?(::OpenSSL::X509::CRL)\n raise TypeError, \"serial must be a Ruby String or Integer object\" unless serial.is_a?(String) || serial.is_a?(Integer)\n\n serial_to_verify = if seria... | [
"0.7698316",
"0.632472",
"0.6292093",
"0.6168512",
"0.61624485",
"0.5942143",
"0.58978087",
"0.5890094",
"0.58048517",
"0.57226646",
"0.5587445",
"0.5544595",
"0.5399927",
"0.5381191",
"0.5373393",
"0.5370943",
"0.5290529",
"0.52627355",
"0.5245815",
"0.5188516",
"0.5152616",... | 0.62932426 | 2 |
Returns the certificate extensions as a hash of R509::Cert::Extensions specific objects. | def extensions
if @r509_extensions.nil?
@r509_extensions = Extensions.wrap_openssl_extensions(self.cert.extensions)
end
@r509_extensions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensions\n if @extensions.nil?\n @extensions = Hash.new\n @cert.extensions.to_a.each { |extension|\n extension = extension.to_a\n if(!@extensions[extension[0]].kind_of?(Array)) then\n @extensions[extension[0... | [
"0.84298736",
"0.82451314",
"0.7465094",
"0.73332787",
"0.64705604",
"0.640403",
"0.63811916",
"0.63708645",
"0.63708645",
"0.63708645",
"0.6333401",
"0.6319978",
"0.63035506",
"0.62571096",
"0.6256936",
"0.6256936",
"0.62504345",
"0.62504345",
"0.62426406",
"0.62426406",
"0.... | 0.7682551 | 2 |
Returns an array of OpenSSL::X509::Extension objects representing the extensions that do not have R509 implementations. | def unknown_extensions
Extensions.get_unknown_extensions(self.cert.extensions)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.cert.extensions)\n end\n\n @r509_extensions\n end",
"def extensions\n unless @extensions\n @extensions={}\n cert.extensions.each {|e| @extensions[e.oid]=e.value} if c... | [
"0.74404144",
"0.7200421",
"0.7143706",
"0.711186",
"0.711186",
"0.69056356",
"0.68678725",
"0.68591857",
"0.65720326",
"0.65720326",
"0.6486559",
"0.64827925",
"0.64784557",
"0.6461111",
"0.6370528",
"0.63052446",
"0.6293656",
"0.6279973",
"0.6234625",
"0.6234625",
"0.623462... | 0.7882428 | 0 |
Shortcuts to extensions Returns this object's BasicConstraints extension as an R509 extension | def basic_constraints
extensions[R509::Cert::Extensions::BasicConstraints]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_constraints\n extensions[R509::Cert::Extensions::PolicyConstraints]\n end",
"def x509v3_basic_constraints\n @x509v3_basic_constraints ||= if (constraints = @node.at('X509v3BasicConstraints'))\n X509v3BasicConstraints.new(constraints)\n ... | [
"0.68101245",
"0.63585997",
"0.62870234",
"0.58957857",
"0.58954084",
"0.58047515",
"0.5796065",
"0.5796065",
"0.5796065",
"0.57412994",
"0.5664446",
"0.56239253",
"0.5578",
"0.5511049",
"0.5507926",
"0.54145384",
"0.53705096",
"0.53602207",
"0.5329285",
"0.5311472",
"0.52816... | 0.80496585 | 0 |
Returns this object's KeyUsage extension as an R509 extension | def key_usage
extensions[R509::Cert::Extensions::KeyUsage]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extended_key_usage\n extensions[R509::Cert::Extensions::ExtendedKeyUsage]\n end",
"def x509v3_extended_key_usage\n @x509v3_extended_key_usage ||= if (node = @node.at('X509v3ExtendedKeyUsage'))\n X509v3ExtendedKeyUsage.new(node)\n ... | [
"0.8207907",
"0.7142938",
"0.6605565",
"0.58819187",
"0.5840512",
"0.5700779",
"0.5679486",
"0.5677527",
"0.567017",
"0.56447935",
"0.56059366",
"0.5499678",
"0.54784733",
"0.5474421",
"0.5462225",
"0.54607964",
"0.54417884",
"0.5422276",
"0.54025096",
"0.5389371",
"0.5335275... | 0.8182536 | 1 |
Returns this object's ExtendedKeyUsage extension as an R509 extension | def extended_key_usage
extensions[R509::Cert::Extensions::ExtendedKeyUsage]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_usage\n extensions[R509::Cert::Extensions::KeyUsage]\n end",
"def x509v3_extended_key_usage\n @x509v3_extended_key_usage ||= if (node = @node.at('X509v3ExtendedKeyUsage'))\n X509v3ExtendedKeyUsage.new(node)\n end... | [
"0.7843301",
"0.7637918",
"0.67561346",
"0.6039131",
"0.59054023",
"0.5843072",
"0.58396447",
"0.58228827",
"0.58166564",
"0.58062434",
"0.5803049",
"0.5781153",
"0.5777496",
"0.575242",
"0.5691019",
"0.5684538",
"0.56381154",
"0.5614539",
"0.55882007",
"0.55785125",
"0.55663... | 0.86784846 | 0 |
Returns this object's SubjectKeyIdentifier extension as an R509 extension | def subject_key_identifier
extensions[R509::Cert::Extensions::SubjectKeyIdentifier]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authority_key_identifier\n extensions[R509::Cert::Extensions::AuthorityKeyIdentifier]\n end",
"def x509v3_subject_key_identifier\n @x509v3_subject_key_identifier ||= if (node = @node.at('X509v3SubjectKeyIdentifier'))\n node.inner_text\n ... | [
"0.704265",
"0.67773896",
"0.6683812",
"0.6562331",
"0.6547139",
"0.64851683",
"0.6454937",
"0.6368408",
"0.6196054",
"0.616761",
"0.6023093",
"0.60143805",
"0.5850117",
"0.5776108",
"0.57570577",
"0.5749129",
"0.57487804",
"0.5723746",
"0.5717099",
"0.5674529",
"0.56709385",... | 0.8348989 | 0 |
Returns this object's AuthorityKeyIdentifier extension as an R509 extension | def authority_key_identifier
extensions[R509::Cert::Extensions::AuthorityKeyIdentifier]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_key_identifier\n extensions[R509::Cert::Extensions::SubjectKeyIdentifier]\n end",
"def x509v3_authority_key_identifier\n @x509v3_authority_key_identifier ||= if (node = @node.at('X509v3AuthorityKeyIdentifier'))\n node.inner_text\n ... | [
"0.7218629",
"0.65831673",
"0.6566487",
"0.64046174",
"0.62813884",
"0.62541735",
"0.6168674",
"0.60411793",
"0.60411793",
"0.60084295",
"0.58808035",
"0.57842857",
"0.5745742",
"0.569881",
"0.5688572",
"0.5656829",
"0.56285876",
"0.5596329",
"0.5595606",
"0.5553849",
"0.5553... | 0.81758493 | 0 |
Returns this object's SubjectAlternativeName extension as an R509 extension | def subject_alternative_name
extensions[R509::Cert::Extensions::SubjectAlternativeName]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x509v3_subject_alternative_name\n @x509v3_subject_alternative_name ||= if (node = @node.search('X509v3SubjectAlternativeName'))\n X509v3SubjectAlternativeName.new(node)\n end\n end",
"def subject_alternative... | [
"0.7385671",
"0.7059788",
"0.6889242",
"0.6772187",
"0.6290945",
"0.6255486",
"0.62115395",
"0.6193081",
"0.6121669",
"0.59525394",
"0.5931325",
"0.5931225",
"0.58601403",
"0.5854309",
"0.5801662",
"0.5792726",
"0.5765612",
"0.56843066",
"0.56809914",
"0.56555414",
"0.5615606... | 0.86322767 | 0 |
Returns this object's AuthorityInfoAccess extension as an R509 extension | def authority_info_access
extensions[R509::Cert::Extensions::AuthorityInfoAccess]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authority_key_identifier\n extensions[R509::Cert::Extensions::AuthorityKeyIdentifier]\n end",
"def authority_information_access\n @authority_information_access ||= if (node = @node.at('AuthorityInformationAccess'))\n AuthorityInformationAccess.new(nod... | [
"0.6396097",
"0.6252541",
"0.5615336",
"0.56038666",
"0.55803734",
"0.5442147",
"0.53991365",
"0.5389542",
"0.53837836",
"0.5318792",
"0.52865344",
"0.52845585",
"0.5183891",
"0.5183557",
"0.5183557",
"0.5122377",
"0.5114303",
"0.51074487",
"0.5074441",
"0.50536025",
"0.50351... | 0.8085448 | 0 |
Returns this object's CRLDistributionPoints extension as an R509 extension | def crl_distribution_points
extensions[R509::Cert::Extensions::CRLDistributionPoints]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.cert.extensions)\n end\n\n @r509_extensions\n end",
"def x509v3_crl_distribution_points\n @x509v3_crl_distribution_points ||= if (node = @node.at('X509v3CRLDistributionPoints'))\... | [
"0.6751949",
"0.6179677",
"0.5928213",
"0.58870715",
"0.58820474",
"0.5759917",
"0.57396185",
"0.56039554",
"0.5489349",
"0.54856294",
"0.5423188",
"0.5420508",
"0.53275585",
"0.5264877",
"0.52450746",
"0.5234385",
"0.5222809",
"0.5217157",
"0.5162716",
"0.5127284",
"0.510617... | 0.78106076 | 0 |
Returns true if the OCSP No Check extension is present (value is irrelevant to this extension) | def ocsp_no_check?
(extensions.key?(R509::Cert::Extensions::OCSPNoCheck))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensions_present?\n\t\treturn !self.extensions.empty?\n\tend",
"def extension?\n @extension != \"\"\n end",
"def service_none?()\n return true if (@service == TAC_PLUS_AUTHEN_SVC_NONE)\n return false\n end",
"def extension?\n !@arg[:extension].nil?\n end",
"def snp_ex... | [
"0.6220928",
"0.6076846",
"0.57829374",
"0.57672584",
"0.56387347",
"0.5590637",
"0.55607533",
"0.5558472",
"0.5550574",
"0.5520836",
"0.5517586",
"0.5514688",
"0.55138534",
"0.55106527",
"0.5494738",
"0.5494738",
"0.54485375",
"0.5436952",
"0.5432207",
"0.5432207",
"0.542136... | 0.84892666 | 0 |
Returns this object's CertificatePolicies extension as an R509 extension | def certificate_policies
extensions[R509::Cert::Extensions::CertificatePolicies]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.cert.extensions)\n end\n\n @r509_extensions\n end",
"def policy_constraints\n extensions[R509::Cert::Extensions::PolicyConstraints]\n end",
"def to_x509()\n @cert\n en... | [
"0.7202022",
"0.71252334",
"0.61748475",
"0.60742444",
"0.5953976",
"0.5953806",
"0.5834613",
"0.5797152",
"0.570377",
"0.5665281",
"0.5658037",
"0.5644575",
"0.5600177",
"0.55753654",
"0.5575153",
"0.55702657",
"0.5536947",
"0.5507498",
"0.5492153",
"0.54906875",
"0.5488104"... | 0.8077334 | 0 |
Returns this object's InhibitAnyPolicy extension as an R509 extension | def inhibit_any_policy
extensions[R509::Cert::Extensions::InhibitAnyPolicy]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_security_policy_report_only; end",
"def content_security_policy_report_only; end",
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.cert.extensions)\n end\n\n @r509_extensions\n end",
"def policy_constraints\n ex... | [
"0.5813436",
"0.5813436",
"0.58121",
"0.5780821",
"0.5775276",
"0.5775276",
"0.5697843",
"0.56942165",
"0.5568452",
"0.54836553",
"0.5471182",
"0.53939855",
"0.528295",
"0.5183874",
"0.5150399",
"0.5140778",
"0.513322",
"0.509148",
"0.509106",
"0.5065338",
"0.5059647",
"0.5... | 0.82008153 | 0 |
Returns this object's PolicyConstraints extension as an R509 extension | def policy_constraints
extensions[R509::Cert::Extensions::PolicyConstraints]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basic_constraints\n extensions[R509::Cert::Extensions::BasicConstraints]\n end",
"def certificate_policies\n extensions[R509::Cert::Extensions::CertificatePolicies]\n end",
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.ce... | [
"0.6767132",
"0.6693151",
"0.65172994",
"0.59465075",
"0.5723592",
"0.57087475",
"0.556049",
"0.54888374",
"0.5404319",
"0.54012996",
"0.53926134",
"0.5342869",
"0.53126097",
"0.52556753",
"0.51393145",
"0.5107933",
"0.51073337",
"0.51019984",
"0.5100501",
"0.5097844",
"0.507... | 0.78476447 | 0 |
Returns this object's NameConstraints extension as an R509 extension | def name_constraints
extensions[R509::Cert::Extensions::NameConstraints]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basic_constraints\n extensions[R509::Cert::Extensions::BasicConstraints]\n end",
"def policy_constraints\n extensions[R509::Cert::Extensions::PolicyConstraints]\n end",
"def extensions\n if @r509_extensions.nil?\n @r509_extensions = Extensions.wrap_openssl_extensions(self.cert.e... | [
"0.66201246",
"0.64274174",
"0.64137775",
"0.6168287",
"0.6133555",
"0.60052043",
"0.5872061",
"0.5795785",
"0.57092685",
"0.55844295",
"0.5521967",
"0.54967916",
"0.54619855",
"0.546083",
"0.5447764",
"0.54234105",
"0.5413067",
"0.5337918",
"0.5331685",
"0.52662784",
"0.5264... | 0.75515276 | 0 |
This method exists only to provide a friendlier error msg if you attempt to parse a CSR as a certificate. All for Sean | def csr_check(cert)
begin
OpenSSL::X509::Request.new cert
raise ArgumentError, 'Cert provided is actually a certificate signing request.'
rescue OpenSSL::X509::RequestError
# do nothing, it shouldn't be a CSR anyway!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_signing_csr\n return unless [:get_certificate, :create_certificate, :renew_certificate].include? command\n return if cert_request_valid?(signing_csr)\n\n errors.add(:signing_csr, SIGNING_CERT_REQUEST_ERROR_MESSAGE)\n end",
"def prepare_certificate(csr)\n cert = OpenSSL::X509::Certi... | [
"0.63865125",
"0.62992495",
"0.6199958",
"0.6146716",
"0.6090626",
"0.6025339",
"0.6003121",
"0.57881147",
"0.57881147",
"0.57818776",
"0.5765765",
"0.5631569",
"0.5628738",
"0.56081235",
"0.55706304",
"0.5555007",
"0.554962",
"0.5546225",
"0.5540748",
"0.5487325",
"0.5471231... | 0.6625979 | 0 |
GET /bets GET /bets.json | def index
@bets = Bet.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_bets\n @bets = Bet.where('owner = ? AND status != ? AND status != ?', params[:id], \"won\", \"lost\").to_a\n @bets.sort! {|x,y| x.id <=> y.id }\n render 'my-bets.json.jbuilder'\n end",
"def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.72007155",
"0.71528786",
"0.68772197",
"0.67754173",
"0.6765627",
"0.6759127",
"0.67020994",
"0.66774404",
"0.66462874",
"0.6554614",
"0.6494587",
"0.64937955",
"0.6476366",
"0.6447285",
"0.6428931",
"0.64149874",
"0.6407953",
"0.6398111",
"0.6398111",
"0.63917655",
"0.636... | 0.7150734 | 2 |
GET /bets/1 GET /bets/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end",
"def show\n @bet = Bet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bet... | [
"0.7048347",
"0.7009155",
"0.6972464",
"0.6911999",
"0.67556894",
"0.6748667",
"0.6744998",
"0.66880316",
"0.6664587",
"0.6661901",
"0.6556887",
"0.65367734",
"0.6507215",
"0.64959973",
"0.6477747",
"0.64402366",
"0.6433237",
"0.64237785",
"0.6377124",
"0.63739717",
"0.635712... | 0.0 | -1 |
POST /bets POST /bets.json | def create
@bet = Bet.new(bet_params)
respond_to do |format|
if @bet.save
format.html { redirect_to @bet, notice: 'Bet was successfully created.' }
format.json { render :show, status: :created, location: @bet }
else
format.html { render :new }
format.json { render json: @bet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @bet = Bet.new(params[:bet])\n\n respond_to do |format|\n if @bet.save\n format.html { redirect_to @bet, notice: 'Bet was successfully created.' }\n format.json { render json: @be... | [
"0.63637143",
"0.6326079",
"0.61378026",
"0.60871506",
"0.6051604",
"0.60336953",
"0.60268337",
"0.5990327",
"0.598453",
"0.59775484",
"0.59080195",
"0.5892942",
"0.5886788",
"0.58627987",
"0.5822075",
"0.58182746",
"0.58015615",
"0.5789065",
"0.5773754",
"0.57444197",
"0.574... | 0.6307491 | 2 |
PATCH/PUT /bets/1 PATCH/PUT /bets/1.json | def update
respond_to do |format|
if @bet.update(bet_params)
format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }
format.json { render :show, status: :ok, location: @bet }
else
format.html { render :edit }
format.json { render json: @bet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @belt.update(belt_params)\n format.html { redirect_to @belt, notice: 'Belt was successfully upd... | [
"0.65477216",
"0.6442095",
"0.63838917",
"0.63697785",
"0.63105184",
"0.6253809",
"0.6210746",
"0.6206869",
"0.62025726",
"0.6185574",
"0.61607444",
"0.6145277",
"0.61186963",
"0.6113401",
"0.6105885",
"0.6104616",
"0.6080596",
"0.6080596",
"0.6080596",
"0.6063763",
"0.605107... | 0.5987713 | 29 |
DELETE /bets/1 DELETE /bets/1.json | def destroy
@bet.destroy
respond_to do |format|
format.html { redirect_to bets_url, notice: 'Bet was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bet = Bet.find(params[:id])\n @bet.destroy\n\n respond_to do |format|\... | [
"0.69783837",
"0.68244374",
"0.67883456",
"0.67883456",
"0.67784846",
"0.6741181",
"0.67177576",
"0.66819793",
"0.6680703",
"0.66535157",
"0.664925",
"0.6640362",
"0.66348714",
"0.66328627",
"0.6628323",
"0.6622358",
"0.66179585",
"0.6615562",
"0.6600409",
"0.6590072",
"0.656... | 0.6337486 | 80 |
Use callbacks to share common setup or constraints between actions. | def set_bet
@bet = Bet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def bet_params
params[:bet]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Query applied to chart.js pie chart for Favorite Flavor Friday | def flavor_faves
@flavors=Flavor.all
@flavors=@flavors.order(svy_vote: :desc).limit(5)
@first=@flavors.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pie_chart_data\n response = api_request(:summary, {group_by: 'keywords'})\n results = extract_and_sort_results(response)\n\n total_other = results.drop(4).map {|row| row['total_calls']}.sum\n pie_segments = results.take(4)\n pie_segments << { \"key\" => \"Other\", \"total_calls\" => total_other ... | [
"0.5702207",
"0.55815595",
"0.5553516",
"0.54489785",
"0.54193234",
"0.54022175",
"0.5395523",
"0.5338904",
"0.5282439",
"0.5207803",
"0.5197374",
"0.5192759",
"0.51384115",
"0.5123413",
"0.51222575",
"0.50753057",
"0.5064015",
"0.50561476",
"0.501354",
"0.5011014",
"0.498793... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.