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 |
|---|---|---|---|---|---|---|
Return the preferred language for literal value selection for term fetch. Only applies if the authority provides language encoded literals. | def term_language
return @term_language unless @term_language.nil?
lang = Config.config_value(term_config, :language)
return nil if lang.nil?
lang = [lang] if lang.is_a? String
@term_language = lang.collect(&:to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def language (value = nil)\n\t\tif value\n\t\t\traise_if_error C.glyr_opt_lang(to_native, value)\n\t\telse\n\t\t\tto_native[:lang]\n\t\tend\n\tend",
"def select_language\n I18n.backend.send(:init_translations) unless I18n.backend.initialized?\n lang = PatientHelper.languages(primary_language)&.dig(:code)&.... | [
"0.6892601",
"0.6644617",
"0.66379243",
"0.6631493",
"0.6465269",
"0.6465269",
"0.6465269",
"0.63848174",
"0.6342725",
"0.63016415",
"0.62941664",
"0.62736636",
"0.6269395",
"0.62621105",
"0.623273",
"0.62284756",
"0.6221173",
"0.6197366",
"0.6192198",
"0.61330897",
"0.607697... | 0.67905855 | 1 |
Return parameters that are required for QA api | def term_qa_replacement_patterns
Config.config_value(term_config, :qa_replacement_patterns)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qa_params\n params.fetch(:qa, {})\n end",
"def altoq_params\n params.fetch(:altoq, {})\n end",
"def api_v1_question_params\n params.fetch(:api_v1_question, {})\n end",
"def api_params(q = {})\n @api[:optional].deep_merge(@api[:required]).deep_merge(q)\n end",
"def reques... | [
"0.7521961",
"0.6979034",
"0.6782931",
"0.6754813",
"0.6733016",
"0.671401",
"0.66703606",
"0.6561681",
"0.6520662",
"0.65206015",
"0.6505873",
"0.6495679",
"0.6412497",
"0.64057755",
"0.63969517",
"0.63658667",
"0.634184",
"0.6318486",
"0.6318486",
"0.6313167",
"0.63059354",... | 0.0 | -1 |
Should the replacement pattern be encoded? | def term_qa_replacement_encoded?(pattern_key)
map_key = term_qa_replacement_patterns[pattern_key].to_sym
term_replacement_encoded? map_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def javascriptify_pattern(pattern)\n pattern.gsub!(/^\\\\A/, '^')\n pattern.gsub!(/\\\\z$/, '$')\n \"/#{pattern}/\"\n end",
"def reencode_string(input); end",
"def string_replacements\nend",
"def id3 pattern\n id3tool(pattern).encode! 'UTF-8',\n ... | [
"0.6729404",
"0.63441247",
"0.6325576",
"0.63092875",
"0.6298945",
"0.62757164",
"0.6254565",
"0.61993325",
"0.61525327",
"0.6091126",
"0.6013831",
"0.600055",
"0.600055",
"0.5995484",
"0.5995484",
"0.5995484",
"0.5991386",
"0.5923532",
"0.59208715",
"0.590815",
"0.590815",
... | 0.6861212 | 0 |
Are there replacement parameters configured for term fetch? | def term_replacements?
term_replacement_count.positive?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def term_replacements\n return @term_replacements unless @term_replacements.nil?\n @term_replacements = {}\n @term_replacements = term_url_mappings.select { |k, _v| !term_qa_replacement_patterns.value?(k.to_s) } unless term_config.nil? || term_url_mappings.nil?\n @term_replacements\n ... | [
"0.6010386",
"0.57534367",
"0.5718806",
"0.5673127",
"0.56246346",
"0.55411404",
"0.5516069",
"0.5513188",
"0.54924035",
"0.54756874",
"0.54684055",
"0.54171485",
"0.5373414",
"0.53592384",
"0.535789",
"0.535789",
"0.535762",
"0.535565",
"0.53330994",
"0.53172326",
"0.5297368... | 0.5932273 | 1 |
Should the replacement parameter be encoded? | def term_replacement_encoded?(map_key)
return false unless term_url_mappings[map_key].key? :encode
term_url_mappings[map_key][:encode]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reencode_string(input); end",
"def encode_string_ex; end",
"def replace(input, string, replacement = T.unsafe(nil)); end",
"def replace\n end",
"def normalize_encode_params(params); end",
"def term_qa_replacement_encoded?(pattern_key)\n map_key = term_qa_replacement_patterns[pattern_key].to_s... | [
"0.67503697",
"0.66480947",
"0.65140265",
"0.64896667",
"0.64593476",
"0.6415307",
"0.6285969",
"0.6257486",
"0.6235421",
"0.6230398",
"0.62216794",
"0.6167915",
"0.6162557",
"0.6162557",
"0.61597395",
"0.6130953",
"0.6097707",
"0.6089438",
"0.60717064",
"0.60704106",
"0.6069... | 0.6386572 | 6 |
Return the number of possible replacement values to make in the term URL | def term_replacement_count
term_replacements.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_of_url_in_seo(input)\n\t \tNonAdwordUrl.where(url: input).count\n\t end",
"def term_replacements?\n term_replacement_count.positive?\n end",
"def word_count\n @tried_solutions.length\n end",
"def nonadword_count_total(page)\n\t\tnonadword_urls(page).length\n\tend",
"def url_cont... | [
"0.60595226",
"0.5989144",
"0.58407545",
"0.5704308",
"0.56784153",
"0.5633429",
"0.5622745",
"0.54799354",
"0.5425366",
"0.5361639",
"0.5361229",
"0.5356592",
"0.52727115",
"0.5229313",
"0.5228294",
"0.5195668",
"0.5195668",
"0.51910275",
"0.51777726",
"0.51773554",
"0.51716... | 0.76797587 | 0 |
Return the replacement configurations | def term_replacements
return @term_replacements unless @term_replacements.nil?
@term_replacements = {}
@term_replacements = term_url_mappings.select { |k, _v| !term_qa_replacement_patterns.value?(k.to_s) } unless term_config.nil? || term_url_mappings.nil?
@term_replacements
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_replacements; end",
"def as_replacements; end",
"def as_replacements; end",
"def replaces\n @replaces ||= []\n end",
"def replaces\n @replaces ||= []\n end",
"def configurations; end",
"def matched_configs\n [@full_config['environments'][environment], @full_config['nodes'][f... | [
"0.67082316",
"0.67082316",
"0.67082316",
"0.64707136",
"0.64707136",
"0.63352954",
"0.62769514",
"0.6205945",
"0.6161139",
"0.61302644",
"0.60717314",
"0.59082615",
"0.5874846",
"0.5815852",
"0.5788381",
"0.5767073",
"0.5767073",
"0.5767073",
"0.5710181",
"0.56625044",
"0.56... | 0.5943522 | 11 |
Are there subauthorities configured for term fetch? | def term_subauthorities?
term_subauthority_count.positive?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def term_subauthorities\n @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities)\n @term_subauthorities ||= term_config[:subauthorities]\n end",
"def term_subauthority_count\n term_subauthorities.size\n end",
"def subauthorities\n SUBAUTHORITIES... | [
"0.75910294",
"0.7062189",
"0.69789237",
"0.693804",
"0.63819087",
"0.6315325",
"0.62678456",
"0.62612593",
"0.62366945",
"0.6191987",
"0.59692997",
"0.5802569",
"0.5756488",
"0.5755255",
"0.5706198",
"0.5681793",
"0.5681793",
"0.56603545",
"0.56513065",
"0.56513065",
"0.5620... | 0.7887249 | 0 |
Is a specific subauthority configured for term fetch? | def term_subauthority?(subauth_name)
subauth_name = subauth_name.to_sym if subauth_name.is_a? String
term_subauthorities.key? subauth_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def term_subauthorities?\n term_subauthority_count.positive?\n end",
"def term_subauthorities\n @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities)\n @term_subauthorities ||= term_config[:subauthorities]\n end",
"def term_subauthority_count\n ... | [
"0.765371",
"0.6534615",
"0.64777064",
"0.6447676",
"0.6109477",
"0.59710646",
"0.58551747",
"0.58389294",
"0.58365357",
"0.5820499",
"0.57719266",
"0.5747871",
"0.5732477",
"0.5693589",
"0.56495875",
"0.55933917",
"0.55773175",
"0.556693",
"0.55357575",
"0.55251074",
"0.5497... | 0.83130115 | 0 |
Return the number of subauthorities defined for term fetch | def term_subauthority_count
term_subauthorities.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def term_subauthorities\n @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities)\n @term_subauthorities ||= term_config[:subauthorities]\n end",
"def term_subauthorities?\n term_subauthority_count.positive?\n end",
"def subauthorities\n SUBAUTHO... | [
"0.7275419",
"0.7162359",
"0.6783471",
"0.65590227",
"0.596303",
"0.5954418",
"0.59074116",
"0.59045035",
"0.5845982",
"0.5794759",
"0.57620573",
"0.57620573",
"0.5733754",
"0.57333744",
"0.5708774",
"0.5674188",
"0.5631695",
"0.5631695",
"0.56295884",
"0.5615472",
"0.5564155... | 0.85006934 | 0 |
Return the list of subauthorities for term fetch | def term_subauthorities
@term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities)
@term_subauthorities ||= term_config[:subauthorities]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subauthorities\n SUBAUTHORITIES.keys\n end",
"def term_subauthority_count\n term_subauthorities.size\n end",
"def term_subauthorities?\n term_subauthority_count.positive?\n end",
"def secondary_terms\n []\n end",
"def secondary_terms\n []\n end",
"d... | [
"0.76643497",
"0.69095445",
"0.6396478",
"0.61391807",
"0.61391807",
"0.61391807",
"0.6114977",
"0.6111542",
"0.5898662",
"0.5822158",
"0.57895225",
"0.57468915",
"0.57323104",
"0.5702708",
"0.5702091",
"0.5699518",
"0.5672731",
"0.5664483",
"0.565798",
"0.56277585",
"0.56123... | 0.79320955 | 0 |
Return the replacement configurations | def term_subauthority_replacement_pattern
return {} unless term_subauthorities?
@term_subauthority_replacement_pattern ||= {} if term_config.nil? || !term_subauthorities?
pattern = term_qa_replacement_patterns[:subauth]
@term_subauthority_replacement_pattern ||= { pattern: pattern, default: term_url_mappings[pattern.to_sym][:default] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_replacements; end",
"def as_replacements; end",
"def as_replacements; end",
"def replaces\n @replaces ||= []\n end",
"def replaces\n @replaces ||= []\n end",
"def configurations; end",
"def matched_configs\n [@full_config['environments'][environment], @full_config['nodes'][f... | [
"0.67082316",
"0.67082316",
"0.67082316",
"0.64707136",
"0.64707136",
"0.63352954",
"0.62769514",
"0.6205945",
"0.6161139",
"0.61302644",
"0.60717314",
"0.5943522",
"0.59082615",
"0.5874846",
"0.5815852",
"0.5788381",
"0.5767073",
"0.5767073",
"0.5767073",
"0.5710181",
"0.566... | 0.0 | -1 |
This tries an average of 16 times to get aligned encryption | def encrypt(box, message)
while true
# We add even more randomness to erase any patterns in random_prefix
# It's not necessary for this one, but could be in more realistic attack
random_pad = "A" * rand(0..15)
encrypted = box.call(random_pad + alignment_block + message)
i = 0
while i + 80 < encrypted.size
blocks = encrypted[i, 80]
if blocks[0,16] == blocks[16,16] &&
blocks[0,16] != blocks[32,16] &&
blocks[0,16] == blocks[48,16] &&
blocks[0,16] == blocks[64,16]
return encrypted[i+80..-1]
end
i += 16
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_block_size\n (size/8)-12\n end",
"def vigenere_cipher(message, keys)\n alphabet = (\"a\"..\"z\").to_a\n indices = message.split(\"\").map {|char| alphabet.index(char)}\n \n ciphered_message = \"\"\n indices.each_with_index do |n, i|\n shift_amount = keys[i % keys.length]\n ... | [
"0.6412979",
"0.6404489",
"0.63950646",
"0.6393603",
"0.63792163",
"0.63783014",
"0.63331944",
"0.6328843",
"0.6294866",
"0.6278272",
"0.6272806",
"0.6262966",
"0.6238474",
"0.62333554",
"0.6211109",
"0.6193841",
"0.6171217",
"0.6158139",
"0.61558175",
"0.6109341",
"0.6105967... | 0.6165188 | 17 |
See current Goodreads Notifications. Note, this will mark them as seen | def notifications(page = 1)
options = {"page" => page}
data = oauth_request("/notifications.xml", options)
Hashie::Mash.new(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seen\n if @ok\n @ok = @notification.has_been_seen\n end\n @new_notifications = current_user.number_notifications_not_seen\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def saw_notific... | [
"0.6556326",
"0.65034765",
"0.639331",
"0.6387553",
"0.6336311",
"0.6316533",
"0.62613624",
"0.6221774",
"0.62205684",
"0.62104297",
"0.6208574",
"0.62054366",
"0.6193375",
"0.6185426",
"0.6124191",
"0.61023325",
"0.60834783",
"0.60366696",
"0.59945333",
"0.5955392",
"0.59484... | 0.0 | -1 |
Problem 19 You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirtyone, Saving February alone, Which has twentyeight, rain or shine. And on leap years, twentynine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? | def sundayCounter
days = [31,28,31,30,31,30,31,31,30,31,30,31]
date, sundays = 0, 1
(1901...2000).each do
(0..11).each do |month|
date = (date + days[month]) % 7
sundays += 1 if date == 6
end
end
sundays
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countSundaysYear(year, startDay)\n\tsundays = 0\n\tday = startDay % 7\n\tif(isLeapYear(year))\n\t\tyear = $MonthsLeap\n\telse\n\t\tyear = $Months\n\tend\n\t\n\tyear.each do |x|\n\t\tif(day == 0)\n\t\t\tsundays += 1\n\t\tend\n\t\tday = ((day + x) % 7)\n\t\t\n\tend\n\t\n\treturn sundays\nend",
"def total_sunda... | [
"0.7031975",
"0.69888425",
"0.6858229",
"0.6805469",
"0.68043214",
"0.6795406",
"0.67244285",
"0.6660073",
"0.6636704",
"0.6620901",
"0.65219444",
"0.64850533",
"0.64824045",
"0.64739656",
"0.6443859",
"0.6441277",
"0.6403524",
"0.63678235",
"0.63574046",
"0.6337407",
"0.6311... | 0.652602 | 10 |
origin_price should be input as rounded up integer dollar val | def initialize(make, model, make_year, origin_price)
@make = make
@model = model
@make_year = make_year
@origin_price = origin_price
@current_value = current_value
@dealer_price = current_value + dealer_markup
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_in_cents\n Integer(price*100 + 0.5)\n end",
"def price_adjustment \n price_adjustment_fixed / 100.0 \n end",
"def price_in_cents\n\t\tInteger(price * 100 + 0.5)\n\tend",
"def price_in_cents\n\t\tInteger(price * 100 + 0.50)\n\tend",
"def price_in_cents\n\t\tInteger(@price*100 + 0.5)\n\tend... | [
"0.7081104",
"0.7062171",
"0.7015531",
"0.69937783",
"0.6971159",
"0.69410735",
"0.6865865",
"0.6708257",
"0.6700364",
"0.6696963",
"0.6649046",
"0.6646286",
"0.6624281",
"0.66184884",
"0.6600148",
"0.65886587",
"0.6532084",
"0.6522088",
"0.6519116",
"0.6512718",
"0.6457268",... | 0.0 | -1 |
markup arbitrarily determined here to be 8% of MSRP (origin price) | def dealer_markup
(origin_price*0.08).round
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markup_tirerack(price)\n (((price + 12.50) * 1.35) * 1.16) \n end",
"def base_markup_price\n @base_price + (@base_price * Flat_Markup_Rate)\n end",
"def mark_up_amt\n rounder5(self.vehicle.price * 0.082)\n end",
"def calculate_markup()\n markup = @selling_price - @buyi... | [
"0.74036324",
"0.6854294",
"0.6535629",
"0.6514163",
"0.647483",
"0.6389953",
"0.6388788",
"0.6351148",
"0.63147366",
"0.6259358",
"0.61915433",
"0.6176857",
"0.60935986",
"0.60457134",
"0.60196584",
"0.5968887",
"0.59479433",
"0.5946795",
"0.59375715",
"0.5900401",
"0.589778... | 0.74139893 | 0 |
As part of 101 lesson requirements. I will need three pieces of information: the loan amount the Annual Percentage Rate (APR) the loan duration from the above, I will calculate the following two things: 1) monthly interest Rate 2) loan duration in months This is the formula: m = p (j / (1 (1 + j)(n))) m = monthly payment, p = loan amount, j = monthly interest rate, n = loan duration in months the code should be run through Rubocop | def prompt(message)
puts("=>#{message}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_monthly_pay(loan_amount, interest_rate, loan_duration)\n loan_amount * (interest_rate * ( 1 + interest_rate) * loan_duration) /\n (interest_rate * ( 1 + interest_rate) * (loan_duration - 1))\nend",
"def calculate_apr\n payment_ratio = monthly_payment_with_fees / loan_amount\n f = lambda... | [
"0.7767276",
"0.741205",
"0.7370564",
"0.7325309",
"0.72984415",
"0.7290021",
"0.7176764",
"0.7147285",
"0.7076989",
"0.7007485",
"0.6972636",
"0.69348717",
"0.6841337",
"0.6819061",
"0.67889756",
"0.67024094",
"0.66294926",
"0.6604359",
"0.6534027",
"0.64861894",
"0.6484733"... | 0.0 | -1 |
Recursive Depth First Search | def find(root, data)
current_node = root
if current_node.title == data
return current_node
elsif current_node.left != nil
find(current_node.left, data)
elsif current_node.right != nil
find(current_node.right, data)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then ch... | [
"0.75888014",
"0.7499341",
"0.74279803",
"0.7419357",
"0.73943675",
"0.73359835",
"0.72105503",
"0.71925867",
"0.7169048",
"0.71621275",
"0.7159493",
"0.7157254",
"0.7154016",
"0.71169007",
"0.7078584",
"0.7065554",
"0.7062552",
"0.70263875",
"0.69791156",
"0.69565874",
"0.69... | 0.0 | -1 |
Recursive Breadth First Search | def printf(children=nil)
new_children = []
if children == nil
children = [@root.left, @root.right]
puts @root.title.to_s + ": " + @root.rating.to_s
end
children.each do |ch|
if ch != nil
puts ch.title.to_s + ": " + ch.rating.to_s
new_children.push(ch.left) if ch.left
new_children.push(ch.right) if ch.right
end
end
if new_children != []
printf(new_children)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do... | [
"0.75271535",
"0.75112754",
"0.7444565",
"0.73405594",
"0.7280742",
"0.7275826",
"0.7228846",
"0.72257054",
"0.720302",
"0.716926",
"0.7132503",
"0.707997",
"0.7053239",
"0.7046879",
"0.7041311",
"0.70368093",
"0.699208",
"0.6980703",
"0.697969",
"0.6918669",
"0.6910106",
"... | 0.0 | -1 |
Lambda for OCLC Number | def argot_oclc_number(config)
lambda do |rec, acc|
st = {}
config.each do |key, spec|
extractor = MarcExtractor.cached(spec, separator: nil)
oclc_num = extractor.extract(rec).collect! do |o|
Marc21Semantics.oclcnum_extract(o)
end.compact
oclc_num = oclc_num.uniq
if key == 'value'
st[key] = oclc_num.first if oclc_num
else
st[key] = oclc_num unless oclc_num.empty?
end
end
val = st['value']
acc << st unless val.nil? || val.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_proc\n lambda do |v|\n n = Version::Number.parse(v)\n n.send(operator, number)\n end\n end",
"def oclcnum(extract_fields = \"035a\")\n extractor = MarcExtractor.new(extract_fields, :separator => nil)\n\n lambda do |record, accumulator|\n list = extractor.extract... | [
"0.6357634",
"0.5922278",
"0.57377696",
"0.5723621",
"0.5705648",
"0.5604444",
"0.56027",
"0.56027",
"0.557201",
"0.5550252",
"0.5523592",
"0.5519715",
"0.549374",
"0.5487778",
"0.5479818",
"0.54736334",
"0.54540896",
"0.5410149",
"0.5382446",
"0.53263617",
"0.532513",
"0.5... | 0.60230523 | 1 |
Lambda for Rollup ID | def argot_rollup_id(spec)
lambda do |rec, acc|
extractor = MarcExtractor.cached(spec, separator: nil)
oclc_num = extractor.extract(rec).collect! do |o|
Marc21Semantics.oclcnum_extract(o)
end.compact
acc << "OCLC#{oclc_num.first}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_id \n end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def id_number; end",
"def source_record_id_proc\n @source_record_id_proc ||= lambda do |source_xml_record|\n if ( source_xml_record &&\n source_xml_record.kind_of?(Nokogiri::X... | [
"0.5741075",
"0.5738728",
"0.5738728",
"0.5738728",
"0.56978136",
"0.55969846",
"0.55409384",
"0.55069935",
"0.5503045",
"0.5482689",
"0.5459605",
"0.54581225",
"0.5438138",
"0.5433964",
"0.541559",
"0.5391834",
"0.5383986",
"0.5342479",
"0.5276477",
"0.5270603",
"0.52628195"... | 0.5822824 | 0 |
Lambda for Generic Vernacular Object | def argot_gvo(spec)
lambda do |rec, acc|
gvo = ArgotSemantics.get_gvo(rec, spec)
acc << gvo if gvo
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda; end",
"def call(object); end",
"def initialize\n @get_target_type = ->t{t}\n @get_target_field = ->f{f.name}\n @get_target_key = ->f{f.name}\n yield(self) if block_given?\n end",
"def to_proc\n ->(**properties) { perform(**properties) }\n end",
"def to_proc()\n #... | [
"0.60795176",
"0.5592288",
"0.5591423",
"0.5572634",
"0.555421",
"0.5429147",
"0.5429147",
"0.5367591",
"0.53259087",
"0.5301907",
"0.52794814",
"0.5279038",
"0.5251005",
"0.52347434",
"0.51998305",
"0.51756805",
"0.51756805",
"0.51631045",
"0.513148",
"0.51228267",
"0.511899... | 0.0 | -1 |
Converts an array of string to a delimited hierarchical facet value as expected by blacklighthierarchy. e.g. [foo, bar, baz] => [ foo, foo:bar, foo:bar:baz ] | def array_to_hierarchy_facet(args, delimiter = ':')
result = []
args.each_with_object([]) do |part, acc|
acc << part
result << acc.join(delimiter)
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explode_hierarchical_strings(array_of_strings, delimiter = ':')\n split_arrays = array_of_strings.map { |s| s.split(delimiter) }\n result = arrays_to_hierarchy(split_arrays)\n result.flatten.uniq\n end",
"def hierarchies(array)\n count = 0\n array.reduce([]) { |acc, value| acc << arra... | [
"0.70578915",
"0.64761114",
"0.5879758",
"0.56592804",
"0.55354136",
"0.5523862",
"0.54923004",
"0.5476224",
"0.54631925",
"0.5461544",
"0.54139006",
"0.53507465",
"0.533705",
"0.5281066",
"0.5243991",
"0.52384645",
"0.51868445",
"0.5181798",
"0.5178788",
"0.5171019",
"0.5158... | 0.7959872 | 0 |
Converts array of strings representing a hierarchical values to delimited hierarchical facet values as expected by blacklighthierarchy ['a:b:c', 'a:b:d'] => ['a', 'a:b', 'a:b:c', 'a:b:d'] | def explode_hierarchical_strings(array_of_strings, delimiter = ':')
split_arrays = array_of_strings.map { |s| s.split(delimiter) }
result = arrays_to_hierarchy(split_arrays)
result.flatten.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_to_hierarchy_facet(args, delimiter = ':')\n result = []\n args.each_with_object([]) do |part, acc|\n acc << part\n result << acc.join(delimiter)\n end\n result\n end",
"def hierarchies(array)\n count = 0\n array.reduce([]) { |acc, value| acc << array.slice(0, ... | [
"0.75897133",
"0.68396264",
"0.56584704",
"0.5637435",
"0.5493297",
"0.5491261",
"0.547969",
"0.5433971",
"0.541508",
"0.53570455",
"0.52750045",
"0.5250995",
"0.52423036",
"0.5211978",
"0.5209984",
"0.517046",
"0.51555926",
"0.51446605",
"0.5127346",
"0.509258",
"0.50875884"... | 0.7194458 | 1 |
Generate and deliver the +New Pending Interest Point+ email for this +Interest Point+. | def notify_administrators!
AdminMailer.new_pending_interest_point(self).deliver!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appointment_pending(appoint_obj)\n @doctor = Doctor.find_by_id(appoint_obj.doctor_id)\n @patient = Patient.find_by_id(appoint_obj.patient_id)\n mail(:to => @doctor.email, :subject => \"New Appointment\")\n end",
"def create\n @interest = GtInterest.new(:email => params[:email], :priority_... | [
"0.6468352",
"0.62967336",
"0.6296137",
"0.6221056",
"0.6101837",
"0.60765684",
"0.6039849",
"0.60067147",
"0.59220046",
"0.59165615",
"0.5905543",
"0.5903814",
"0.5892711",
"0.5867239",
"0.5867175",
"0.58389395",
"0.58187854",
"0.5817787",
"0.5804259",
"0.5802057",
"0.577427... | 0.64498854 | 1 |
Ensure the given +latitude+ and +longitude+ coordinates are rounded to six decimal places. | def normalize_coordinates
self.latitude = latitude.round(6) unless self.latitude.nil?
self.longitude = longitude.round(6) unless self.longitude.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_float(float, places); end",
"def compute_latitude_precision\n if code_length <= 10\n return 20**(code_length/-2.0 + 2).floor\n end\n\n (20**-3).to_f/GRID_ROWS**(code_length - 10)\n end",
"def latitude=(lat)\n write_attribute(:latitude, lat.round(10)) if lat\n end",
"def... | [
"0.60885",
"0.57529616",
"0.5489223",
"0.5427365",
"0.5411109",
"0.53360134",
"0.5324703",
"0.52733594",
"0.5253657",
"0.5242261",
"0.5209345",
"0.5122058",
"0.51209885",
"0.5113649",
"0.50571954",
"0.50546175",
"0.5041673",
"0.50359476",
"0.5034785",
"0.50304675",
"0.5005363... | 0.6582302 | 0 |
Should return "/v2.0/teachers/5798dc36fd5e25eb150010b5" from example above | def extract_canonical_uri
user_info['links'].find { |link| link['rel'] == 'canonical' }['uri']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beer_url(id)\n \"/beer/a/#{id}/\"\n end",
"def person_url(id)\n 'https://swapi.co/api/people/' + id.to_s\nend",
"def api_url(id)\n name = get_tourney_name(id)\n return \"https://api.challonge.com/v1/tournaments/uxie#{id}#{name}\"\nend",
"def url_for(base_url,msg)\n if msg[:id]\n ... | [
"0.6007966",
"0.5977593",
"0.5583188",
"0.54437757",
"0.527635",
"0.5251688",
"0.5192246",
"0.5156103",
"0.51297456",
"0.51263756",
"0.5124937",
"0.51007396",
"0.5092284",
"0.5092284",
"0.50903",
"0.50868124",
"0.5076263",
"0.5073722",
"0.5073722",
"0.50692886",
"0.5060033",
... | 0.0 | -1 |
Fix unknown redirect uri bug by NOT appending the query string to the callback url. | def callback_url
full_host + script_name + callback_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_redirect_url\n referer = params[:referer].blank? ? request.referer : params[:referer]\n\n if referer && (referer =~ %r|^https?://#{request.host}#{root_path}| ||\n referer =~ %r|^https?://#{request.host}:#{request.port}#{root_path}|)\n #self-referencing absolute url, make it relative... | [
"0.6365701",
"0.63536686",
"0.61407256",
"0.6077731",
"0.6034369",
"0.6021571",
"0.58974534",
"0.588566",
"0.5851072",
"0.5834352",
"0.5813037",
"0.5809574",
"0.5778022",
"0.5778022",
"0.57420623",
"0.5735997",
"0.57337517",
"0.57075775",
"0.5703975",
"0.5703975",
"0.5674207"... | 0.0 | -1 |
Get the result of the $findAndModify. | def result
query.modify(update, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n return performModify(true)\n end",
"def returnModified\n @modified\n end",
"def find(id)\n item = raw_find(id)\n item && item.dup\n end",
"def find(id)\n find_result\n end",
"def find_one(&block)\r\n copy_and_return(@records.find(&... | [
"0.5862556",
"0.55104643",
"0.54943925",
"0.5474354",
"0.5413498",
"0.53044766",
"0.5205306",
"0.5123025",
"0.51167256",
"0.51167256",
"0.51167256",
"0.51167256",
"0.51167256",
"0.50995266",
"0.50995266",
"0.5090242",
"0.5065189",
"0.50116605",
"0.49801886",
"0.49383828",
"0.... | 0.6770018 | 0 |
Apply criteria specific options query, sort, fields. | def apply_criteria_options
if spec = criteria.options[:sort]
query.sort(spec)
end
if spec = criteria.options[:fields]
query.select(spec)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_criteria_options\n unless criteria.selector.empty?\n command[:pipeline][0][\"$match\"] = criteria.selector\n end\n if sort = criteria.options[:sort]\n command[:pipeline][0][\"$sort\"] = sort\n end\n if limit = criteria.options[:limit]\n comman... | [
"0.8088539",
"0.70572263",
"0.6368393",
"0.63588494",
"0.6208496",
"0.6161933",
"0.6133352",
"0.60946697",
"0.6013391",
"0.58840793",
"0.5879875",
"0.5849001",
"0.5837559",
"0.58297706",
"0.58201605",
"0.5810793",
"0.5763901",
"0.5757591",
"0.5730743",
"0.5725456",
"0.5712985... | 0.88595235 | 0 |
GET /commonquestions GET /commonquestions.json | def index
@commonquestions = Commonquestion.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend",
"def check_que... | [
"0.72750646",
"0.71509826",
"0.70095444",
"0.6462304",
"0.64283323",
"0.64195925",
"0.63508797",
"0.6302301",
"0.6289258",
"0.6273065",
"0.6269526",
"0.6268268",
"0.6259093",
"0.6258808",
"0.6236391",
"0.6234356",
"0.6164906",
"0.61386216",
"0.6108544",
"0.60882604",
"0.60879... | 0.7370706 | 0 |
GET /commonquestions/1 GET /commonquestions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def index\n @commonquestions = Commonquestion.all\n end",
"def get_questions\n items = get_items\n make_response... | [
"0.7184319",
"0.71793646",
"0.7100766",
"0.686292",
"0.6730551",
"0.6579878",
"0.656613",
"0.6557363",
"0.65492606",
"0.6527257",
"0.65143925",
"0.6509181",
"0.6507267",
"0.64820874",
"0.6428335",
"0.638812",
"0.6345387",
"0.6337881",
"0.63206947",
"0.6283913",
"0.6269919",
... | 0.0 | -1 |
POST /commonquestions POST /commonquestions.json | def create
@commonquestion = Commonquestion.new(commonquestion_params)
@commonquestion.question_id = params[:question_id]
@commonquestion.parttype_id = params[:parttype_id]
@commonquestion.questiontype_id = params[:questiontype_id]
respond_to do |format|
if @commonquestion.save
format.html { redirect_to @commonquestion, notice: 'Commonquestion was successfully created.' }
format.json { render :show, status: :created, location: @commonquestion }
else
format.html { render :new }
format.json { render json: @commonquestion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commonquestion_params\n params.require(:commonquestion).permit(:commonquestion_id, :question_text, :options, :answer_option_number, :question_id, :parttype_id, :questiontype_id)\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_in... | [
"0.6820088",
"0.6492851",
"0.6483083",
"0.64829385",
"0.63913435",
"0.6379721",
"0.62458825",
"0.6204053",
"0.6191769",
"0.61807805",
"0.61792463",
"0.61736166",
"0.6161171",
"0.61556166",
"0.6154535",
"0.6146767",
"0.6118",
"0.607924",
"0.6077475",
"0.6076541",
"0.60720456",... | 0.70868933 | 0 |
PATCH/PUT /commonquestions/1 PATCH/PUT /commonquestions/1.json | def update
@commonquestion.question_id = params[:question_id]
@commonquestion.parttype_id = params[:parttype_id]
@commonquestion.questiontype_id = params[:questiontype_id]
respond_to do |format|
if @commonquestion.update(commonquestion_params)
format.html { redirect_to @commonquestion, notice: 'Commonquestion was successfully updated.' }
format.json { render :show, status: :ok, location: @commonquestion }
else
format.html { render :edit }
format.json { render json: @commonquestion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.67997867",
"0.6793198",
"0.6777838",
"0.67436785",
"0.6689164",
"0.6678309",
"0.6670506",
"0.6572901",
"0.65071225",
"0.648953",
"0.6486658",
"0.64773506",
"0.64766",
"0.6467119",
"0.64647025",
"0.6438719",
"0.6433398",
"0.64145887",
"0.6413029",
"0.6413029",
"0.6413029",
... | 0.6797166 | 1 |
DELETE /commonquestions/1 DELETE /commonquestions/1.json | def destroy
@commonquestion.destroy
respond_to do |format|
format.html { redirect_to commonquestions_url, notice: 'Commonquestion was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |... | [
"0.7381674",
"0.72378504",
"0.7228066",
"0.7203905",
"0.7185327",
"0.7160035",
"0.7145627",
"0.71429074",
"0.71427125",
"0.7140694",
"0.7135828",
"0.7135828",
"0.7135828",
"0.7135828",
"0.7135828",
"0.7135828",
"0.7121184",
"0.7119238",
"0.71085715",
"0.7104204",
"0.7101424",... | 0.76137227 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_commonquestion
@commonquestion = Commonquestion.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 commonquestion_params
params.require(:commonquestion).permit(:commonquestion_id, :question_text, :options, :answer_option_number, :question_id, :parttype_id, :questiontype_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
First Init , return error string or nil | def init_var
@all_glossaries_configs = []
@dict_id = params[:dict_id]
DictConfig.all().each {|d|
if d.protocol=='glossary'
@all_glossaries_configs << d
@dict_id = d['dict_sys_name'] if @dict_id == nil
end
}
params[:dict_id] = @dict_id
puts("ALL ")
puts(DictConfig.where(protocol: 'glossary').inspect())
@key_lang = "?"
@prim_lang = "?"
@sec_lang = "?"
@dict_name = "?"
@dict_id = nil
@dict_config=nil
if params[:dict_id]==nil
return
end
@dict_config=DictConfig.find_by( dict_sys_name: params[:dict_id])
puts("dict_config"+@dict_config.inspect())
if @dict_config==nil
return
end
puts("OK")
begin
@dict_ext_cfg = JSON.parse(@dict_config.cfg)
rescue Exception => e
return
end
puts(@dict_config.inspect)
@dict_name = @dict_config.dict_name
@key_lang = @dict_ext_cfg['config']['key_words_lang']
@prim_lang = @dict_ext_cfg['config']['primary_xlate_lang']
@sec_lang = @dict_ext_cfg['config']['secondary_xlate_lang']
@dict_id= params[:dict_id]
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @mes = \"Error: Not enough arguments\"\n end",
"def init\n @init.call if @init\n end",
"def load_error=(_arg0); end",
"def init\n end",
"def init\n end",
"def init\n end",
"def init\n raise NotImplementedError\n end",
"def init; end",
"def init; ... | [
"0.6321575",
"0.6040971",
"0.60351413",
"0.5995689",
"0.5995689",
"0.5995689",
"0.59926957",
"0.5960617",
"0.5960617",
"0.5960617",
"0.5960617",
"0.59112006",
"0.58675545",
"0.58289504",
"0.58198303",
"0.58198303",
"0.58198303",
"0.58198303",
"0.5812501",
"0.58097774",
"0.578... | 0.0 | -1 |
GET /glossaries GET /glossaries.json | def index
@glossaries = []
err = init_var()
if(@dict_id!=nil)
if params[:to_search] == nil or
params[:to_search] == ''
@glossaries = Glossary.where(
[ "dict_id = :dict_id ",
{ dict_id: @dict_id } ] ).limit(100)
else
@glossaries = Glossary.where(
[ "dict_id = :dict_id and key_words = :key_words ",
{ dict_id: @dict_id , key_words: params[:to_search] } ] )
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if logged_in?\n @glossaries = current_user.glossaries.find(:all)\n end\n end",
"def new\n @glossary = Glossary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glossary }\n end\n end",
"def show\n set_glossary_locale(params... | [
"0.7041864",
"0.700592",
"0.6751456",
"0.6749251",
"0.66519606",
"0.6384426",
"0.62804675",
"0.6259578",
"0.6253161",
"0.6244677",
"0.61971176",
"0.61315054",
"0.6062072",
"0.6058682",
"0.60491383",
"0.59864384",
"0.5920943",
"0.59018576",
"0.58186656",
"0.57629323",
"0.57625... | 0.64131814 | 5 |
GET /glossaries/1 GET /glossaries/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @glossary = Glossary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glossary }\n end\n end",
"def show\n set_glossary_locale(params[:locale]) if params[:locale]\n\n respond_to do |format|\n format.html {\n redirect_to glos... | [
"0.72177964",
"0.68546724",
"0.67641246",
"0.6727119",
"0.6675556",
"0.65795195",
"0.6497935",
"0.64530826",
"0.6395647",
"0.63722885",
"0.6309516",
"0.62783295",
"0.6224003",
"0.6196973",
"0.60680306",
"0.6042106",
"0.5939551",
"0.5922832",
"0.5922549",
"0.5921715",
"0.58234... | 0.0 | -1 |
POST /glossaries POST /glossaries.json | def create
@glossary = Glossary.new(glossary_params)
@glossary.setup_record()
respond_to do |format|
if @glossary.save
format.html { redirect_to @glossary, notice: 'Glossary was successfully created.' }
format.json { render :show, status: :created, location: @glossary }
else
format.html { render :new }
format.json { render json: @glossary.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @glossary = Glossary.create_glossary(params[:glossary])\n\n respond_to do |format|\n if @glossary.save\n format.html { redirect_to @glossary, notice: 'Glossary was successfully created.' }\n format.json { render json: @glossary, status: :created, location: @glossary }\n e... | [
"0.77519214",
"0.72174704",
"0.7038011",
"0.69908476",
"0.6808631",
"0.67988425",
"0.65565467",
"0.62849045",
"0.6272299",
"0.61735386",
"0.6006929",
"0.5943295",
"0.591612",
"0.5875173",
"0.5840558",
"0.5835021",
"0.5794603",
"0.5789745",
"0.57872903",
"0.5783994",
"0.577263... | 0.7399516 | 1 |
PATCH/PUT /glossaries/1 PATCH/PUT /glossaries/1.json | def update
respond_to do |format|
puts(glossary_params)
tmp = Glossary.new(glossary_params)
tmp.setup_record()
if @glossary.update(tmp.params())
##if @glossary.update(glossary_params)
format.html { redirect_to @glossary, notice: 'Glossary was successfully updated.' }
format.json { render :show, status: :ok, location: @glossary }
else
format.html { render :edit }
format.json { render json: @glossary.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @glossary = Glossary.find(params[:id])\n saved = @glossary.update_glossary(params[:glossary])\n\n respond_to do |format|\n if saved\n format.html { redirect_to @glossary, notice: 'Glossary was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.74667126",
"0.70632654",
"0.70062625",
"0.6846839",
"0.6222206",
"0.614626",
"0.61316836",
"0.61160177",
"0.61103004",
"0.5976634",
"0.5932507",
"0.59037656",
"0.5900743",
"0.5894954",
"0.5874841",
"0.58570397",
"0.582475",
"0.58245444",
"0.5819762",
"0.5819664",
"0.581166... | 0.6999421 | 3 |
DELETE /glossaries/1 DELETE /glossaries/1.json | def destroy
@glossary.destroy
respond_to do |format|
format.html { redirect_to glossaries_url, notice: 'Glossary was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @glossary = Glossary.find(params[:id])\n @glossary.destroy\n\n respond_to do |format|\n format.html { redirect_to glossaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @glossary = Glossary.find(params[:id])\n @glossary.destroy\n\n respond_t... | [
"0.79644775",
"0.7778502",
"0.7603625",
"0.7154395",
"0.6801182",
"0.6768405",
"0.6612433",
"0.6592294",
"0.65574133",
"0.6537899",
"0.64016116",
"0.6386985",
"0.63759434",
"0.6337245",
"0.6326301",
"0.6323726",
"0.6308397",
"0.63069576",
"0.629387",
"0.62894285",
"0.6273795"... | 0.78103 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_glossary
@glossary = Glossary.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 glossary_params
params.require(:glossary).permit(:dict_id, :key_words, :word_type, :category, :primary_xlate, :secondary_xlate,:digest)
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 |
Provide a user friendly representation | def to_s
'#<Twilio.Video.V1.AnonymizeList>'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Provide a user friendly representation | def to_s
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
"#<Twilio.Video.V1.AnonymizeContext #{context}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def to_s\n super\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70447654",
"0.7025946",
"0.70086724",
"0.7008141",
"0.69449997",
"0.691802",
"0.6843895",
"0.6797355",
"0.6655898",
"0.6622141",
"0.66182053",
"0.66182053",
"0.66182053",
"0.66182053",
"0.66182053",
"0.66182053",
"0.66182053",
"0.66182053",
"0.6610882",
"0.6610882",
"0.658... | 0.0 | -1 |
Provide a detailed, user friendly representation | def inspect
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
"#<Twilio.Video.V1.AnonymizeContext #{context}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details; end",
"def to_s; description end",
"def get_detail\n return self.inspect\n end",
"def to_display\n raise NotImplementedError\n end",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for mor... | [
"0.68170065",
"0.68142146",
"0.6758589",
"0.6718451",
"0.66697186",
"0.6655344",
"0.6632312",
"0.66273594",
"0.6550127",
"0.65188134",
"0.6497969",
"0.6480078",
"0.6477721",
"0.6472211",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64... | 0.0 | -1 |
Build an instance of AnonymizeInstance | def get_instance(payload)
AnonymizeInstance.new(@version, payload, room_sid: @solution[:room_sid], sid: @solution[:sid])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @annonce = Annonce.new\n end",
"def alias_create(al)\n obj_create al, Alias\n end",
"def initialize_dup(orig) # :nodoc:\n %w(plurals singulars uncountables humans acronyms).each do |scope|\n instance_variable_set(\"@#{scope}\", orig.public_send(scope).dup)\n end\n ... | [
"0.58793515",
"0.58409786",
"0.56092286",
"0.5321486",
"0.5295065",
"0.52703553",
"0.52703553",
"0.5267412",
"0.5260969",
"0.52586925",
"0.52577084",
"0.51828414",
"0.5177507",
"0.51624614",
"0.5162172",
"0.5156192",
"0.5141632",
"0.51175404",
"0.50931525",
"0.5058805",
"0.50... | 0.60092294 | 0 |
Provide a user friendly representation | def to_s
'<Twilio.Video.V1.AnonymizePage>'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context | def context
unless @instance_context
@instance_context = AnonymizeContext.new(@version , @params['room_sid'], @params['sid'])
end
@instance_context
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def context\n unless @instance_context\n @instance_context = ApplicationContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n ... | [
"0.68377435",
"0.68029237",
"0.6796913",
"0.6771432",
"0.676858",
"0.676858",
"0.67318654",
"0.668226",
"0.66789144",
"0.6678431",
"0.667694",
"0.66405225",
"0.66096514",
"0.659968",
"0.6591387",
"0.6571754",
"0.6567936",
"0.65607464",
"0.65562326",
"0.65496546",
"0.65470076"... | 0.6627461 | 12 |
Provide a user friendly representation | def to_s
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
"<Twilio.Video.V1.AnonymizeInstance #{values}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Provide a detailed, user friendly representation | def inspect
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
"<Twilio.Video.V1.AnonymizeInstance #{values}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details; end",
"def to_s; description end",
"def get_detail\n return self.inspect\n end",
"def to_display\n raise NotImplementedError\n end",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for mor... | [
"0.68170065",
"0.68142146",
"0.6758589",
"0.6718451",
"0.66697186",
"0.6655344",
"0.6632312",
"0.66273594",
"0.6550127",
"0.65188134",
"0.6497969",
"0.6480078",
"0.6477721",
"0.6472211",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64... | 0.0 | -1 |
Takes the 2 users the potential buyer and the seller, and creates a conversation between them. The 'between' scope that is used below is set out in the Conversation model | def create
# If there is an existing conversation between the 2 parties, then the database is queried for the previous conversation and it is displayed.
if Conversation.between(params[:sender_id], params[:recipient_id]).present?
@conversation = Conversation.between(params[:sender_id], params[:recipient_id]).first
else
#if there is no conversation between the two parties, then the beloew line will create a new conversation
@conversation = Conversation.create!(conversation_params)
end
redirect_to conversation_messages_path(@conversation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_or_create\n other_user = User.find(params[:user_id])\n @conversation = Conversation.exactly_between( current_user, other_user ).first || Conversation.create( users: [ current_user, other_user ] )\n\n respond_to do |format|\n if @conversation\n format.json { redirect_to conversation_me... | [
"0.6531311",
"0.6382754",
"0.63439983",
"0.6300932",
"0.615566",
"0.60914356",
"0.6010778",
"0.5955784",
"0.5947428",
"0.5936066",
"0.5931391",
"0.5927772",
"0.59211767",
"0.59054005",
"0.58973795",
"0.5844476",
"0.5828471",
"0.58262336",
"0.58206093",
"0.5764075",
"0.5748435... | 0.6831759 | 0 |
checks value equivalence to another Injury object | def ==(other)
return false if other.class != self.class
if @duration != other.duration
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eql?(other_money); end",
"def ==(object)\n ret = false\n \n if object.is_a?(self.class)\n # Check all of the ids for a match\n ret = @issn == object.issn if !@issn.nil? and !object.issn.nil?\n ret = @eissn == object.eissn if (!@eissn.nil? and !object.eissn.nil?) and !ret\n... | [
"0.62252355",
"0.6120797",
"0.5972296",
"0.5939234",
"0.5834948",
"0.57861185",
"0.5761977",
"0.57472473",
"0.573988",
"0.571628",
"0.5713358",
"0.57033587",
"0.56807",
"0.56793153",
"0.5670396",
"0.5669838",
"0.56670463",
"0.5642039",
"0.563208",
"0.56291735",
"0.56270826",
... | 0.0 | -1 |
Create an association between the trackgroup and an existing account | def create
@account = Account.find(params[:account][:id])
@trackgroup.accounts << @account
redirect_to account_path(:region => @account.region, :idLoL => @account.idLoL)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createAPI\n \n idLoL = LOL_WRAPPER.get_summoner_id(params[:accname], params[:region])\n #Find the summoner with the corresponding id and region\n @summoner = LOL_WRAPPER.get_summoner_by_id(idLoL, params[:region])\n \n #Create or update the corresponding account in our database\n if Accoun... | [
"0.65680975",
"0.6179515",
"0.6166096",
"0.60909253",
"0.60040194",
"0.59851146",
"0.5977151",
"0.59438497",
"0.58988976",
"0.58710617",
"0.58513016",
"0.58250993",
"0.5823167",
"0.58156466",
"0.5795477",
"0.57815784",
"0.5741664",
"0.57300997",
"0.5724349",
"0.5713293",
"0.5... | 0.7417314 | 0 |
Create an association between the trackgroup and the account using the API for find the account | def createAPI
idLoL = LOL_WRAPPER.get_summoner_id(params[:accname], params[:region])
#Find the summoner with the corresponding id and region
@summoner = LOL_WRAPPER.get_summoner_by_id(idLoL, params[:region])
#Create or update the corresponding account in our database
if Account.exists?(:idLoL => idLoL)
@account = Account.find_by_idLoL(idLoL)
@account.pseudoLoL = @summoner.name
@account.save
else
@account = Account.new(idLoL: idLoL, region: params[:region], pseudoLoL: @summoner.name)
@account.save
end
@trackgroup.accounts << @account
redirect_to(:back)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n @account = Account.find(params[:account][:id])\n @trackgroup.accounts << @account\n redirect_to account_path(:region => @account.region, :idLoL => @account.idLoL)\n \n end",
"def create\n megam_rest.post_accounts(to_hash)\n end",
"def add_account(account)\n @accounts[... | [
"0.73351175",
"0.58987296",
"0.585691",
"0.5788956",
"0.5788372",
"0.5784265",
"0.57608414",
"0.5709021",
"0.57020164",
"0.5623236",
"0.56110454",
"0.560429",
"0.5595556",
"0.5553995",
"0.55522555",
"0.553447",
"0.5508299",
"0.5483048",
"0.5443529",
"0.5440238",
"0.54368854",... | 0.6879409 | 1 |
Remove the association between the trackgroup and the account | def destroy
@account = Account.find(params[:account][:idAccount])
@account.trackgroups.delete(@trackgroup)
redirect_to(:back)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_group(group)\n self.groups.destroy group \n end",
"def remove_from_group(group)\n self.memberships.find_by(group_id: group.id).destroy!\n end",
"def delete_related_groups\n \n end",
"def destroy\n Group.delete_groups_and_acls([id])\n end",
"def unlink_project\n self.project.re... | [
"0.6703053",
"0.6574433",
"0.64497894",
"0.64078015",
"0.63958126",
"0.63798153",
"0.63430995",
"0.62892795",
"0.6200289",
"0.6170799",
"0.61654437",
"0.61654437",
"0.611664",
"0.6091575",
"0.60842526",
"0.6076279",
"0.60597086",
"0.60321134",
"0.60212195",
"0.6016487",
"0.59... | 0.76505816 | 0 |
When an invalid search key is provided | def test_invalid_search_key
key = 'asbhjfkds'
val = 'jahfjg'
results = User.new(key, val).search
assert_equal results, [], 'It must return an empty array if no valid search field is provided'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_query_search\n assert_raises(RuntimeError) { DuckDuckGo::search({:bad => :hash}) }\n end",
"def validate_keyword!\n raise ResponseError::ArgumentError.new(\"Search keyword is missing\") if self.keywords.nil?\n raise ResponseError::ArgumentError.new(\"Search keyword is blank\") i... | [
"0.6851448",
"0.6571141",
"0.6411196",
"0.63957906",
"0.6312697",
"0.625414",
"0.6059312",
"0.6052371",
"0.6050583",
"0.6030073",
"0.5966123",
"0.596612",
"0.59601176",
"0.59398204",
"0.58007246",
"0.57896674",
"0.575152",
"0.57205075",
"0.5708595",
"0.5698149",
"0.5688029",
... | 0.7263118 | 0 |
When the search value is not found | def test_missing_search_value
key = '_id'
val = '8098765432'
results = User.new(key, val).search
assert_equal results, [], 'It must return an empty array if no search result is found'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_found; end",
"def search(find_val)\n false\n end",
"def not_found\n @not_found = yield\n end",
"def parse_not_found\n if @input.match?(/% Object \"(.*)\" not found in database\\n/)\n while @input.scan(/%(.*)\\n/) # strip junk\n end\n ... | [
"0.71171206",
"0.6929736",
"0.65412277",
"0.6439798",
"0.63442653",
"0.6289069",
"0.6286666",
"0.6256247",
"0.62430304",
"0.6236858",
"0.6144926",
"0.6132984",
"0.6064994",
"0.6013763",
"0.600359",
"0.59803987",
"0.59547776",
"0.5950873",
"0.5944596",
"0.59420496",
"0.5926359... | 0.6616584 | 2 |
Test for string case insensitive search | def test_case_insensitivity
data = JSON.parse(File.read(User::JSON_FILENAME))
key = 'name'
val = data[0]['name'].downcase
results = User.new(key, val).search
assert_block('The search must ignore string case while matching') { results.include?(data[0]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def case_insensitive_match; end",
"def case_insensitive_match=(_arg0); end",
"def case_insensitive(input)\n return 1 unless input\n\n input.split(\"\").each do |i|\n return 0 if /[[:upper:]]/ =~ i\n end\n\n return 1\n end",
"def case_sensitive?\n true\n end",
"def case... | [
"0.8204122",
"0.7702296",
"0.7471744",
"0.7460243",
"0.74514866",
"0.7351669",
"0.731728",
"0.7147571",
"0.7125956",
"0.7116514",
"0.69175905",
"0.6901857",
"0.6888603",
"0.68343616",
"0.6830883",
"0.6830476",
"0.6806664",
"0.6806233",
"0.66675276",
"0.66439974",
"0.663596",
... | 0.74331015 | 5 |
sms superfunction for receiving texts | def receive_sms
uninitialize_sms
body = params[:Body]
phone_number = normalize_phone params[:From].strip
@problem_text = body.split
action = sms_parsing(body).downcase
if action == "join"
sms_create_account
return
elsif Account.find_by_phone_number(phone_number) == nil
sms_send(params[:From], "Please first create an account by texting the word 'join'.")
return
end
if !@sms_error
case action
when /^add$/,/^insert$/
sms_create
when /^accept$/
sms_accept_problem
when /^get$/
@offset = false
sms_get(0)
when /^edit$/
sms_edit
when /^delete$/, /^destroy$/
sms_delete
when /^next$/
offset = session["offset"]
if offset == nil
sms_error("Sorry, there is no saved session right now. Please first text \"GET\" with @location !skill %number of texts you want to allow.")
else
@offset = true
sms_get(offset)
end
when /^detail$/, /^details$/, /^describe$/
sms_detail
when /^account$/
forgot_acc
when /^change$/
sms_change_password
when /^password$/
forgot_password
# when /^skill$/, /^skills$/
# sms_skill
when /^keywords$/, /^key$/, /^keys$/, /^help$/
sms_keywords
when /^explain$/
sms_explain
else
if is_num?(action)
session[:received_confirmation] = action
sms_confirm_acc
else
sms_wrong_keyword
end
end
end
render :nothing => true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_sms\n @view = \"sms\"\n @body = params[\"Body\"]\n @phone_number = params[\"From\"]\n set_user_create_message_parse_and_point\n end",
"def new; send_sms; end",
"def send_text\n Rails.logger.info \"Sending \\\"#{text}\\\" to #{number}...\"\n Twilio::Sms.message(TWILIO_CONFIG['call... | [
"0.7524722",
"0.732517",
"0.71886545",
"0.7128708",
"0.7090069",
"0.7074432",
"0.70660824",
"0.70651174",
"0.6900381",
"0.68919986",
"0.6805689",
"0.67973167",
"0.67895824",
"0.6782423",
"0.6760083",
"0.67514706",
"0.6744342",
"0.67342937",
"0.6734272",
"0.67031276",
"0.66859... | 0.75437856 | 0 |
call this to do all the logic to parse the incomming text returns the action that the text wants | def sms_parsing(text_body)
words = text_body.split
action = words.slice!(0)
symbol_set = Set.new ["!", "@", "#", "$"] #all symbols to check for
word_set = Set.new ["limit"]
while !words.empty?
nextWord = words[0]
symbol = nextWord[0]
if symbol_set.member? symbol
nextWord.slice!(0)
case symbol #all symbols to check for here
when "!"
@sms_skills = nextWord + " "
words.slice!(0)
while !words.empty? and !symbol_set.member? words[0][0] and !word_set.member? words[0].downcase #checks if nextWord is a symboled word
@sms_skills = @sms_skills + words[0] + " "
words.slice!(0)
end
@sms_skills.chop!
when "@"
@sms_location = nextWord + " "
words.slice!(0)
while !words.empty? and !symbol_set.member? words[0][0] and !word_set.member? words[0].downcase #checks if nextWord is a symboled word
@sms_location = @sms_location + words[0] + " "
words.slice!(0)
end
@sms_location.chop!
when "#"
@sms_summary = nextWord + " "
words.slice!(0)
while !words.empty? and !symbol_set.member? words[0][0] and !word_set.member? words[0].downcase #checks if nextWord is a symboled word or key word
@sms_summary = @sms_summary + words[0] + " "
words.slice!(0)
end
@sms_summary.chop!
when "$"
@sms_wage = nextWord.to_f
words.slice!(0)
end
else
if word_set.member? nextWord.downcase
case nextWord.downcase
when "limit"
words.slice!(0)
nextWord = words[0]
if nextWord == nil or !is_num?(nextWord)
sms_error("LIMIT must be followed by a integer number")
@sms_error = true
break
end
@sms_limit = nextWord.to_i
words.slice!(0)
end
else
words.slice!(0)
end
end
end
if !@sms_location.nil?
@sms_location = @sms_location.downcase.strip
end
if !@sms_skills.nil?
@sms_skills = @sms_skills.downcase.strip
end
return action
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_action_txt(action_txt, index)\n begin\n reset_parse_action_txt\n set_action_txt(action_txt)\n set_action_txt_index(index)\n set_action_txt_player_name\n set_whole_action_txt\n set_stripped_action\n set_amount\n set_action_txt_player\n cr... | [
"0.697833",
"0.6947745",
"0.6892348",
"0.6626048",
"0.6538646",
"0.6400786",
"0.62936264",
"0.62421995",
"0.6163899",
"0.6122116",
"0.60879403",
"0.60529804",
"0.60362196",
"0.60099715",
"0.5996392",
"0.59463716",
"0.58708954",
"0.5858089",
"0.5858089",
"0.5858089",
"0.583585... | 0.58417434 | 20 |
sms support for problem creation | def sms_create
summary = @sms_summary
location = @sms_location
skills = @sms_skills
wage = @sms_wage
@problem = Problem.new(:location => location, :summary => summary, :skills => skills, :wage => wage)
add_problem_to_user_sms
sms_authenticate
if sms_save_problem
sms_send("You have successfully posted your problem(id: #{@problem.id}). We will notify you of any updates as soon as possible. Thank you for using Emplify!")
else
@problem.errors.full_messages.each do |error|
sms_error(error)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sms_accept_problem\n problem_id = @problem_text[1]\n password = @problem_text[2]\n provider = Account.find_by_phone_number(normalize_phone(params[:From]))\n problem = Problem.find_by_id(problem_id)\n if problem.nil?\n sms_error(\"Sorry, there is no problem that matches ID #{problem_id}. Ple... | [
"0.66650575",
"0.5834069",
"0.57461464",
"0.5659182",
"0.5653695",
"0.5648836",
"0.5641613",
"0.56207407",
"0.56165147",
"0.5604864",
"0.5597876",
"0.55977505",
"0.5585042",
"0.55706966",
"0.5570108",
"0.5561837",
"0.5555722",
"0.55392915",
"0.5494721",
"0.5494721",
"0.548976... | 0.7857824 | 0 |
Expecting the input to look like: "accept [problem id] [password]" | def sms_accept_problem
problem_id = @problem_text[1]
password = @problem_text[2]
provider = Account.find_by_phone_number(normalize_phone(params[:From]))
problem = Problem.find_by_id(problem_id)
if problem.nil?
sms_error("Sorry, there is no problem that matches ID #{problem_id}. Please accept problems in the following format: 'Accept [problem ID]'")
elsif problem.archived
sms_error("Sorry, problem ID #{problem_id} has already been accepted by another provider. Please choose another problem.")
# elsif !provider.verified_skills.include? problem.skills
# sms_error("Sorry, you do not have the skills that this problem requires.")
else
provider.problems << problem
if provider.save
problem.archived = true
problem.save
requester = problem.account
sms_send("You have accepted problem ##{problem_id}. Please contact your requester at #{requester.phone_number} as soon as possible.")
#send a notification to the requester saying that a provider will be contacting shortly
requester_msg = "Your #{problem.summary} problem has been accepted. You can contact your provider at #{provider.phone_number}."
sms_send(requester.phone_number, requester_msg)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n 2.times { puts }\n puts <<-EOF\nYou have entered the following information\nApocalypse server : #{@address}\nApocalypse server port : #{@port}\nApocalypse username : #{@username}\nApocalypse password : #{'*' *@password.length}\nThis Server' hostname : #{@hostname}\... | [
"0.642186",
"0.59057915",
"0.58491653",
"0.58430827",
"0.58391374",
"0.5716963",
"0.57013273",
"0.5699616",
"0.5613457",
"0.5598513",
"0.55845636",
"0.55471337",
"0.5510737",
"0.5498221",
"0.54887646",
"0.5419622",
"0.5404908",
"0.5360304",
"0.5357657",
"0.5351557",
"0.535063... | 0.0 | -1 |
Return's true if the skill exists, else it returns false and sends an error SMS to the person who texted in. Use only in sms functions Doesn't do anything if input is nil. Returns true. | def skill_check? skill
if !skill.nil?
curr_skill = Skill.find_by_skill_name(skill)
if curr_skill.nil?
sms_error("Skills: #{skill} is not a current skill we have. Text 'Skills' to get a list of skills we currently have.")
return false
else
return true
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skill_ok?\n check_ok?(:skill) || all_ok?\n end",
"def skill?\n fail NotImplementedError\n end",
"def skill_wtype_ok?(skill)\r\n return true\r\n end",
"def skill_learn?(skill_id)\n return @skills.include?(skill_id)\n end",
"def create\n if !skill_already_exists?(skill_params)\n #... | [
"0.6540748",
"0.65278304",
"0.652087",
"0.59817135",
"0.59368896",
"0.5903813",
"0.58838",
"0.5880899",
"0.5856321",
"0.5759966",
"0.57254595",
"0.56602764",
"0.56366765",
"0.5601597",
"0.5594932",
"0.5572668",
"0.5525742",
"0.55110663",
"0.5504361",
"0.54783106",
"0.5401052"... | 0.728954 | 0 |
belongs_to :showback_event belongs_to :showback_bucket validates :showback_bucket, :presence => true, :allow_nil => false validates :showback_event, :presence => true, :allow_nil => false | def clean_costs
self.cost = nil
save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_validation_on_create\n existingEventParticipant = EventParticipant.find(:first,:conditions=>\"horse_id=#{self.horse.id} and event_id=#{self.event.id}\")\n if !existingEventParticipant.nil?\n raise \"You may not create a new event participant, this horse, #{existingEventParticipant.horse.name}... | [
"0.5585754",
"0.5544094",
"0.55144995",
"0.54895747",
"0.5472289",
"0.5365731",
"0.52832",
"0.5274019",
"0.52270144",
"0.5223512",
"0.52057874",
"0.5194643",
"0.51891303",
"0.5173412",
"0.5173412",
"0.5171043",
"0.5141908",
"0.5123797",
"0.5115794",
"0.5089242",
"0.50845104",... | 0.0 | -1 |
=================================================================== Methods below operate on a single user only | def changed_activity_size?(key)
ua = activity(key)
size_before = ua.size
yield(key, ua)
size_after = activity(key).size
(size_before > size_after)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n return Ecore::User.anybody if @user_id == Ecore::User.anybody.id\n return Ecore::User.everybody if @user_id == Ecore::User.everybody.id\n u = Ecore::User.find_by_id(@user_id)\n u = Ecore::Group.find_by_id(@user_id) unless u\n u\n end",
"def user\n batch_load_one(object... | [
"0.7146153",
"0.7093401",
"0.7023578",
"0.7009504",
"0.7009504",
"0.69656473",
"0.6944301",
"0.69233346",
"0.69117355",
"0.6887864",
"0.6844914",
"0.6843428",
"0.68005615",
"0.67848104",
"0.6769001",
"0.6748009",
"0.6747496",
"0.6745792",
"0.67348593",
"0.67271584",
"0.672449... | 0.0 | -1 |
:all: By default, some changes are not displayed. When displaying details for a single change, set :all=>true to display all changes. :show_all_tags: Show unchanged tags. | def get_default_field_options
@default_field_options ||= {
:suppress_fields => []
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_tags\n tag_list = \"\"\n self.tags.each do |t|\n tag_list << \"#{t.name} \"\n end\n tag_list\n end",
"def all\n @hash_tags\n end",
"def all_tags\n applied_tags + @tags\n end",
"def all_tags\n applied_tags + @tags\n end",
"def show_edits!\n\t\treturn un... | [
"0.6068189",
"0.5835069",
"0.5793695",
"0.5793695",
"0.5748019",
"0.5729484",
"0.5729484",
"0.5729484",
"0.5679866",
"0.56776476",
"0.5649279",
"0.5610532",
"0.55468595",
"0.5502811",
"0.54731995",
"0.5470918",
"0.5423929",
"0.5377756",
"0.53773457",
"0.53773457",
"0.53773457... | 0.0 | -1 |
yield more than two numbers | def yielder(number)
puts "_________"
(1..number).each do |x|
while x<5 do
puts x
x=x+1
end
end
yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiples(number1, number2, range1, range2)\n (range1...range2).select { |value| value % number1 == 0 || value % number2 == 0 }.reduce(:+)\nend",
"def looping_by_multi_2( num )\n\n result = 1\n\n while( result < num )\n result *= 2\n puts( result )\n end\n\nend",
"def random_numbers\n\tputs \"Fo... | [
"0.6627067",
"0.64697886",
"0.646002",
"0.64106214",
"0.64034605",
"0.6347632",
"0.62985533",
"0.6283758",
"0.6234302",
"0.6209411",
"0.6182586",
"0.6175896",
"0.616859",
"0.61605",
"0.61551344",
"0.61245704",
"0.6124051",
"0.6115012",
"0.6086649",
"0.6085838",
"0.60847616",
... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
smallest_val = 0
smallest_key = 0
comp = nil
name_hash.each do |key,val|
comp = val
if smallest_key == 0
smallest_key = key
smallest_val = val
end
if comp < smallest_val
smallest_val = comp
smallest_key = key
end
end
if smallest_key == 0
return nil
else
return smallest_key
end
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.88225716",
"0.87791526",
"0.87779355",
"0.87472314",
"0.8690887",
"0.8656373",
"0.8653365",
"0.8617534",
"0.85888296",
"0.85730934",
"0.8568526",
"0.85522825",
"0.8530813",
"0.8530813",
"0.8519404",
"0.84942126",
"0.84763813",
"0.84763813",
"0.8466587",
"0.845011",
"0.8449... | 0.82392734 | 56 |
GET /backup def backup end POST /generate_backup | def generate_backup
if Export.launch_export!
current_user.update(
last_backup_at: Time.zone.now,
last_backup_entry_id: current_user.last_entry_id
)
redirect_to backup_succeeded_path
else
redirect_to backup_failed_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup_wallet\n client.make_request('/backup-wallet', 'post', params: {})\n end",
"def cmd_backup argv\n setup argv\n command = @hash['command']\n name = @hash['name']\n response = @api.backup(command, name)\n msg response\n return response\n end",
"def system_backup\n\n\n ... | [
"0.7160548",
"0.6996519",
"0.697848",
"0.6977541",
"0.68865484",
"0.67735803",
"0.6687378",
"0.66806626",
"0.66524833",
"0.6544933",
"0.64617133",
"0.64174485",
"0.6412878",
"0.6409217",
"0.6373063",
"0.6280851",
"0.62536395",
"0.6250678",
"0.6230015",
"0.62258905",
"0.620516... | 0.6912226 | 4 |
def arrange input = gets.to_s.strip puts input.chars.sort.join end arrange Write a script that checks whether a passed string is palindrome or not. def palindrome input = gets.to_s.strip.gsub(" ", "") reverse = input.reverse if (input === reverse) puts "It is a palindrome" else puts "It is not a palindrome" end end palindrome def count_vowels() string = gets.to_s.strip vowels = 0 counter = 0 while counter < string.length do if string[counter]=="a" || string[counter]=="e" || string[counter]=="i" || string[counter]=="o" || string[counter]=="u" vowels += 1 end counter += 1 end puts vowels end count_vowels() Write a for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. | def number_check
nums = [0, 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10, 11, 12, 13, 14, 15]
nums.each do |i|
if i % 2 == 0
puts "#{i} even"
else
puts "#{i} odd"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPalindrome(string)\n # if x.to_s.reverse == x\n # return true\n # end\n # return false\n count = {}\n oddCount = 0\n string.each_char.with_index do |value, index|\n if count[string[index]]\n count[string[index]] += 1\n else\n count[string[index]] = 1\n ... | [
"0.7324962",
"0.67785645",
"0.67058784",
"0.669905",
"0.66704535",
"0.6653015",
"0.663643",
"0.65785",
"0.65077055",
"0.6502734",
"0.6484548",
"0.6459028",
"0.64204764",
"0.6403513",
"0.640112",
"0.6396102",
"0.63946944",
"0.63855284",
"0.63783765",
"0.6362989",
"0.63521016",... | 0.0 | -1 |
Confirms an admin user. | def admin_user
redirect_to(root_url) unless current_user.is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end",
"def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless cu... | [
"0.79044944",
"0.767215",
"0.76483077",
"0.76210374",
"0.7605678",
"0.7605678",
"0.75945777",
"0.7588445",
"0.7588445",
"0.7503662",
"0.74675834",
"0.7451482",
"0.7424005",
"0.7411313",
"0.74107665",
"0.7402138",
"0.73993605",
"0.7358812",
"0.7329228",
"0.73179626",
"0.731276... | 0.0 | -1 |
GET /activities GET /activities.json | def index
@activities = Activity.all(limit: ActivitiesController::MAX_SEARCH_RESULTS)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @activities }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activities\n get_call(\"1/activities.json\")\n end",
"def activities(params = {})\n scope 'default'\n get('activities/', params)\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def acti... | [
"0.87228423",
"0.823766",
"0.8175158",
"0.8175158",
"0.8160505",
"0.8032669",
"0.7979835",
"0.7971086",
"0.79515815",
"0.7610422",
"0.7540613",
"0.75270593",
"0.7450179",
"0.7426079",
"0.7413399",
"0.7386743",
"0.73542464",
"0.7342398",
"0.7319785",
"0.7319785",
"0.7276885",
... | 0.69915974 | 42 |
GET /activities/1 GET /activities/1.json | def show
@activity = Activity.find(params[:id])
if current_user
@user = current_user
@user_activity = UserActivity.find_by_user_id_and_activity_id @user.id, @activity.id
Rails.logger.info "#{@user_activity.inspect}"
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @activity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activities\n get_call(\"1/activities.json\")\n end",
"def show\n begin\n @activity = PublicActivity::Activity.all.find(params[:id])\n rescue ActiveRec... | [
"0.83788407",
"0.83788407",
"0.8096585",
"0.7685623",
"0.7667807",
"0.76401794",
"0.7609177",
"0.75712854",
"0.75329125",
"0.74525696",
"0.74308854",
"0.7332175",
"0.73110914",
"0.72872484",
"0.7285642",
"0.7231286",
"0.7206347",
"0.7206347",
"0.7189005",
"0.7184855",
"0.7056... | 0.6816858 | 46 |
GET /activities/new GET /activities/new.json | def new
@activity = Activity.new
images_left = (ActivitiesController::MAX_IMAGES - @activity.activity_images.count)
images_left.times { @activity.activity_images.build }
respond_to do |format|
format.html # new.html.erb
format.json { render json: @activity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @breadcrumb = 'create'\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\n end\n end",
"def new\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | [
"0.8030845",
"0.795746",
"0.795746",
"0.7671767",
"0.7667353",
"0.7381573",
"0.7371675",
"0.73648643",
"0.7263187",
"0.724126",
"0.72343117",
"0.72343117",
"0.72125345",
"0.7207512",
"0.7192852",
"0.7192852",
"0.7192852",
"0.71043736",
"0.70947236",
"0.7093483",
"0.7056507",
... | 0.0 | -1 |
POST /activities POST /activities.json | def create
Rails.logger.info params
@activity = Activity.new(params[:activity])
@activity.user = current_user
if params.has_key?('hidden-activity') and params['hidden-activity'].has_key?('tag_list')
@activity.tag_list = params['hidden-activity'][:tag_list]
end
respond_to do |format|
if @activity.save
format.html { redirect_to @activity, notice: 'Activity was successfully created.' }
format.json { render json: @activity, status: :created, location: @activity }
else
# Delete images post invalidation
@activity.activity_images.map(&:destroy)
@activity.activity_images = []
ActivitiesController::MAX_IMAGES.times { @activity.activity_images.build }
format.html { render action: "new" }
format.json { render json: @activity.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @activity = @user.activities.create(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Exercise event was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n ... | [
"0.7249106",
"0.70048165",
"0.6964346",
"0.6956599",
"0.69475126",
"0.6929332",
"0.69046366",
"0.6889496",
"0.6862793",
"0.68420047",
"0.6838635",
"0.68081975",
"0.68079776",
"0.68079776",
"0.6798919",
"0.677082",
"0.6740217",
"0.67014927",
"0.6675203",
"0.6665923",
"0.665974... | 0.6625307 | 24 |
PUT /activities/1 PUT /activities/1.json | def update
@activity = Activity.find(params[:id])
if params.has_key?('hidden-activity') and params['hidden-activity'].has_key?('tag_list')
params[:activity][:tag_list] = params['hidden-activity'][:tag_list]
end
respond_to do |format|
if @activity.update_attributes(params[:activity])
format.html { redirect_to @activity, notice: 'Activity was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @activity.errors, status: :unprocessable_entity }
end
end
if @activity.created_at < 1.day.ago
authorize! :edit, @activity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n @title = Title.find(activity_params[:title_id])\n @event = Event.find(@title[:event_id])\n @activity = Activity.new(activity_params)\n @title.activities << @activity\n \n respond_to do |format|\n if @activity.update(activity_params)\n format.html { redirect_to \"/events... | [
"0.67760414",
"0.6759261",
"0.67530906",
"0.6727096",
"0.67267734",
"0.6719355",
"0.66723365",
"0.6667481",
"0.6626926",
"0.6595789",
"0.6546449",
"0.65202326",
"0.65202326",
"0.65202326",
"0.6504074",
"0.6504074",
"0.6504074",
"0.6504074",
"0.6504074",
"0.65034425",
"0.64797... | 0.6235562 | 42 |
DELETE /activities/1 DELETE /activities/1.json | def destroy
@activity = Activity.find(params[:id])
@activity.destroy
respond_to do |format|
format.html { redirect_to activities_url }
format.json { head :no_content }
end
if @activity.created_at < 1.day.ago
authorize! :edit, @activity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :n... | [
"0.7712568",
"0.7712568",
"0.7712568",
"0.7712568",
"0.7712568",
"0.76978153",
"0.7688336",
"0.7663404",
"0.7663404",
"0.76458544",
"0.76458544",
"0.7643713",
"0.7564872",
"0.75457203",
"0.745816",
"0.73909366",
"0.73904556",
"0.73731923",
"0.73731923",
"0.73731923",
"0.73731... | 0.7001932 | 57 |
What is the sum of the digits of the number 2^1000? | def get_digits(num)
digits = []
result = num
first_iter_flag = true
while(result != 0)
result = result/10 if(!first_iter_flag)
first_iter_flag = false if(first_iter_flag)
digits.unshift result%10 if(result != 0)
end
digits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sixteen\n sum_of_digits 2**1000\nend",
"def power_digit_sum(base, exponent)\n\t(2 ** 1000).to_s.split(\"\").inject(0) {|sum, n| sum + n.to_i}\nend",
"def digit_summer(pow_pow)\n\tdigit = 2**pow_pow\n\n\tdigit_string = digit.to_s\n\n\tsum = 0\n\n\tdigit_string.each_char do |num|\n\t\tsum = sum + num.to_i\n... | [
"0.7641358",
"0.7380501",
"0.71218634",
"0.7095613",
"0.6878825",
"0.67998147",
"0.6773035",
"0.676628",
"0.67499423",
"0.66921014",
"0.6579649",
"0.6563784",
"0.65574837",
"0.65153456",
"0.65046656",
"0.6448706",
"0.64434296",
"0.6443126",
"0.64426327",
"0.643573",
"0.642876... | 0.0 | -1 |
end of method iattr_accessor | def cattr_reader(*syms)
syms.flatten.each do |sym|
next if sym.is_a?(Hash)
class_eval(<<-EOS, __FILE__, __LINE__)
unless defined? @@#{sym}
@@#{sym} = nil
end
def self.#{sym}
@@#{sym}
end
def #{sym}
@@#{sym}
end
EOS
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_attr_accessor(attr)\n attr_accessor(attr)\n end",
"def attr; end",
"def internal_attr_accessor(*syms)\n internal_attr_reader(*syms)\n internal_attr_writer(*syms)\n end",
"def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end",
"def attr_accessor(sym, ... | [
"0.7890997",
"0.7890375",
"0.75989985",
"0.7497774",
"0.7450574",
"0.74476784",
"0.74476784",
"0.74476784",
"0.7394971",
"0.7394971",
"0.7394971",
"0.7394971",
"0.7394971",
"0.7394971",
"0.7394971",
"0.7378075",
"0.7264349",
"0.7238084",
"0.720851",
"0.72070783",
"0.72030103"... | 0.0 | -1 |
retrieve the categories for the user_info partial | def get_category_count
if(params[:id])
@user = User.find(params[:id].downcase)
@all_projects = @user.projects.order("updated_at DESC")
@arts_and_crafts_count = 0
@clothing_count = 0
@cooking_count = 0
@electronics_count = 0
@mechanical_count = 0
@other_count = 0
arts_and_crafts_category = Category.where(:name => "Arts & Crafts").first
clothing_category = Category.where(:name => "Clothing").first
cooking_category = Category.where(:name => "Cooking").first
electronics_category = Category.where(:name => "Electronics").first
mechanical_category = Category.where(:name => "Mechanical").first
other_category = Category.where(:name => "Other").first
@all_projects.each do |project|
if project.categories.include?(arts_and_crafts_category)
@arts_and_crafts_count += 1
end
if project.categories.include?(clothing_category)
@clothing_count += 1
end
if project.categories.include?(cooking_category)
@cooking_count += 1
end
if project.categories.include?(electronics_category)
@electronics_count += 1
end
if project.categories.include?(mechanical_category)
@mechanical_count += 1
end
if project.categories.include?(other_category)
@other_count += 1
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @categories = current_user.categories\n end",
"def profileinfo(user_id)\n categories = db.execute(\"SELECT category FROM categories\")\n arr = []\n categories.each do |category|\n arr << category[\"category\"]\n end\n return [db.execute(\"SELECT * FROM users WHERE user_id=?\... | [
"0.66995823",
"0.65575814",
"0.6525585",
"0.64731693",
"0.6375938",
"0.6370895",
"0.6326278",
"0.631424",
"0.6285089",
"0.62302125",
"0.6216325",
"0.6150744",
"0.61404485",
"0.6131284",
"0.6090818",
"0.608891",
"0.608531",
"0.6064446",
"0.6061637",
"0.60410655",
"0.602744",
... | 0.0 | -1 |
validate uniqueness of email | def validate_email
email = params[:email]
# valid if username doesn't exist already
valid = !User.pluck(:email).include?(email)
respond_to do |format|
format.json {render :json => valid}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uniqueness_of_email\n if Person.exists?(:email=>self.email,:user_id => self.user_id)\n self.errors.add(:email, :taken)\n return false\n else\n return true\n end\n end",
"def unique_email\n\t\treturn if email.blank?\n\t\tif Email.where(email: email).count > 0\n\t\t\terrors.ad... | [
"0.8493842",
"0.843575",
"0.8248474",
"0.81815803",
"0.8108412",
"0.8002195",
"0.79162",
"0.77153873",
"0.7686052",
"0.7477267",
"0.7352634",
"0.73438746",
"0.7246181",
"0.71821254",
"0.7153108",
"0.71396035",
"0.7112482",
"0.7098818",
"0.70748365",
"0.70688635",
"0.70532346"... | 0.672899 | 30 |
touch: update the user's updated at date if logged in | def touch
if current_user
current_user.touch
end
respond_to do |format|
format.json {render :nothing => true}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def touch_user_data\n user.update user_data_updated_at: Time.zone.now if user.present?\n end",
"def update_user\n current_user.update_last_access if current_user && signed_in?\n end",
"def update_last_user_activity\n if current_user\n current_user.update_attributes(:last_user_activity => Time.n... | [
"0.8018211",
"0.7566768",
"0.72849125",
"0.7202335",
"0.7166964",
"0.70127594",
"0.6911699",
"0.685908",
"0.6846113",
"0.67954934",
"0.67588025",
"0.674576",
"0.67308736",
"0.6713763",
"0.66589177",
"0.65835357",
"0.6581792",
"0.6570115",
"0.6544697",
"0.6503571",
"0.64936256... | 0.6375694 | 33 |
Returns salt value to be used for hashing. | def salt
# 72 bits
SecureRandom.hex(9)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def salt\n read_attribute(:salt) or returning self.class.generate_salt do |s|\n write_attribute(:salt, s)\n end\n end",
"def salt\n p_salt(profile.salt_bytes)\n end",
"def get_salt\n @salt ||= BCrypt::Engine.generate_salt\n end",
"def salt\n if salt_path.file?... | [
"0.8397726",
"0.8228236",
"0.8178956",
"0.79635614",
"0.7926941",
"0.7792873",
"0.7729237",
"0.7709584",
"0.7595341",
"0.7543805",
"0.7541343",
"0.74773",
"0.74534196",
"0.73896766",
"0.7378751",
"0.73278445",
"0.7295854",
"0.72740465",
"0.72273326",
"0.72187436",
"0.7211811"... | 0.78466207 | 5 |
Returns if the given password match the encoded password. | def verify(_password, _encoded)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_encoded?(password)\n reg_ex_test = \"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$\"\n\n if password =~ /#{reg_ex_test}/ then\n return true\n else\n return false\n end\n end",
"def password_match? password\n\t\tBCryp... | [
"0.8292634",
"0.8250844",
"0.8242472",
"0.8111532",
"0.79036313",
"0.7891534",
"0.7811354",
"0.7770088",
"0.77575773",
"0.77467626",
"0.7722079",
"0.7722079",
"0.7704711",
"0.7691086",
"0.76547784",
"0.764005",
"0.76346636",
"0.76341325",
"0.76341325",
"0.7630522",
"0.7627207... | 0.0 | -1 |
Returns given password encoded with the given salt. | def encode(_password, _salt)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encry... | [
"0.7344556",
"0.7344556",
"0.7344556",
"0.7344556",
"0.7344556",
"0.7344556",
"0.7296721",
"0.7277346",
"0.71848965",
"0.70527714",
"0.70500624",
"0.70409435",
"0.7022958",
"0.7022958",
"0.6999717",
"0.6926968",
"0.6910913",
"0.68941855",
"0.6891788",
"0.6835064",
"0.67956614... | 0.7387263 | 0 |
Returns if given encoded password needs to be updated. | def must_update(_encoded)
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_update?(new_pass)\n return false if current_resource.info['rep:password'].end_with?(\n hash_generator(new_pass)\n )\n true\n end",
"def has_password?( submitted_password )\n encrypted_password == encrypt( submitted_password )\n end",
"def has_password?(submit... | [
"0.79622346",
"0.7473102",
"0.74606514",
"0.74606514",
"0.7444055",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433514",
"0.7433023",
"0.74207824",
"0.7402928",... | 0.0 | -1 |
GET /contents/1 GET /contents/1.json | def show
add_breadcrumb @content, corkboard_content_path(@corkboard, @content)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @contents = Content.all\n render json: @contents\n end",
"def index\n @contents = Content.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contents }\n end\n end",
"def index\n\n @contents = Content.all\n\n respond_to do |f... | [
"0.7337962",
"0.72771823",
"0.72729874",
"0.7242928",
"0.69509673",
"0.6893205",
"0.67762524",
"0.67762524",
"0.67579806",
"0.6703063",
"0.6670591",
"0.6638352",
"0.6602084",
"0.65537834",
"0.6455138",
"0.6454024",
"0.6454024",
"0.6454024",
"0.6454024",
"0.6454024",
"0.645402... | 0.0 | -1 |
GET /contents/new GET /contents/new.json | def new
@content = @corkboard.contents.new
@content.build_document
respond_to do |format|
format.html # new.html.erb
format.json { render json: @content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @title = t 'view.contents.new_title'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | [
"0.70694655",
"0.706462",
"0.706462",
"0.706462",
"0.706462",
"0.706462",
"0.706462",
"0.7025736",
"0.6755228",
"0.6738443",
"0.6649702",
"0.6638704",
"0.65894943",
"0.65253186",
"0.6483694",
"0.6483694",
"0.6483694",
"0.6483694",
"0.6483694",
"0.6483694",
"0.6483694",
"0.6... | 0.6686396 | 10 |
POST /contents POST /contents.json | def create
@content = @corkboard.contents.new(params[:content])
respond_to do |format|
if @content.save
current_user.create_activity @content, 'created'
format.html { redirect_to corkboard_contents_path(@corkboard), notice: 'Content was successfully created.' }
format.json { render json: @content, status: :created, location: @content }
else
format.html { render action: "new" }
format.json { render json: @content.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @contents = Content.all\n render json: @contents\n end",
"def create(contents, params = {:language => \"Plain Text\", :private => false})\n params = params.merge({:contents => contents}.merge(@base_params))\n self.class.post(\"/paste\", :body => params).parsed_response\n end",
"... | [
"0.6282009",
"0.62486786",
"0.620182",
"0.60974866",
"0.60562325",
"0.6044423",
"0.6020207",
"0.5959216",
"0.59045476",
"0.5900914",
"0.58946466",
"0.58662325",
"0.5840403",
"0.5793481",
"0.5786892",
"0.5785959",
"0.57757515",
"0.5748183",
"0.5742464",
"0.57402545",
"0.570712... | 0.5762252 | 17 |
PUT /contents/1 PUT /contents/1.json | def update
add_breadcrumb @content, corkboard_content_path(@corkboard, @content)
@content = @corkboard.contents.find(params[:id])
@document = @content.document
@content.transaction do
@content.update_attributes(params[:content])
@document.update_attributes(params[:content][:document]) if @document
unless @content.valid? || (@content.valid? && @document && !@document.valid?)
raise ActiveRecord::Rollback
end
end
respond_to do |format|
format.html { redirect_to corkboard_contents_path(@corkboard), notice: 'Content was successfully updated.' }
format.json { head :no_content }
end
rescue ActiveRecord::Rollback
respond_to do |format|
format.html do
flash.now[:error] = "Update failed."
render action: "edit"
end
format.json { render json: @content.errors, status: :unprocessable_entity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @contents = args[:contents] if args.key?(:contents)\n end",
"def update!(**args)\n @contents = args[:contents] if args.key?(:contents)\n end",
"def update!(**args)\n @contents = args[:contents] if args.key?(:contents)\n @path = args[:path]... | [
"0.65915227",
"0.65915227",
"0.6413576",
"0.6361351",
"0.6278191",
"0.6209755",
"0.61951864",
"0.60822284",
"0.60800284",
"0.6031631",
"0.60218817",
"0.59756523",
"0.59215033",
"0.59085596",
"0.5867997",
"0.5830863",
"0.57885987",
"0.57885987",
"0.57885987",
"0.57880205",
"0.... | 0.0 | -1 |
TODO add game rule in game info | def generate_game_info(room)
players = room.players.inject(""){ |acc, p| acc << " id : #{p.id}, name : #{p.name}\n" }
"======================================\n"+
"[Game Information]\n"+
"Room name : #{room.name}\n"+
"Round : #{room.max_round} round\n"+
"player : #{room.player_num} player\n"+
"#{players}"+
"======================================\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply(game)\n end",
"def game_mode; end",
"def gameflow\n \n end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def games\n 'Games/Toys' if %w[r m].include?(record.leader[6]) &&\n (%w[g w... | [
"0.69384867",
"0.68055534",
"0.669947",
"0.6691355",
"0.6691355",
"0.6691355",
"0.6691355",
"0.6691355",
"0.66896605",
"0.66896605",
"0.6588429",
"0.6346782",
"0.62634933",
"0.61646825",
"0.6110487",
"0.61006546",
"0.6049994",
"0.6047262",
"0.60256773",
"0.6024613",
"0.602279... | 0.5650816 | 57 |
Compare the given other quantile. | def <=>(other)
self.quantile <=> other.quantile && self.inaccuracy <=> other.inaccuracy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare(x,y)\n a = CachedProduct.find_by_product_id(x['product_id'].to_s)\n b = CachedProduct.find_by_product_id(y['product_id'].to_s)\n return a.max_small <=> b.max_small\n end",
"def <=>(other_bid)\n self.estimate <=> other_bid.estimate\n end",
"def >= other\n ... | [
"0.672714",
"0.653636",
"0.6266369",
"0.62450737",
"0.6161021",
"0.6111681",
"0.6029919",
"0.6018348",
"0.5986716",
"0.59852314",
"0.59165037",
"0.5907251",
"0.5905221",
"0.5869129",
"0.5858638",
"0.58572346",
"0.58527356",
"0.58451885",
"0.5836544",
"0.58184415",
"0.58070314... | 0.7366779 | 0 |
def update user = User.find_by(id: params[:id]) if (params[:status]) user.update(status: true) else user.update(status: false) end end | def create
puts user_params
user = User.new(user_params)
if user.save
render json: { user: user, status: :success }
else
render json: { status: :failure, errors: user.errors.full_messages.join('') }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_status\n @user = User.find params[:id]\n @user.update(user_status: params[:status])\n end",
"def update\n @user = current_user\n @user.status = params[:user][:status]\n @user.save\n redirect_to :root\n end",
"def update_status\n @user = User.find(params[:id])\n if para... | [
"0.8929619",
"0.8308182",
"0.8257215",
"0.8062934",
"0.8051349",
"0.8029836",
"0.80071944",
"0.77803713",
"0.7777881",
"0.76620126",
"0.76508826",
"0.7615377",
"0.7595614",
"0.75456935",
"0.74501306",
"0.74280185",
"0.74228966",
"0.72843003",
"0.72725",
"0.7267696",
"0.726504... | 0.0 | -1 |
Get our sort_order. Use value from params if !nil, otherwise attempt to use session data. | def _get_sort_order
if !params[:sort_order].nil?
return params[:sort_order]
end
if !session[:sort_order].nil?
@redirect_required = true
order = session[:sort_order]
session.delete(:sort_order)
order
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sort_order\n if flash[:sort_order]\n return flash[:sort_order]\n else\n return Hash.new()\n end\n end",
"def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend",
"def sort_for_fields(sortable)\n key = [:controll... | [
"0.7083558",
"0.7067402",
"0.6892127",
"0.6848392",
"0.67269206",
"0.650365",
"0.6478131",
"0.64460665",
"0.6431029",
"0.63801336",
"0.63588035",
"0.63559407",
"0.6354081",
"0.63501525",
"0.63417166",
"0.63299966",
"0.63299966",
"0.63255507",
"0.6297142",
"0.62957454",
"0.627... | 0.84520775 | 0 |
Get our selected_ratings. Use value from params if !nil, otherwise attempt to use session data. | def _get_selected_ratings
if !params[:ratings].nil?
return params[:ratings]
end
if !session[:ratings].nil?
@redirect_required = true
ratings = session[:ratings]
session.delete(:ratings)
ratings
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checked_ratings\n if params[:ratings]\n params[:ratings].keys\n else\n @all_ratings\n end\n end",
"def chosen_rating?(rating)\n chosen_ratings = session[:ratings]\n return true if chosen_ratings.nil?\n chosen_ratings.include? rating\nend",
"def saved_ratings\n if params[:rat... | [
"0.6881069",
"0.67163396",
"0.6652119",
"0.62522113",
"0.61347204",
"0.5864441",
"0.57380277",
"0.567731",
"0.56674206",
"0.5629044",
"0.55183303",
"0.55139434",
"0.55000854",
"0.55000854",
"0.55000854",
"0.5490598",
"0.5490598",
"0.5490598",
"0.5490598",
"0.5490598",
"0.5490... | 0.9041133 | 0 |
this finds both the precincts that explicitly use this ballot drop location and the precincts that use it implicitly, because they are in the same locality and do not specify a ballot drop location | def precincts
precs = precincts_builtin + Precinct.find(:all,
:joins => "LEFT JOIN ballot_drop_locations_precincts jointable
ON jointable.precinct_id = precincts.id",
:conditions => ["jointable.ballot_drop_location_id IS NULL AND
precincts.locality_id = ?", self.locality_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onsite_holdings\n holdings.select do |holding|\n !is_offsite_location_code?(holding[:location_code])\n # !LOCATIONS['offsite_locations'].include? holding[:location_code]\n end\n end",
"def pickup_locations\n # Borrow Direct requests need to provide a library-specific BD code, provided h... | [
"0.538128",
"0.5286698",
"0.52640563",
"0.51731384",
"0.51404375",
"0.50940275",
"0.50786614",
"0.4945028",
"0.49234504",
"0.49208042",
"0.49035388",
"0.48954877",
"0.48739508",
"0.48683634",
"0.4864085",
"0.48428077",
"0.4831716",
"0.48199928",
"0.48179698",
"0.4808689",
"0.... | 0.57110375 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.