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 |
|---|---|---|---|---|---|---|
See "initialise_sections" for details; call here, passing a task related to the currently processed row, to find out if this task (and therefore its associated row) are the first row in a new section. Returns 'true' if so, else 'false'. | def sections_new_section?( task )
this_project = task.project
this_customer = this_project.nil? ? nil : this_project.customer
changed = ( this_customer != @sections_last_customer or this_project != @sections_last_project )
if ( changed )
@sections_last_customer = this_customer
@sections_last_project = this_project
@sections_last_group = sections_group_title( task )
@sections_current_index += 1
end
return changed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def starts_new_section?( task_id_str )\n @task_starts_section[ task_id_str ]\n end",
"def section?\n !@section.nil?\n end",
"def at_start_rows?\n row = pos[0]\n \n return true if row == 1 || row == 6\n \n false\n end",
"def sections?\n false\n ... | [
"0.68702525",
"0.6167725",
"0.59841764",
"0.59632385",
"0.58014077",
"0.57709706",
"0.5681437",
"0.56643325",
"0.56627214",
"0.5533184",
"0.54988",
"0.5490353",
"0.54653484",
"0.54618514",
"0.5417466",
"0.53905535",
"0.53877306",
"0.53802985",
"0.5362944",
"0.53313184",
"0.53... | 0.68212306 | 1 |
If "new_section?" returns 'true', call here to return a title appropriate for this section (it'll be based on customer and project name set up by the prior call to "new_section?"). Assumes an HTML view for the caller and may return HTML data (HTML safe, unescaped where necessary, might have links to things); however if you pass 'true' in the optional input parameter then plain text is returned with no escaping (e.g. for CSV). | def sections_section_title( plain_text = false )
if ( @sections_last_project.nil? )
return 'No customer, no project'
elsif ( @sections_last_customer.nil? )
if ( plain_text )
return "(No customer) #{ @sections_last_project.title }"
else
return "(No customer) #{ sections_augmented_link( @sections_last_project ) }".html_safe()
end
else
if ( plain_text )
return "Customer #{ @sections_last_customer.title } - #{ @sections_last_project.title }"
else
return "Customer #{ sections_augmented_link( @sections_last_customer ) } - #{ sections_augmented_link( @sections_last_project ) }".html_safe()
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_section(title, options={})\n send_audit(:kind => :new_section, :text => title, :category => options[:category])\n end",
"def section_title(title)\n end",
"def create_new_section(title, options={})\n send_request('create_new_section', normalize_options(title, options))\n end",
... | [
"0.646043",
"0.64094615",
"0.6312189",
"0.6054184",
"0.60364264",
"0.59447104",
"0.5889859",
"0.57758707",
"0.5762663",
"0.57324404",
"0.56079984",
"0.5514661",
"0.55098003",
"0.5490151",
"0.54756635",
"0.5455546",
"0.54508585",
"0.5436285",
"0.5414485",
"0.54077494",
"0.5356... | 0.67517537 | 0 |
Return the section index of the current section. Call any time after at least on prior call to "new_section?" (regardless of the return value of that prior call). | def sections_section_index
return @sections_current_index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def section_index(name)\n 0.upto(length - 1) do |index|\n return index if section_name(index) == name\n end\n nil\n end",
"def current_section\n if section = @temporary_section then\n @temporary_section = nil\n else\n section = @current_section\n en... | [
"0.7244815",
"0.68555784",
"0.6632444",
"0.6259132",
"0.6259132",
"0.62512463",
"0.6123809",
"0.60657644",
"0.60333854",
"0.585335",
"0.5851305",
"0.5841182",
"0.5815071",
"0.5802083",
"0.57846993",
"0.57488555",
"0.5737308",
"0.57248807",
"0.5723448",
"0.5710396",
"0.5648727... | 0.80677426 | 0 |
Similar to "new_section?", except returns 'true' when the task title indicates a group. A task title includes a group name if the title has at least one ":" (colon) character in it. Any part of the title before the first colon is considered a group name. View code usually makes only a subtle disctinction for changes in group, e.g. an extra vertical spacer, but if you want to explicitly show new group names then you can do so by calling "group_title" to recover the name string. Unlike sections, groups are not given unique indices. | def sections_new_group?( task )
this_group = sections_group_title( task )
changed = ( this_group != @sections_last_group )
@sections_last_group = this_group if changed
return changed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sections_group_title( task )\n this_group = nil\n task_title = task.title || ''\n colon = task_title.index( ':' )\n this_group = task_title[ 0..( colon - 1 ) ] unless ( colon.nil? )\n\n return this_group\n end",
"def title\n this_group = nil\n task_title = @task.title || ''\n ... | [
"0.7801417",
"0.69032484",
"0.60971296",
"0.5953221",
"0.58316773",
"0.5734134",
"0.56865084",
"0.5683403",
"0.5661128",
"0.56576604",
"0.56525874",
"0.56458205",
"0.5643623",
"0.5638177",
"0.5624564",
"0.55775416",
"0.556051",
"0.5558333",
"0.5529849",
"0.5492156",
"0.546203... | 0.712222 | 1 |
Return the group name inferred from the given task title, or 'nil' for no apparent group name in the task title. See "new_group?" for details. The method is called "group_title" rather than "group_name" for symmetry with "section_title" it's more natural when writing caller code to remember (or guess at!) a name of "group_title". | def sections_group_title( task )
this_group = nil
task_title = task.title || ''
colon = task_title.index( ':' )
this_group = task_title[ 0..( colon - 1 ) ] unless ( colon.nil? )
return this_group
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n this_group = nil\n task_title = @task.title || ''\n colon = task_title.index( ':' )\n this_group = task_title[ 0..( colon - 1 ) ] unless ( colon.nil? )\n\n return this_group\n end",
"def group_name\n @group_name ||= self.class.group_name(group)\n end",
"def grou... | [
"0.8244201",
"0.6865138",
"0.68379945",
"0.65096575",
"0.6388028",
"0.6290484",
"0.6202153",
"0.61641246",
"0.6063169",
"0.60552245",
"0.6003315",
"0.5920917",
"0.5894588",
"0.5894588",
"0.5882277",
"0.5839409",
"0.5839409",
"0.5834146",
"0.58304536",
"0.5808793",
"0.57999444... | 0.82821906 | 0 |
The idea of this function is reduce the search space of possible anagrams The function will take wordlist of 99175 words, then reduce it to 1659 words How it works: This method will take a file path for raw list of words and known_anagram Then it will create a map of the characters of the known_anagram Using this map we can check every word in the file if it contains the required characters Condition for valid words are: It should not have a character not exists in the known_anagram characters It should not have a character repeated more times than in the known_anagram characters | def get_possible_words(file_path, known_anagram)
possible_words = {}
possible_chars = {}
known_anagram.each_char do |c|
possible_chars[c] = possible_chars.key?(c) ? possible_chars[c] + 1 : 1;
end
IO.foreach(file_path).each do |word|
word.chomp!
chars = {}
word.each_char do |c|
chars[c] = chars.key?(c) ? chars[c] + 1 : 1;
end
is_possible_word = true
chars.keys.each do |c|
if !possible_chars.key?(c) || chars[c] > possible_chars[c]
is_possible_word = false
break
end
end
possible_words[word] = 1 if is_possible_word
end
possible_words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anagrams(word)\n\n dictionary = File.open(\"enable.txt\").read.split(\"\\n\")\n\n dictionary_array = word.chars.to_a\n matches = dictionary_array.permutation(word.length).to_a\n\n my_anagrams = []\n matches.each do |i|\n matches = i.join\n if dictionary.include?(matches)\n \tmy_anagrams.push(matc... | [
"0.73001885",
"0.7170167",
"0.70995045",
"0.69122225",
"0.6868791",
"0.6788363",
"0.6759987",
"0.67509335",
"0.6714638",
"0.671404",
"0.6696378",
"0.6690978",
"0.6670484",
"0.6610122",
"0.66045815",
"0.6604227",
"0.66030014",
"0.6546928",
"0.6535519",
"0.65306604",
"0.6530660... | 0.8091709 | 0 |
The idea is of this function is we can create a hash table of the known anagram. Then using this hash table we can create a hash for every phrase and compare them. The hash table is generated with every character mapped to prime number starting from 3. | def get_hash_table(str)
table = {}
current = 3
str.split("").sort.uniq.each do |c|
table[c] = current
current += 3
end
table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_anagram(s,t)\n\n if s.length != t.length\n return false\n end\n\n #create hashes\n hash_table1 = Hash.new(0)\n hash_table2 = Hash.new(0)\n\n #check frequency of letters in string\n\n s.each_char do |ch|\n if hash_table1[ch] == nil?\n hash_table1[ch] = hash_table1[ch] + 1\n else\n ... | [
"0.7897444",
"0.7492911",
"0.7437408",
"0.7323987",
"0.7248536",
"0.72095084",
"0.72015965",
"0.7199012",
"0.7198733",
"0.7185057",
"0.71672744",
"0.7135496",
"0.71215636",
"0.7106442",
"0.7085392",
"0.7083627",
"0.7082058",
"0.7070074",
"0.7068771",
"0.7066355",
"0.706224",
... | 0.0 | -1 |
This function will hash a string to a number using the hash_table generated by get_hash_table | def get_hash(str, hash_table)
value = 1
str.each_char do |c|
return 0 unless hash_table.key?(c)
value *= hash_table[c]
end
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_code(str)\n str.each_char.reduce(0) do |result, char|\n [((result << 5) - result) + char.ord].pack('L').unpack('l').first\n end\n end",
"def hard(string)\n hasher = KnotHash.new(256, string.bytes + [17, 31, 73, 47, 23])\n 64.times { hasher.round }\n hasher.hash\nend",
"def... | [
"0.75561196",
"0.7225067",
"0.72035366",
"0.70970434",
"0.70423496",
"0.70423496",
"0.70004827",
"0.6955915",
"0.6814059",
"0.6660981",
"0.6652147",
"0.6612327",
"0.6553476",
"0.65524596",
"0.6549005",
"0.65463936",
"0.65177613",
"0.6511462",
"0.6471643",
"0.6454531",
"0.6415... | 0.7344252 | 1 |
This function is where search for a hash happens. It has O(n^3) complexity. N = number of reduced list of words. Using get_possible_words we reduce N from 99175 to 1659 but it is still large ! so we use parallel distribute the computation across all cores. Roughly it will do 4.5 billion iteration, which is on DigitalOcean 24 core instance will take ~5min. To make each iteration faster we apply the following conditions in this order Skip the phrase if its length != the length of known_anagram Skip the phrase if it is not an anagram. We check this by comparing the hash Skip the phrase if its md5 does not the one we are looking for Note: This function has flow. We assume that the search space should be a phrase with three words & two spaces. However the third hash 665e5bcb0c20062fe8abaaf4628bb154 maps to "wu lisp not statutory" so it will not be able to find this hash. | def find_hash(possible_words, known_anagram, known_md5s, start, n = 3)
cpus = Parallel.processor_count
puts "Total number of iteration: #{possible_words.length**n}"
puts "You got #{cpus} cores"
hash_table = get_hash_table(known_anagram)
known_hash = get_hash(known_anagram, hash_table)
Parallel.map(possible_words, in_processes: cpus) do |w1|
possible_words.each do |w2|
possible_words.each do |w3|
# Print every ten million iteration
phrase = "#{w1} #{w2} #{w3}"
# Allow only equal size phrases
next unless phrase.length == known_anagram.length
# Allow only equal hash phrases
hash = get_hash(phrase, hash_table)
next unless hash == known_hash
# All only equal md5 phrases
md5 = Digest::MD5.hexdigest phrase
next unless known_md5s.include?(md5)
puts "#{phrase} #{md5} (#{Time.now - start}s)"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Too... | [
"0.6774362",
"0.6413032",
"0.6154646",
"0.6092108",
"0.60672605",
"0.6009354",
"0.5999103",
"0.5995286",
"0.5988853",
"0.5976706",
"0.5972919",
"0.5953729",
"0.5952609",
"0.5935893",
"0.5918484",
"0.58686906",
"0.5833233",
"0.5808016",
"0.5802413",
"0.5769563",
"0.5768231",
... | 0.7859335 | 0 |
Returns the current log level if set, otherwise it logs everything it receives | def level
@level || :trace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_level\n @log_level ||= DEFAULT_LOG_LEVEL\n end",
"def log_level\n @log_level ||= DEFAULT_LOG_LEVEL\n end",
"def level\n @log.level\n end",
"def log_level; end",
"def log_level; end",
"def log_level\n @log_level ||= begin\n log_level = @config.log_level || @conf... | [
"0.8177418",
"0.8177418",
"0.7759712",
"0.766368",
"0.766368",
"0.75857615",
"0.7584837",
"0.7584837",
"0.7570446",
"0.74697804",
"0.7467554",
"0.74524486",
"0.7417584",
"0.7408159",
"0.74033684",
"0.7403254",
"0.73990947",
"0.73453546",
"0.73453546",
"0.73453546",
"0.7327339... | 0.65067834 | 56 |
A subscriber should implement flush if it can. | def flush
# NOOP
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush\n raise NotImplementedError\n end",
"def flush!\n # a publisher might be uninitialized until the first event is published\n return unless topic.async_publisher\n\n topic.async_publisher.stop.wait!\n end",
"def flush_when_ready\n # make super()-safe so we can make ... | [
"0.6672988",
"0.66150695",
"0.65879506",
"0.64452696",
"0.6426121",
"0.63339007",
"0.61994755",
"0.61408246",
"0.611853",
"0.6105828",
"0.6079474",
"0.60794425",
"0.60794425",
"0.60794425",
"0.60663885",
"0.6008345",
"0.6008345",
"0.6008345",
"0.6008345",
"0.6008345",
"0.5973... | 0.63832706 | 6 |
TODO: Implement this mehtod in all appenders TODO: Output relevant message when appender isn't valid TODO: Check this valid? method before using appender, output above error message if not valid? TODO: Wait with adding appenders until they are needed solve this by below TODO: Implement possibility of finding and deleting appenders by env | def valid?
fail NotImplementedError, "needs to be implemented in appender"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def console_appender?(logger)\n logger.appenders.each do |a|\n if a.kind_of? Logging::Appenders::Stdout then\n return true\n end\n end\n\n if logger.respond_to?(:parent) && logger.parent then\n return console_appender?(logger.parent)\n end\n\n ... | [
"0.59352374",
"0.5647004",
"0.55781794",
"0.5471682",
"0.5458776",
"0.5368815",
"0.5341968",
"0.5328524",
"0.52913505",
"0.52523893",
"0.5179534",
"0.51550174",
"0.5132289",
"0.507511",
"0.5045598",
"0.49887875",
"0.49887875",
"0.4956599",
"0.4915981",
"0.48752552",
"0.483311... | 0.53195053 | 8 |
TODO: Implement a format string with class name and interesting values see: | def to_s
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_class(*) end",
"def print_class\n\n puts \"* #{name.capitalize} *\".colorize(:light_green).bold.indent(10)\n puts\n puts short_description.to_s.colorize(:green).indent(10)\n puts\n stats.each_pair do |name, value|\n print \"| \".colorize(:green).indent(10)\n print \" #{name.cap... | [
"0.6545343",
"0.652678",
"0.6427754",
"0.6312625",
"0.6312625",
"0.6312625",
"0.6312625",
"0.6312625",
"0.6312625",
"0.6312625",
"0.6312625",
"0.62722516",
"0.61876607",
"0.6177767",
"0.6155547",
"0.6152369",
"0.6113445",
"0.6079478",
"0.6071951",
"0.6020866",
"0.60028505",
... | 0.0 | -1 |
A subscriber should implement close if it can. | def close
# NOOP
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close; @receiver_impl.close; end",
"def close; @receiver_impl.close; end",
"def closed?; @receiver_impl.isClosed; end",
"def closed?; @receiver_impl.isClosed; end",
"def close\n @mutex.synchronize do\n @closed = true\n @listeners.each(&:close) # make .pop return nil\n end\n end",
"de... | [
"0.71264005",
"0.71264005",
"0.6944521",
"0.6944521",
"0.6837857",
"0.65809697",
"0.6530517",
"0.653047",
"0.651379",
"0.6502181",
"0.6493321",
"0.64623606",
"0.6444587",
"0.6419104",
"0.63928217",
"0.6385194",
"0.63660514",
"0.63645226",
"0.63498676",
"0.6345525",
"0.6333830... | 0.6163907 | 43 |
Returns [Sapience::Formatters::Default] formatter default for this subscriber | def default_formatter
Sapience::Formatters::Default.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatter\n @formatter ||= Formatters::Default.new\n end",
"def default_formatter\n SemanticLogger::Formatters::Default.new\n end",
"def default_formatter\n SemanticLogger::Formatters::Raw.new\n end",
"def default_formatter\n if protocol == :syslog\n # Format i... | [
"0.7983676",
"0.7982167",
"0.7605805",
"0.7594618",
"0.7392292",
"0.7392292",
"0.7392292",
"0.7113006",
"0.70974624",
"0.699034",
"0.6986514",
"0.6953043",
"0.6903268",
"0.66591114",
"0.6657544",
"0.66319454",
"0.6629351",
"0.6565293",
"0.64973575",
"0.64598966",
"0.6450989",... | 0.86064756 | 0 |
Allow app_name to be set globally or per subscriber | def app_name
@app_name || Sapience.app_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_name=(value)\n @app_name = value\n end",
"def app_name=(value)\n @app_name = value\n end",
"def change_app_name!\n end",
"def appname=(appname)\n validate_options(appname: appname)\n @appname = appname\n end",
"def set_name\n @a... | [
"0.7921008",
"0.7921008",
"0.75908554",
"0.7476147",
"0.7426026",
"0.7383582",
"0.7364789",
"0.7364789",
"0.73395604",
"0.7322136",
"0.7304904",
"0.7240154",
"0.7232703",
"0.7091693",
"0.7028789",
"0.70195526",
"0.6993056",
"0.6914341",
"0.68743306",
"0.68743306",
"0.68659586... | 0.7433512 | 4 |
Allow host name to be set globally or per subscriber | def host
@host || Sapience.config.host
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host=(_); end",
"def hostname(h)\n @config[:host] = h\n end",
"def configure_host_name(config, host_name)\n if host_name\n config.hostsupdater.remove_on_suspend = true\n config.vm.host_name = host_name\n config.hostsupdater.aliases = [\"secure.#{host_name}\"]\n end\n end",... | [
"0.73381424",
"0.718695",
"0.71823907",
"0.7073536",
"0.70496786",
"0.70375544",
"0.7033795",
"0.6958551",
"0.69100636",
"0.6876487",
"0.6875245",
"0.6875245",
"0.6863053",
"0.6861352",
"0.68480676",
"0.68345076",
"0.68345076",
"0.6818897",
"0.68186295",
"0.68186295",
"0.6818... | 0.63414454 | 80 |
Initializer for Abstract Class Sapience::Subscriber Parameters level: [:trace | :debug | :info | :warn | :error | :fatal] Override the log level for this subscriber. Default: :error formatter: [Object|Proc] An instance of a class that implements call, or a Proc to be used to format the output from this subscriber Default: Use the builtin formatter (See: call) filter: [Regexp|Proc] RegExp: Only include log messages where the class name matches the supplied. regular expression. All other messages will be ignored. Proc: Only include log messages where the supplied Proc returns true The Proc must return true or false. host: [String] Name of this host to appear in log messages. Default: Sapience.config.host app_name: [String] Name of this app_name to appear in log messages. Default: Sapience.app_name | def initialize(options = {}, &block)
# Backward compatibility
options = { level: options } unless options.is_a?(Hash)
options = options.dup
level = options.delete(:level)
filter = options.delete(:filter)
@formatter = extract_formatter(options.delete(:formatter), &block)
@app_name = options.delete(:app_name)
@host = options.delete(:host)
fail(ArgumentError, "Unknown options: #{options.inspect}") unless options.empty?
# Subscribers don't take a class name, so use this class name if an subscriber
# is logged to directly
super(self.class, level, filter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(level: nil, formatter: nil, filter: nil, application: nil, environment: nil, host: nil, metrics: false, &block)\n self.formatter = block || formatter\n @application = application\n @environment = environment\n @host = host\n @metrics = metrics\n\n # S... | [
"0.74149096",
"0.6596118",
"0.6428333",
"0.64199764",
"0.63736975",
"0.62817985",
"0.6184753",
"0.6139564",
"0.6129037",
"0.6073888",
"0.6056656",
"0.6004805",
"0.60027045",
"0.5977054",
"0.59615564",
"0.59443295",
"0.59334457",
"0.59216243",
"0.59156674",
"0.5911164",
"0.580... | 0.7500825 | 0 |
Return the level index for fast comparisons Returns the lowest level index if the level has not been explicitly set for this instance | def level_index
@level_index || 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level\n init unless @initialized\n level = level_to_sym(@level)\n end",
"def level\n parent_id.nil? ? 0 : compute_level\n end",
"def level\n return @level\n end",
"def level\n return @level\n end",
"def level\n @l... | [
"0.7064486",
"0.696878",
"0.69673276",
"0.69673276",
"0.6918607",
"0.6918607",
"0.6910088",
"0.6836507",
"0.6775542",
"0.6757528",
"0.6664843",
"0.6664321",
"0.66425747",
"0.6640475",
"0.6632845",
"0.6614444",
"0.66047686",
"0.65632993",
"0.6506189",
"0.6472225",
"0.64619386"... | 0.827122 | 1 |
Initializes the provisioner with the machine that it will be provisioning along with the provisioner configuration (if there is any). The provisioner should _not_ do anything at this point except initialize internal state. | def initialize(machine, config)
@machine = machine
@config = config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def begin_provisioning\n @provisioner = Souffle::Provisioner::System.new(@system, @provider)\n end",
"def _initialize(name, machine)\n initialize_capabilities!(\n name.to_sym,\n { name.to_sym => [Class.new, nil] },\n Vagrant.plugin(\"2\").manager.provider_capabilitie... | [
"0.78066605",
"0.7001654",
"0.679365",
"0.62299407",
"0.6164894",
"0.61231273",
"0.60337526",
"0.6009418",
"0.5968908",
"0.59613913",
"0.59565735",
"0.59512",
"0.5885755",
"0.58834565",
"0.58322895",
"0.5811745",
"0.5747568",
"0.5733088",
"0.57207227",
"0.5702692",
"0.5683067... | 0.58499134 | 15 |
Called with the root configuration of the machine so the provisioner can add some configuration on top of the machine. During this step, and this step only, the provisioner should modify the root machine configuration to add any additional features it may need. Examples include sharing folders, networking, and so on. This step is guaranteed to be called before any of those steps are done so the provisioner may do that. No return value is expected. | def configure(root_config)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(machine, config_name, logger = @log, extra_files = [], chef_version = '16.1.16')\n logger.info(\"Configuring machine #{machine['network']} with #{config_name}\")\n remote_dir = '/tmp/provision'\n within_ssh_session(machine) do |connection|\n install_chef_on_server(connection, chef_versi... | [
"0.62101907",
"0.6181702",
"0.61678314",
"0.6073279",
"0.5866303",
"0.57910097",
"0.57862806",
"0.5755307",
"0.5714774",
"0.56875235",
"0.56828254",
"0.5674134",
"0.5668273",
"0.5624892",
"0.5623279",
"0.5601547",
"0.5593131",
"0.5580409",
"0.5566407",
"0.55468744",
"0.553305... | 0.58718413 | 5 |
This is the method called when the actual provisioning should be done. The communicator is guaranteed to be ready at this point, and any shared folders or networks are already setup. No return value is expected. Create virtual disk for hyperv | def hyperv
has_grow, grow_by = SubutaiDisk.has_grow
file_disk = SubutaiDisk.file_path(grow_by, "hyper_v")
disk_path = Pathname.new file_disk
unless disk_path.exist?
Put.warn SubutaiDisk.message(grow_by)
if has_grow
if SubutaiDisk.hyperv_create_disk(grow_by, disk_path.to_s)
SubutaiDisk.save_path(SubutaiDisk.port, disk_path.to_s)
SubutaiDisk.save_conf(grow_by)
end
end
else
Put.error "Disk file already exist in #{file_disk}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provision_and_mount_volume(server, disk_size, device)\n unless provider.find_server_device(server, device)\n say \"Provisioning #{disk_size}Gb persistent disk for inception VM...\"\n provider.create_and_attach_volume(\"Inception Disk\", disk_size, server, device)\n end\n\n ... | [
"0.7184478",
"0.7171226",
"0.6888836",
"0.6855057",
"0.6751313",
"0.6733427",
"0.67110723",
"0.6693538",
"0.6674975",
"0.66719466",
"0.66538936",
"0.6632338",
"0.6566986",
"0.6548418",
"0.64755124",
"0.6435872",
"0.64113206",
"0.64079195",
"0.631962",
"0.6284248",
"0.62420166... | 0.72430027 | 0 |
Create virtual disk for parallels | def parallels
has_grow, grow_by = SubutaiDisk.has_grow
if has_grow
if SubutaiDisk.parallels_create_disk(grow_by)
Put.warn SubutaiDisk.message(grow_by)
SubutaiDisk.save_conf(grow_by)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @parti... | [
"0.67778575",
"0.66375697",
"0.6601021",
"0.64847475",
"0.6472364",
"0.6427526",
"0.6419448",
"0.63295513",
"0.62945926",
"0.62583375",
"0.62545604",
"0.6196271",
"0.6192126",
"0.6191641",
"0.61850196",
"0.6151338",
"0.6117992",
"0.6103454",
"0.6074768",
"0.6073221",
"0.60340... | 0.64364976 | 5 |
This is the method called when destroying a machine that allows for any state related to the machine created by the provisioner to be cleaned up. | def cleanup
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(machine, opts)\n end",
"def destroy_machine(action_handler, machine_spec, machine_options)\n raise \"#{self.class} does not implement destroy_machine\"\n end",
"def after_destroy(machine)\n expire_cache_for(machine)\n MachineChange.create! machine: machine, change_type: Machine... | [
"0.7396266",
"0.721743",
"0.7215667",
"0.70918",
"0.6923953",
"0.68861246",
"0.67556965",
"0.67232376",
"0.6697899",
"0.6697899",
"0.66616756",
"0.6639539",
"0.6629815",
"0.6593809",
"0.65660787",
"0.6553978",
"0.65416646",
"0.6508392",
"0.6476208",
"0.64621925",
"0.6448655",... | 0.0 | -1 |
prepend_before_action :require_no_authentication, :only => [ :new, :create ] | def edit
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_no_authentication\n end",
"def login_required\n not_authorized unless current_user\n end",
"def require_no_authentication\n # skip this!\n end",
"def require_authentication\n\n # No matter what the app does a user can always login, forgot\n # password and register.... | [
"0.7519862",
"0.71997106",
"0.7147204",
"0.70662355",
"0.7024284",
"0.6958652",
"0.6954026",
"0.6906881",
"0.69065624",
"0.6863152",
"0.68626606",
"0.68237215",
"0.68176854",
"0.68174756",
"0.67948294",
"0.6771515",
"0.6762861",
"0.6762861",
"0.6740018",
"0.67387325",
"0.6731... | 0.0 | -1 |
Calculate time elapse since the beginning of the sprint. If sprint has no end_date then return days elapsed instead of a percentage. | def time_elapsed_calculation
today = Date.today
consumed_days = (today - self.start_date).to_i
if self.end_date && self.end_date > today
duration = (self.end_date - self.start_date).to_i
return (consumed_days > 0 ? percentage_calculation(consumed_days, duration) : 0).truncate, :percent
elsif self.end_date && self.end_date <= today
return 100, :percent
else
return consumed_days > 0 ? consumed_days : 0, :days
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed_time\n if end_time && start_time\n return ((end_time - start_time)/60).round\n else\n return 0\n end\n end",
"def seconds_until_end_of_day\n end_of_day.to_f - to_f\n end",
"def duration\n @end_date - @begin_date\n end",
"def get_duration()\n puts \"The task will t... | [
"0.65186733",
"0.6436352",
"0.62474847",
"0.6228137",
"0.6202688",
"0.6159158",
"0.6148828",
"0.61454594",
"0.6118584",
"0.61168593",
"0.60945094",
"0.6093331",
"0.6054964",
"0.6049991",
"0.6039363",
"0.6010414",
"0.60022587",
"0.60022587",
"0.59882295",
"0.59774464",
"0.5936... | 0.7462136 | 0 |
This is calculated based on done progression ratio of tasks attached to user stories. | def tasks_progress
total_done = 0
total_tasks = 0
self.stories.each do |story|
story.issues.each do |issue|
total_tasks += 1
total_done += issue.done
end
end
total_tasks > 0 ? total_done / total_tasks : 100
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percent_complete\n # return 0 if there is no tasks\n return 0 if tasks.none?\n ((total_complete.to_f / total_tasks) * 100).round\n end",
"def progress\n total_steps_count = self.steps.count\n\n if total_steps_count.zero?\n 0.0\n else\n approved_steps_count = self.steps.where(stat... | [
"0.74512154",
"0.7436753",
"0.72438914",
"0.67643964",
"0.67224556",
"0.662583",
"0.6580096",
"0.65684044",
"0.6532772",
"0.6526737",
"0.651519",
"0.65108883",
"0.65090024",
"0.6506567",
"0.65000975",
"0.64937645",
"0.64682925",
"0.64525026",
"0.641646",
"0.64145035",
"0.6393... | 0.8558803 | 0 |
Action /set_org_member_password/ PATCH /setorgmemberpassword XmlHttpRequest Purpose: Allow org members to set their passwords via signup link These are org members who have had user resources created for them by an org admin | def set_org_member_password
@user = User.includes(:profile).find_by_email(params[:email])
# Update users password and set signup_token to nil
# Setting signup_token to nil invalidates sign up link
# used by the user.
@user.update(
password: params[:password],
password_confirmation: params[:password_confirmation],
signup_token: nil
)
@user.profile.update(dashboard_registered: true)
# Create zoho lead record
if !@user.organization.nil? && @user.organization.name != 'test'
ZohoService.save_to_zoho(@user.profile)
end
sign_in(@user, scope: :user)
# Setting up alias to map user id to mixapanel unique id. So we can use userid moving forward
mixpanel_distinct_id = params[:distinct_id]
@tracker.alias(@user.id, mixpanel_distinct_id)
@tracker.people.set(@user.id,{
'$first_name' => @user.profile.first_name,
'$last_name' => @user.profile.last_name,
'$email' => @user.email,
'$phone' => @user.profile.phone,
},@user.current_sign_in_ip.to_s)
@tracker.track(@user.id,'User account activated')
flash[:notice] = 'Welcome to MyDomino!'
# Mixpanel event - User set password
render json: {
message: 'User password updated',
status: 200
}, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n super\n resource.update(password: params[:password], password_confirmation: params[:password_confirmation], member_id: SecureRandom.alphanumeric(6))\n post_gmo_with_create_member(resource)\n end",
"def update_with_password(params, *options); end",
"def attempt_set_password(params)\n\t p ... | [
"0.63011265",
"0.5962949",
"0.58636236",
"0.58540285",
"0.58495784",
"0.5841403",
"0.58366054",
"0.58302",
"0.5809686",
"0.579569",
"0.57862204",
"0.5773143",
"0.575053",
"0.57415247",
"0.57415247",
"0.57415247",
"0.57415247",
"0.57415247",
"0.57415247",
"0.57415247",
"0.5741... | 0.69969654 | 0 |
Action /create_org_member/ POST /createorgmember XmlHttpRequest Purpose: Creates organization member and provisions Dashboard, and Profile resources | def create_org_member
@organization = Organization.find(params[:organization_id].to_i)
@email = params[:email]
@first_name = params[:first_name]
@last_name = params[:last_name]
@pw = params[:password]
@pw_confirmation = params[:password_confirmation]
# TODO check if authtoken is in sess variable
# If so, only update user password
# Allocate User account, dashboard, and profile
@user = User.create(
email: @email,
password: @pw,
password_confirmation: @pw_confirmation,
organization: @organization
)
if @user
Dashboard.create(
lead_email: @email,
lead_name: "#{@first_name} #{@last_name}",
user: @user
)
profile = Profile.find_or_create_by!(email: @email) do |profile|
profile.first_name = @first_name
profile.last_name = @last_name
profile.dashboard_registered = true
end
profile.update(user: @user)
# Create zoho lead record
if !@orgnization.nil? && @organization.name != 'test'
ZohoService.save_to_zoho(profile)
end
#sign in newly created user
sign_in(@user, scope: :user)
# Setting up alias to map user id to mixapanel unique id. So we can use userid moving forward
mixpanel_distinct_id = params[:distinct_id]
@tracker.alias(@user.id,mixpanel_distinct_id)
@tracker.people.set(@user.id,{
'$first_name' => @user.profile.first_name,
'$last_name' => @user.profile.last_name,
'$email' => @user.email,
'$phone' => @user.profile.phone
},@user.current_sign_in_ip.to_s)
@tracker.track(@user.id,'User account created for org. member')
# flash[:notice] = 'Welcome to MyDomino!'
render json: {
message: 'User added',
status: 200
}, status: 200
else
render json: {
message: 'Error adding user',
status: 400
}, status: 400
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_member\n # Member.create!..\n\n respond_to do |format|\n format.html { redirect_to organization_path(params[:orgaid])}\n format.json { head :no_content }\n end\n end",
"def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @or... | [
"0.72760755",
"0.7131431",
"0.6958997",
"0.6934037",
"0.67965883",
"0.6728821",
"0.6460498",
"0.64373523",
"0.6360528",
"0.6336583",
"0.63169545",
"0.63102674",
"0.62421125",
"0.6202948",
"0.6199938",
"0.6198528",
"0.61858857",
"0.61443496",
"0.61057204",
"0.60915136",
"0.607... | 0.695995 | 2 |
Action /check_org_member_email/ GET /checkorgmemberemail XmlHttpRequest Purpose: Checks submitted org member email. Checks if a user account already exists for the provided email address If a user account exists, generate unique sign up link and provide relevant feedback If a user account doesn't exist, user will be prompted for setting first name, last name, and password. | def check_org_member_email
@user = User.includes(:profile).find_by_email(params[:email])
# If user account exists, send signup link email
if @user
# If a user has previously set a password,
# Redirect them to the sign in page.
# Else send the users a sign up link
# TODO: May want to change dashboard_registered to password_registered ?
if @user.profile.dashboard_registered
flash[:alert] = 'Your membership has already been activated. Try logging in.'
render json: {
message: 'User has already signed up.',
status: 400
}, status: 400
return
else
message = "account exists"
@user.email_signup_link
end
else
message = "no account exists"
end
render json: {
message: message,
status: 200
}, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_email_address\n\t logger.info \"Checking email address\"\n\t logger.info params.inspect\n\t user = OrderUser.find_by_email_address(params[:email_address])\n\t if user\n\t # Show pop window with login page...\n\t render(:update) { |page| page.call('showLoginWin', user.email_address) }\n\t ret... | [
"0.64584976",
"0.6062465",
"0.60611117",
"0.6051014",
"0.60369486",
"0.60173655",
"0.6002389",
"0.5834479",
"0.58031744",
"0.5724737",
"0.5722901",
"0.571182",
"0.56537503",
"0.56503636",
"0.5609442",
"0.55434406",
"0.5498514",
"0.5471769",
"0.5447769",
"0.5430609",
"0.541109... | 0.78106475 | 0 |
/after_sign_up_path_for/ This action is hit after a user registers through the devise registration form | def after_sign_up_path_for(resource)
@email = current_user.email
@profile = Profile.find_by_email(@email)
current_user.profile = @profile if !@profile.nil?
# Assumption is that profiles exist
# fallback to default profile
# Create and bind dashboard to user
# Assign provisioned dashboard to newly registered user (i.e. user who onboarded through mydomino.com)
if dashboard = Dashboard.find_by_lead_email(@email)
current_user.dashboard = dashboard
else
#if dashboard hasn't been allocated (i.e. imported lead) create one
current_user.dashboard = Dashboard.create(lead_name: "#{@profile.first_name} #{@profile.last_name}", lead_email: @profile.email)
end
@profile.update(dashboard_registered: true)
DashboardRegisteredZohoJob.perform_later @profile
user_dashboard_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_up_path_for(resource)\n complete_user_registration_path\n end",
"def after_sign_up_path_for(resource)\n after_register_path\n end",
"def after_sign_up_path_for(resource)\n '/carrier/sign_up_complete'\n end",
"def after_sign_up_path_for(user)\n after_sign_in_path_for(user)\n end... | [
"0.8524374",
"0.847958",
"0.82449675",
"0.8136874",
"0.8133482",
"0.8131235",
"0.8057278",
"0.8025833",
"0.8017078",
"0.79332334",
"0.7923754",
"0.7917164",
"0.7911184",
"0.7907128",
"0.7866602",
"0.78593326",
"0.78593326",
"0.78530574",
"0.7851859",
"0.7847106",
"0.7834858",... | 0.0 | -1 |
creates a repo that will persist until a teardown is called | def repo!(name='blah')
path = File.join(PATH, name.to_s)
FileUtils::mkdir_p(path)
delete!(name)
@repos ||= {}
@current_repo = name.to_sym
@repos[@current_repo] = SvnRepos.create(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo\n return @repo if can_persist?\n return nil\n end",
"def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"git@github.com:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n ... | [
"0.6811285",
"0.6763754",
"0.65948415",
"0.640709",
"0.63802975",
"0.6360155",
"0.6224533",
"0.6216736",
"0.6189139",
"0.608706",
"0.6045054",
"0.59831566",
"0.59831566",
"0.59831566",
"0.59831566",
"0.59560657",
"0.5909084",
"0.59039855",
"0.58957815",
"0.5890653",
"0.587082... | 0.63730687 | 5 |
Defines a new LoggedEmail2 type and registers a definition | def mailing(name, &block)
definition = MailControl::DefinitionDSL.new(name)
definition.instance_eval(&block)
MailControl::Definition.register(definition)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n # Setting the target alum for use in the 'create' method\n @alum = get_target_alum\n @email = SimpleEmail.new\n end",
"def email_address2_field\n #unit_test_no_generate: email_address2_field, input.className(create_ats_regex_string(\"ats-emailaddr2field\"))\n $tracer.trace(__method_... | [
"0.54313",
"0.52686584",
"0.5221663",
"0.5178695",
"0.5047233",
"0.5014113",
"0.50047094",
"0.50000656",
"0.49762675",
"0.49468237",
"0.49468237",
"0.49468237",
"0.49315363",
"0.49005938",
"0.48987067",
"0.4879325",
"0.48744422",
"0.48724532",
"0.48644552",
"0.48644552",
"0.4... | 0.0 | -1 |
Publishes an mailing using an mailing name and data | def send_email(verb, data)
new.send_email({:verb => verb}.merge(data))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliver_dovecot data\n cmd = [\"/usr/lib/dovecot/deliver\", \"-d\", data[\"selector\"]]\n if data[\"spam\"]\n cmd += [\"-m\", @spam_folder_name]\n elsif data[\"folder\"]\n cmd += [\"-m\", data[\"folder\"]]\n end\n\n IO.popen(cmd, \"w\") do |io|\n io.write data[\"ma... | [
"0.6577093",
"0.6550975",
"0.6524113",
"0.64956677",
"0.6429725",
"0.6384903",
"0.63551754",
"0.6287927",
"0.62176687",
"0.61984324",
"0.617865",
"0.6176727",
"0.61686975",
"0.6161325",
"0.6159985",
"0.6119547",
"0.6115549",
"0.6107035",
"0.60711765",
"0.6069106",
"0.60288286... | 0.55938953 | 100 |
Publishes the mailing to the receivers | def send_email(data = {})
assign_properties(data)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform\n current_time = Time.now\n packages = find_packages(city_db_id)\n emails = find_emails(city_db_id)\n\n ## Create list of recipients as array of strings\n recipients = []\n emails.each do |email|\n recipients << email.email_value\n end\n\n Emailer.packages_notification(curr... | [
"0.6839867",
"0.6791205",
"0.67628634",
"0.65801597",
"0.647074",
"0.646174",
"0.63911223",
"0.6372528",
"0.63397455",
"0.6327601",
"0.6317294",
"0.6301084",
"0.6233337",
"0.618318",
"0.61799383",
"0.6159365",
"0.61271095",
"0.6112922",
"0.610818",
"0.60695434",
"0.606483",
... | 0.0 | -1 |
TODO: ask for confirmation | def reset_and_clean
@continue_building = true
ea = ExecutionAgent.new(a_batch_file)
puts "clean workspace..."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm\n\n end",
"def confirm\n end",
"def confirm\n end",
"def confirmation\n end",
"def confirmed?; end",
"def confirm(prompt); end",
"def confirm_order\n end",
"def confirm\n puts \"#{@gre}[ok] #{@lastMsg}. #{@ncl}\"\n end",
"def confirm(question)\n CLI::UI.confirm(question... | [
"0.73962414",
"0.70659375",
"0.70659375",
"0.705378",
"0.6909239",
"0.6475207",
"0.64598745",
"0.64061874",
"0.63475966",
"0.6332395",
"0.6330128",
"0.6308999",
"0.6286164",
"0.6256752",
"0.62067795",
"0.6180479",
"0.6177662",
"0.61279875",
"0.61279875",
"0.612125",
"0.611696... | 0.0 | -1 |
using_insert increases the length of the array using_uniq takes in an argument of an array and uses the uniq method to remove any duplicate items using_flatten takes in an argument of an array that contains other arrays and uses the flatten method to return an array of strings using_delete takes in two arguments, an array and a string, and uses the delete method to remove any items from the array that are equal to that string using_delete_at takes in two arguments, an array and an integer and deletes the element at the index of the array that is equal to that integer | def using_push(array, str)
array.push(str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_uniq(array)\n\n \nend",
"def remove_duplicates(array)\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup\ndel=[]\nsource.each do |item|\n if item.is_a? Integer\n del << item\n next\n elsif item.include?(thing_to_delete)\n next\n else\n del << it... | [
"0.6412517",
"0.6087503",
"0.60739917",
"0.60194963",
"0.5999837",
"0.5917707",
"0.5917707",
"0.59056693",
"0.59056693",
"0.59056693",
"0.59056693",
"0.59056693",
"0.59056693",
"0.5894723",
"0.5893275",
"0.5893275",
"0.5869435",
"0.5861813",
"0.5844778",
"0.5837999",
"0.58349... | 0.0 | -1 |
Sample names Get sample names containing a substring | def get_sample_names(substring)
inputs = Dir.glob("inputs/#{$jobid}/*.txt").select {|x| x.include? substring}
inputs = inputs.map{|x| File.basename(x).sub(".txt", "")}
return inputs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sample_names(substring)\n inputs = Dir.glob(\"inputs/#{$jobid}/*.txt\")\n inputs = inputs.select {|x| x.include? substring}\n inputs = inputs.map{|x| File.basename(x).sub(\".txt\", \"\")}\n return inputs\nend",
"def get_sample_names(substring)\n inputs = Dir.glob(\"inputs/#{$jobid}/*.txt\").select {... | [
"0.76673555",
"0.7073276",
"0.6378959",
"0.6314352",
"0.6258772",
"0.6256963",
"0.6181172",
"0.6140425",
"0.60791445",
"0.6078461",
"0.6075472",
"0.60706043",
"0.6051366",
"0.58784837",
"0.5877926",
"0.5872074",
"0.58698726",
"0.5865676",
"0.5839899",
"0.58268607",
"0.5812277... | 0.7544055 | 4 |
Function to get the .root files for an analyzer and samples | def get_analyzer_results(analyzer, the_samples)
output = Array.new
analyzer_base = analyzer.sub('.py', '')
the_samples.each do |sample|
output << "results/#{$jobid}/#{analyzer_base}/#{sample}.root"
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_analyzer_results(analyzer, the_samples)\n output = Array.new\n analyzer_base = analyzer.sub('.py', '')\n puts the_samples\n puts analyzer\n the_samples.each do |sample|\n output << \"results/#{$jobid}/#{$selection}#{$jetcorrection}/iso#{$isolation}/#{analyzer_base}/#{sample}.root\"\n #output << ... | [
"0.6927361",
"0.6595028",
"0.6505841",
"0.62933654",
"0.6244913",
"0.6138477",
"0.60480464",
"0.603243",
"0.6031432",
"0.59945494",
"0.59823954",
"0.59545237",
"0.59512407",
"0.58564824",
"0.5855207",
"0.5851612",
"0.5800092",
"0.5742886",
"0.5724508",
"0.5693501",
"0.5686286... | 0.7131445 | 5 |
We have to override the parent method, because we consume the entire "should" array | def insync?(is)
self.is_to_s(is) == self.should_to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should\n @should\n end",
"def should\n @should\n end",
"def should\n @should\n end",
"def should\n return nil unless defined?(@should)\n\n self.devfail \"should for #{self.class.name} on #{resource.name} is not an array\" unless @should.is_a?(Ar... | [
"0.7158155",
"0.7158155",
"0.7158155",
"0.71242136",
"0.7097036",
"0.6896818",
"0.6888195",
"0.6191928",
"0.6100909",
"0.6100909",
"0.6100909",
"0.5870007",
"0.5762448",
"0.5711155",
"0.568075",
"0.5679225",
"0.5636177",
"0.5539586",
"0.5537129",
"0.553543",
"0.5503607",
"0... | 0.0 | -1 |
A method used to do parameter input handling. Converts integers in string form to actual integers, and returns the value if it's an integer or false if it's just a normal string. | def numfix(num)
if num =~ /^\d+$/
return num.to_i
elsif num.is_a?(Integer)
return num
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_is_integer?(string)\n return string.strip.numeric?\n end",
"def is_int? str\n Integer(str) rescue return false\n return true\nend",
"def integer?(input)\n Integer(input) rescue false\nend",
"def is_integer?(input)\n input.to_i.to_s == input\nend",
"def integer?(string)\n b = Integer(stri... | [
"0.7472513",
"0.73254853",
"0.726793",
"0.7262263",
"0.7192054",
"0.71796495",
"0.71796495",
"0.7177845",
"0.7148516",
"0.70875627",
"0.7021748",
"0.70129055",
"0.69769156",
"0.69529355",
"0.6935498",
"0.69320345",
"0.69314617",
"0.69084823",
"0.6907056",
"0.6892853",
"0.6838... | 0.0 | -1 |
Verify that a number is within the specified limits. Return the number if it is, or false if it is not. | def limitcheck(num, lower, upper)
(num >= lower and num <= upper) && num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_range?\n (0..@max_num).cover?(@number)\n end",
"def is_limit_valid?(limit)\n return (limit.class == Float &&\n limit >= 0.0 &&\n limit <= 100.0)\n end",
"def greater_or_equal_to?(value, limit)\n integer?(value) && value >= limit\n end",
"def... | [
"0.76447666",
"0.7299161",
"0.71911174",
"0.7053231",
"0.70380837",
"0.70098907",
"0.7008786",
"0.6995218",
"0.6921978",
"0.6866598",
"0.68082786",
"0.67724204",
"0.67624515",
"0.6752354",
"0.6723312",
"0.66525555",
"0.66408575",
"0.6637935",
"0.662008",
"0.66172594",
"0.6595... | 0.80487645 | 1 |
Verify that a value falls within the specified array. Does case insensitive matching, and supports matching either the entire word or the first three letters of the word. | def alphacheck(value, ary)
tmp = value.downcase
# If they specified a shortened version of the name, then see
# if we can lengthen it (e.g., mon => monday).
if tmp.length == 3
ary.each_with_index { |name, index|
if tmp.upcase == name[0..2].upcase
return index
end
}
else
return ary.index(tmp) if ary.include?(tmp)
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(array)\n array.find_all do |word|\n # split word into arry of letters\n if word.split(\"\").sort == @word.sort\n word\n end\n end\n end",
"def all_words_capitalized?(arr)\n arr.all? {|word| word[0].upcase == word[0] && word[1..-1].downcase == word[1..-1]}\nend",
"def m... | [
"0.66882634",
"0.6687752",
"0.65862554",
"0.6517565",
"0.6470131",
"0.6382463",
"0.6336332",
"0.63281643",
"0.62703556",
"0.62609845",
"0.6255969",
"0.62534815",
"0.6252075",
"0.6187171",
"0.61824715",
"0.61695766",
"0.6070352",
"0.6025694",
"0.59876657",
"0.5966383",
"0.5932... | 0.6440437 | 5 |
Please use property_values/config/routes.rb instead for extension routes. def self.require_gems(config) config.gem "gemnamegoeshere", :version => '1.2.3' end | def activate
Product.class_eval do
accepts_nested_attributes_for :product_properties, :allow_destroy => true
end
Property.class_eval do
has_many :property_values, :attributes => true, :dependent => :destroy
accepts_nested_attributes_for :property_values, :allow_destroy => true
end
Admin::ProductPropertiesController.class_eval do
create.response do |wants|
wants.html { redirect_to collection_url }
end
def update_all
@product = parent_object
@product.product_properties_attributes = params[:product][:product_properties_attributes]
@product.save!
flash[:notice] = "Properties updated"
redirect_to collection_url
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_gems; end",
"def require!\n super do\n gem @gem_name, @version if @version\n end\n end",
"def add_gem_paths; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gem... | [
"0.730155",
"0.68819106",
"0.6672021",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6593869",
"0.6397409",
"0.62860185",
"0.62860185",
"0.62860185",
"0.62860185",
"0.62860185",
"0.62860185",
"0.62277764",
"0.6205618",
"0.619013... | 0.0 | -1 |
Define the server to connect to If no username is given, the current user name is used If no password is given, the current user public key will be used (`~/.ssh/id_rsa.pub`) | def initialize(ssh_uri)
uri = URI(ssh_uri)
@host = uri.host
@port = uri.port || 22
@user = uri.user || ENV['USER']
if uri.password
@password = uri.password
else
@key = "#{ENV['HOME']}/.ssh/id_rsa"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ssh_user(username, password)\n # Sets the credentials for a the remote SSH user\n @username = username\n @password = password\n end",
"def ssh_user(arg=nil)\n set_or_return(:ssh_user, arg, :kind_of => String)\n end",
"def ssh_user(val=nil)\n from... | [
"0.68364817",
"0.66508293",
"0.66296035",
"0.64606094",
"0.6443436",
"0.64218736",
"0.63578415",
"0.6327119",
"0.6316823",
"0.6294683",
"0.62412894",
"0.6229186",
"0.6220012",
"0.6207844",
"0.61931086",
"0.61772263",
"0.6162133",
"0.61479926",
"0.6131438",
"0.6131438",
"0.607... | 0.57233804 | 52 |
Connect to the server using SSH and cache the connection during the block execution If no password is memorized, try to connect using the user ssh key (in ~/.ssh/id_rsa) Can be used without block, but the connection need to be closed manually | def connect(&block)
options = { port: @port }
if @password then
options[:password] = @password
else
options[:keys] = @key
end
if block
Net::SSH.start @host, @user, options do |ssh|
@ssh = ssh
yield ssh
@ssh = nil
end
else
@ssh = Net::SSH.start @host, @user, options
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(&block)\n begin\n Puppet.debug \"Trying to connect to #{host} as #{user}\"\n @ssh = Net::SSH.start(host, user, :port => port, :password => password, :timeout => timeout,\n :paranoid => Net::SSH::Verifiers::Null.new,\n :global_known_host... | [
"0.76560146",
"0.73639697",
"0.73221517",
"0.7311251",
"0.7253374",
"0.71861815",
"0.71575177",
"0.70106196",
"0.6966203",
"0.6957361",
"0.6918605",
"0.6908999",
"0.68282473",
"0.6793941",
"0.6756721",
"0.67559063",
"0.6659014",
"0.6625321",
"0.65938944",
"0.6569488",
"0.6555... | 0.7602745 | 1 |
Close the SSH connection if opened | def disconnect
@ssh.close if @ssh
@ssh = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_ssh\n puts \"Close connection\"\n @ssh.close unless @ssh.closed?\n end",
"def close\n ssh.close if @_ssh\n end",
"def close\n log 'closing connection'\n @ssh.close\n end",
"def close()\n #N Without this check, we'll be trying to close the connection even... | [
"0.8865944",
"0.8551008",
"0.8537254",
"0.8465464",
"0.824279",
"0.8175149",
"0.8061026",
"0.79126906",
"0.7698339",
"0.74421877",
"0.7399983",
"0.7333281",
"0.7232063",
"0.71255445",
"0.71255445",
"0.68480676",
"0.6797574",
"0.67678875",
"0.6747421",
"0.6712352",
"0.6577173"... | 0.7993064 | 7 |
Exec a command on the server (need to be connected) AND raise an error if the command failed. If an error is raised, it will print the backtrace, the stdout and stderr, the command and its exit status code. | def exec!(cmd, options={})
exit_status, stdout, stderr, cmd = exec(cmd, options)
error_msg = options[:error_msg] || "The following command exited with an error"
raise Appd::RemoteError.new(stdout, stderr, exit_status, cmd), error_msg if exit_status != 0
return stdout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec!(command, status: T.unsafe(nil), &block); end",
"def exec( command, want_reply=false )\n send_request_string \"exec\", command, want_reply\n end",
"def exec!(command, timeout=nil)\n logger.info(\"Executing: #{command}\")\n stderr,stdout = '', ''\n stdout, stderr = timeou... | [
"0.6836282",
"0.6723535",
"0.66255736",
"0.66209733",
"0.66013384",
"0.65274096",
"0.6517381",
"0.65150493",
"0.65127134",
"0.6485924",
"0.6464947",
"0.64349043",
"0.6426631",
"0.6407975",
"0.6374313",
"0.6372777",
"0.63415104",
"0.63336945",
"0.63299197",
"0.6299393",
"0.629... | 0.72001165 | 0 |
Exec a command on the remote server and return the exit status | def exec?(cmd, options={})
exit_status, stdout, stderr, cmd = exec(cmd, options)
return (exit_status == 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_remote_command(server, cmd)\n ssh(server, cmd).status == 0\n end",
"def exec!(cmd, options={})\n exit_status, stdout, stderr, cmd = exec(cmd, options)\n error_msg = options[:error_msg] || \"The following command exited with an error\"\n raise Appd::RemoteError.new(stdout, std... | [
"0.72105175",
"0.70535463",
"0.7035014",
"0.7032693",
"0.7003596",
"0.6885663",
"0.6885663",
"0.68631244",
"0.6726727",
"0.66648394",
"0.6651327",
"0.66450477",
"0.6560962",
"0.6540383",
"0.6540141",
"0.65165603",
"0.65146625",
"0.6483564",
"0.6483061",
"0.64688414",
"0.64637... | 0.0 | -1 |
Write content into a file on the remote host | def write(path, options={}, &block)
content = options[:content]
if block
content = []
yield content
content = content.join("\n")
end
exec! "cat > '#{path}' <<EOF\n#{content}\nEOF", options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_write(file, content)\n \n instructions = \"echo #{content.inspect} >> #{file}\"\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n puts 'r: ' + r.inspect if @debug\n \n @results[:file_write] = r\n\n end",
"def write_contents_remote(remote_filepath_str,contents_s... | [
"0.7695218",
"0.75683963",
"0.7312869",
"0.7216182",
"0.7052506",
"0.7018462",
"0.6911208",
"0.6908314",
"0.6902739",
"0.6656745",
"0.66372293",
"0.6543747",
"0.6444073",
"0.64080316",
"0.6341587",
"0.6341587",
"0.6210509",
"0.6197474",
"0.6155756",
"0.61106557",
"0.6106852",... | 0.0 | -1 |
Send a local file to the server using scp. | def send_file(src, dst)
uploaded = false
Net::SCP.start(@host, @user, password: @password, port: @port) do |scp|
scp.upload! src, dst do |ch, name, sent, total|
uploaded = true if sent == total
end
end
return uploaded
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_to_remote(local_file, remote_path)\n\t\t@ssh_session.scp.upload! local_file, remote_path\n\tend",
"def put(local_file, remote_file=nil)\n remote_file = remote_file.nil? ? File.basename(local_file) : remote_file\n @logger.debug(sprintf('scp from host[%s] to VM[%s]', local_file, remote_file))\n\n ... | [
"0.79339105",
"0.768277",
"0.73314",
"0.7243429",
"0.7198924",
"0.7126455",
"0.7126079",
"0.7084108",
"0.7080932",
"0.7078195",
"0.70153093",
"0.69521195",
"0.69249064",
"0.68756217",
"0.6860868",
"0.6858283",
"0.6844322",
"0.6752004",
"0.6744988",
"0.67368484",
"0.67204815",... | 0.7014803 | 11 |
Test User methods permissions should be a commaseparated string of facebook permissions | def create_fb_test_user(connected=true,permissions="email")
ug = Koala::Facebook::TestUsers.new(:app_id => OPTIONS[:facebook_app_id], :secret => OPTIONS[:facebook_secret_key])
if connected
user = ug.create(true, permissions)
else
user = ug.create(false)
end
return user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_permissions *permissions\n permissions = Array(permissions).flatten\n permissions = Array(permissions).flatten\n ensure_service!\n grpc = service.test_topic_permissions name, permissions\n grpc.permissions\n end",
"def fpermissions(*list, &block)\n de... | [
"0.6383695",
"0.63198805",
"0.61445504",
"0.6016366",
"0.60052454",
"0.6004652",
"0.5976006",
"0.5823895",
"0.5820458",
"0.5683805",
"0.56685793",
"0.56655115",
"0.5661828",
"0.56320536",
"0.5542861",
"0.5522072",
"0.5465148",
"0.546467",
"0.54577744",
"0.540157",
"0.5394609"... | 0.0 | -1 |
the recursive implementation should have the same signature you can have another private method that has a different signature for example: def better_inject_recursion(initial = nil, &block) better_inject_recursion_array(self.dup, initial, &block) end private instead of passing n, you can pass a smaller array each time, it'll be cleaner def better_inject_recursion_array(array, initial) ... | def better_inject_recursion(initial = nil,n=nil,&block)
result = 0
n ||= 0
return result if n == self.length
current_element = initial.nil? ? self[n] : initial
n+=1
result = yield(better_inject_recursion(nil,n,&block),current_element)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_controlled_flatten(n=1)\n #here\n return self if n < 1\n\n results = []\n self.each do |el|\n if el.class == Array\n #here\n results += el.my_controlled_flatten(n-1)\n else\n results << el\n end\n end\n\n results\n\n end",
"def recursive_print(array)\... | [
"0.66167915",
"0.63878083",
"0.6352145",
"0.62360066",
"0.62048554",
"0.61695063",
"0.6157169",
"0.61477333",
"0.61477333",
"0.61477333",
"0.61420524",
"0.61420524",
"0.6133313",
"0.6125838",
"0.6084929",
"0.6081736",
"0.607021",
"0.60536736",
"0.60536736",
"0.60512245",
"0.6... | 0.7825252 | 0 |
Convenient method that logs at info level, but also outputs the message to STDOUT if verbose is set in the config. | def puts_and_logs(msg)
@@logger.puts_and_logs msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_info(message)\n logger.info(message) if logger && logger.info?\n end",
"def info message\n log Logger::INFO, message\n end",
"def log_info(msg)\n logger ? logger.info(msg) : puts(msg)\n end",
"def info(message)\n logger.info(message) if logger\n end",
"def verbose_in... | [
"0.75979984",
"0.75744265",
"0.7569905",
"0.7427213",
"0.7389527",
"0.73231435",
"0.73169035",
"0.73169035",
"0.721636",
"0.7194176",
"0.7182379",
"0.7159204",
"0.71569955",
"0.71499485",
"0.713266",
"0.71188647",
"0.70857346",
"0.7081079",
"0.70806676",
"0.70727545",
"0.7072... | 0.0 | -1 |
Gets all SwiftPOS sales matching the specified search criteria. The saleId parameter allows users of the api to exclude sales that have been previously retrieved. Providing a value for the saleId parameter will result in the api returning sales with an id greater than the provided value. This means that users can periodically call the api to retrieve only those sales that have occurred since the last call to the api. The id parameter works with the maxRecords parameter, which limits the maximum number of sales that can be returned in a response. A maxRecords value greater than 0 results in the response being limited to the provided maximum number of sales. Transaction Types: Transaction Type 0 is the most common Transaction Type, which indicates a standard sale. Other Transaction Types, most notably 098 and 150500 (excluding types listed below) also indicate a standard sale. 00099 No Sale 00100 Cancelled Sale 00101 Door Access 00102 Clerk Log On 00103 Clerk Log Off 00112 Clock On 00113 Clock Off 00114 Start Break 00115 End Break 00525 Stocktake 00526 Transfer/s Out 00527 Transfer/s In 00990 Cash Drop 00999 Paid Out 05005 StkShrinkage 05010 Purchases 05011 Purchase Credits 08001 StkReceipts 08002 StkAdjustments 08003 StkDamaged 08004 StkReturns 08005 StkWastage 23456 Cash Up 29700 Points Balance 29800 Stock Promo Draw 29805 Attendance Draw 29810 Member Draw | def sale_get(api_key, opts = {})
data, _status_code, _headers = sale_get_with_http_info(api_key, opts)
return data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def sales\n FarMar::Sale.all.find_all {|instance| instance.product_id == id}\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == @id }\n end",
"def sale\n ret = nil\n if @json_... | [
"0.70221037",
"0.672777",
"0.6709693",
"0.66394746",
"0.6545108",
"0.6519183",
"0.64847565",
"0.63962024",
"0.6358856",
"0.6258127",
"0.6229073",
"0.6215882",
"0.61302745",
"0.6067937",
"0.606125",
"0.6048285",
"0.60308886",
"0.5992331",
"0.59498847",
"0.5939269",
"0.5932086"... | 0.59299934 | 21 |
Gets all SwiftPOS sales matching the specified search criteria. The saleId parameter allows users of the api to exclude sales that have been previously retrieved. Providing a value for the saleId parameter will result in the api returning sales with an id greater than the provided value. This means that users can periodically call the api to retrieve only those sales that have occurred since the last call to the api. The id parameter works with the maxRecords parameter, which limits the maximum number of sales that can be returned in a response. A maxRecords value greater than 0 results in the response being limited to the provided maximum number of sales. Transaction Types: Transaction Type 0 is the most common Transaction Type, which indicates a standard sale. Other Transaction Types, most notably 098 and 150500 (excluding types listed below) also indicate a standard sale. 00099 No Sale 00100 Cancelled Sale 00101 Door Access 00102 Clerk Log On 00103 Clerk Log Off 00112 Clock On 00113 Clock Off 00114 Start Break 00115 End Break 00525 Stocktake 00526 Transfer/s Out 00527 Transfer/s In 00990 Cash Drop 00999 Paid Out 05005 StkShrinkage 05010 Purchases 05011 Purchase Credits 08001 StkReceipts 08002 StkAdjustments 08003 StkDamaged 08004 StkReturns 08005 StkWastage 23456 Cash Up 29700 Points Balance 29800 Stock Promo Draw 29805 Attendance Draw 29810 Member Draw | def sale_get_with_http_info(api_key, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: SaleApi.sale_get ..."
end
# verify the required parameter 'api_key' is set
if @api_client.config.client_side_validation && api_key.nil?
fail ArgumentError, "Missing the required parameter 'api_key' when calling SaleApi.sale_get"
end
# resource path
local_var_path = "/api/Sale"
# query parameters
query_params = {}
query_params[:'saleId'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?
query_params[:'maxRecords'] = opts[:'max_records'] if !opts[:'max_records'].nil?
query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
header_params[:'ApiKey'] = api_key
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Array<SwiftPOSVenue>')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: SaleApi#sale_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def sales\n FarMar::Sale.all.find_all {|instance| instance.product_id == id}\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == @id }\n end",
"def sale\n ret = nil\n if @json_... | [
"0.70221037",
"0.672777",
"0.6709693",
"0.66394746",
"0.6545108",
"0.6519183",
"0.64847565",
"0.63962024",
"0.6358856",
"0.6258127",
"0.6229073",
"0.6215882",
"0.61302745",
"0.6067937",
"0.606125",
"0.6048285",
"0.60308886",
"0.5992331",
"0.59498847",
"0.5939269",
"0.5932086"... | 0.5243882 | 78 |
Creates a directory (with an optional specific name) in a temporary directory which will automatically be destroyed. | def directory(name = 'some-dir', &block)
tmpdir = Dir.mktmpdir.tap do |path|
Dir.chdir(path) do
Dir.mkdir(name)
Dir.chdir(name) do
block.call if block_given?
end
end
end
File.join(tmpdir, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tmp_dir\n if(!File.directory? @temp_dir)\n Dir.mkdir(@temp_dir)\n end\n end",
"def create_temp_dir(name, location)\n @@temporary_dir_number += 1\n pid = Process.pid # This doesn't work on some platforms, according to the docs. A better way to get it would be nice.\n ra... | [
"0.7821082",
"0.7664397",
"0.7616646",
"0.7204022",
"0.7022481",
"0.6985148",
"0.6925294",
"0.69169176",
"0.6908956",
"0.68860394",
"0.68668145",
"0.68594486",
"0.6830376",
"0.6808272",
"0.68014616",
"0.6801133",
"0.67968494",
"0.67689335",
"0.6765274",
"0.67477864",
"0.67329... | 0.69137245 | 9 |
~ Action methods ........................................................... GET /workouts | def index
# if cannot? :index, Workout
# redirect_to root_path,
# notice: 'Unauthorized to view all workouts' and return
# end
@workouts = Workout.where(is_public: true)
@gym = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @workouts = Workout.all\n end",
"def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end",
"def index\n @workouts = current_user.workouts\n end",
"def index\n @user_workouts = U... | [
"0.813163",
"0.8007345",
"0.7796086",
"0.77821445",
"0.7729885",
"0.76954705",
"0.7651642",
"0.75880766",
"0.74503076",
"0.7265428",
"0.7231462",
"0.72271246",
"0.72260165",
"0.7167732",
"0.71315014",
"0.70554054",
"0.7054849",
"0.7045599",
"0.70231366",
"0.6989184",
"0.69299... | 0.6790416 | 30 |
Placeholder for any views I want experiment with | def dummy
@workouts = Workout.find(1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rendered_views=(_arg0); end",
"def _view; end",
"def views(name = nil)\n raise NotImplementedError, \"views is an abstract method\"\n end",
"def view; end",
"def stub_view_routes\n\n view.stub( :experiment_path ).and_return( '/split_cat/experiment' )\n view.stub( :experiments_path ).and_r... | [
"0.6755775",
"0.6707505",
"0.64383924",
"0.63888973",
"0.63737494",
"0.6347292",
"0.6166714",
"0.6163269",
"0.60046864",
"0.59420943",
"0.59061086",
"0.5876028",
"0.58678716",
"0.58672917",
"0.5832808",
"0.5789411",
"0.57862735",
"0.5765245",
"0.5739917",
"0.5709199",
"0.5698... | 0.0 | -1 |
PATCH/PUT /workouts/1 def update | def update
if cannot? :update, @workout
redirect_to root_path,
notice: 'Unauthorized to update workout' and return
end
workout_offering_id = create_or_update
@workout.save!
if workout_offering_id.nil?
url = url_for(workout_path(id: @workout.id))
else
url = url_for(organization_workout_offering_path(
organization_id: params[:organization_id],
term_id: params[:term_id],
course_id: params[:course_id],
id: workout_offering_id
)
)
end
respond_to do |format|
format.json { render json: { url: url } }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n flash[:alert] = 'Workout was successfully updated.'\n format.html { redirect_to @workout }\n format.json { head :no_content }\n else\n format... | [
"0.8184355",
"0.81449056",
"0.810107",
"0.79373205",
"0.79182196",
"0.7844348",
"0.7834818",
"0.7821877",
"0.7776146",
"0.7744329",
"0.7724448",
"0.7627322",
"0.7540964",
"0.7517522",
"0.74878514",
"0.74718",
"0.74421734",
"0.74299747",
"0.74068516",
"0.73929507",
"0.73762697... | 0.73961467 | 19 |
Use callbacks to share common setup or constraints between actions. | def set_workout
@workout = Workout.find(params[:id])
@xp = 30
@xptogo = 60
@remain = 10
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def workout_params
params.require(:workout).permit(:name, :scrambled, :exercise_ids,
:description, :target_group, :points_multiplier, :opening_date, :exercise_workout,
:exercise_workouts_attributes, :workout_offerings_attributes,
:soft_deadline, :hard_deadline)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Output: boolean (is_palindome?) Examples: abcdcba | def is_palindrome(string) # a b c d c b a, m u m s, e a a e
left = 0
right = string.length - 1
while left <= right # 0 != 6, 1 != 5, 2 != 4, 3 != 3
return false if string[left] != string[right]
if string[left] == string[right]
left += 1
right -= 1
end
end
return true if left > right
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pal?(x)\n x.to_s == x.to_s.reverse\nend",
"def possible_palindrome?(word)\n nb_each_letters(word).one?(&:odd?) ||\n nb_each_letters(word).all?(&:even?)\nend",
"def are_palindromes?\n self.all? {|s| s == s.reverse }\n end",
"def can_be_palindrome?(str)\n\tstr.gsub!(/\\s+/, \"\")\n\tletter_co... | [
"0.6864109",
"0.636435",
"0.62906975",
"0.6288887",
"0.6257884",
"0.6218374",
"0.62143856",
"0.61909086",
"0.6184018",
"0.59737706",
"0.5937944",
"0.5926834",
"0.59158653",
"0.591034",
"0.5907504",
"0.5898474",
"0.5896198",
"0.58961433",
"0.588915",
"0.58526653",
"0.5840573",... | 0.0 | -1 |
Not really the purpose of the class... | def total_off_days(from, to)
total_off_days = 0
(from..to).map(&:wday).each do |day|
total_off_days += 1 if [0, 1].include?(day)
end
total_off_days
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def internal; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def custom; end",
"def custom; end",
"def initialize; end",
"def initialize; end",
"def initialize... | [
"0.83882517",
"0.72523725",
"0.72523725",
"0.69706726",
"0.6929537",
"0.6888524",
"0.6888524",
"0.6888524",
"0.6888524",
"0.67528456",
"0.67528456",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255",
"0.6706255... | 0.0 | -1 |
Metodo inicializador del grafo como un diccionario | def initialize
@grafo = Hash.new()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n if File.exist?(\"../Sauvegarde/grilles.dump\") == true \n @@instanceSauvegardeGrille = Marshal.load( File.binread( \"../Sauvegarde/grilles.dump\" ) )\n else\n @mesGrilles = [nil]\n @@instanceSauvegardeGrille = self\n end\n @@instanceSa... | [
"0.66914684",
"0.6681507",
"0.62510276",
"0.6184099",
"0.6160928",
"0.61394763",
"0.61394763",
"0.61394763",
"0.61394763",
"0.6138601",
"0.6070748",
"0.6070748",
"0.6070748",
"0.6052653",
"0.6045272",
"0.60330033",
"0.5998778",
"0.5995235",
"0.5962499",
"0.59558743",
"0.59549... | 0.6616176 | 2 |
Metodo par inserta en el diccionario los nodos y su lista de adyacencias como 'clave'/'valor' respectivamente | def insert(clave, valor)
@grafo[clave] = valor
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertar_varios(nodos)\n \n nodos.each do |nodoo|\n \n insertar(nodoo)\n \n end\n \n end",
"def insertar_por_cola(value)\n\t\tnodo=Node.new(value,nil,nil)\n if(@tail==nil)\n @tail=nodo\n @head=nodo\n... | [
"0.7297009",
"0.67136014",
"0.65927935",
"0.6372417",
"0.6301467",
"0.5861747",
"0.57229125",
"0.5720859",
"0.57178026",
"0.5694787",
"0.5630192",
"0.55995136",
"0.55414253",
"0.5496419",
"0.5454196",
"0.54316944",
"0.5422135",
"0.5408839",
"0.5403567",
"0.54024667",
"0.53898... | 0.6266126 | 5 |
Metodo busqueda Este recibe "g", que es el grafo; "d"; "h"; el contador "nro_nodos" y el arreglo de nodos "visitados" | def busqueda(g, d, h, nro_nodos, nodos_visitados, nro_nodos_en_caminos)
#Luego, en esta variable dependiendo de si estamos en un objeto DFS o BFS, se definira el orden
#en el que se seleccionaran los nodos para la busqueda. Ademas, esta variable tendra los elementos
#adyacentes del nodo d ya sea en una pila o en una cola.
pila_o_cola = self.orden_nodos(g,d)
#pila_o_cola.estructura.each {|elem| puts elem}
#Verificamos si la pila o cola, de adyacentes, incluye a "h"
if pila_o_cola.estructura.include? h
#De ser asi, se incluye el numero de nodos del recorrido que llevo a "h"
nro_nodos_en_caminos << nro_nodos
#Si la pila o cola no incluye a "h"
else
#Entonces mientras no este vacia, se recorre la estructura
while not(pila_o_cola.vacio)
#Luego se remueve un nodo de la estructura, que sera el siguiente que se usara
#como "inicio" de la busqueda
siguiente_nodo = pila_o_cola.remover
#Si el nodo en cuestion no ha sido visitado
if not(nodos_visitados.include? siguiente_nodo)
#Lo agregamos al arreglo de visitados
nodos_visitados << siguiente_nodo
#Y hacemos una llamada recursiva al metodo busqueda pero esta vez partiendo
#del nodo antes tomado. En esta llamada aumentamos el numero de nodos (nro_nodos)
#en 1
busqueda(g, siguiente_nodo, h , nro_nodos + 1 , nodos_visitados, nro_nodos_en_caminos)
end
end
end
#Luego de que acaba todo el procesamiento verificamos si en el arreglo "nro_nodos_en_caminos"
#esta vacio, si es asi entonces significa que el nodo "h" no fue alcanzado entonces
if nro_nodos_en_caminos.empty?
#retornamos -1
return -1
end
#Finalmente, si sobrevivimos todo lo anterior, llegados a este punto retornamos el numero de nodos que
#fueron recorridos de "d" a "h". Recordamos que el arreglo "nro_nodos_en_caminos" contiene para todos los
#caminos de "d" a "h", el numero de nodos recorridos.
## OJO: En este caso se retornara el nro de nodos recorridos del camino mas corto. ##
#Sin embargo, si se quisiera el nro de nodos de solo el primer camino por el que se metio y encontro a "h"
#bastaria con solo retornar "nro_nodos_en_caminos[0]".
#Por otra parte, si se quisiera para cada camino el nro de nodos recorridos entonces basta con retornar
#el arreglo completo, etc.
return "#{nro_nodos_en_caminos.min} nodos recorridos."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traktiNodon(nod, stato)\n\n objekto = {\"tipo\" => nod.name, \"filoj\" => [], \"tradukoj\" => {}, \"filNombro\" => 0}\n stato[\"super\"] << nod.name\n\n miaMarko = false\n\n if nod[\"mrk\"] != nil\n objekto[\"mrk\"] = nod[\"mrk\"]\n stato[\"marko\"] << nod[\"mrk\"]\n miaMarko = true\n ... | [
"0.64423686",
"0.6115086",
"0.5870854",
"0.58110684",
"0.57413095",
"0.5692658",
"0.5667712",
"0.5576723",
"0.5528481",
"0.55251",
"0.5498957",
"0.5424521",
"0.54237777",
"0.5403097",
"0.5399177",
"0.53670967",
"0.5322805",
"0.5310988",
"0.5270261",
"0.52621996",
"0.52258253"... | 0.70838374 | 0 |
Metodo que se encarga de establecer el orden de seleccion de nodos, a profundidad, como una pila | def orden_nodos(g,d)
return Pila.new(g.grafo[d])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_nodo\n @nodo = Nodo.find(params[:id])\n end",
"def select_tiporelacion\n [ \n [\"BENEFICIARIO\",\"BENEFICIARIO\"],\n [\"INTEGRANTE\",\"INTEGRANTE\"],\n [\"PROPIETARIO\",\"PROPIETARIO\"],\n [\"APODERADO\",\"APODERADO\"]\n ] \n end",
"def nodes; end",
"def nodes; e... | [
"0.62485915",
"0.58692455",
"0.5703276",
"0.5703276",
"0.5703276",
"0.5681463",
"0.55722487",
"0.55649984",
"0.5546442",
"0.54983515",
"0.5497418",
"0.5466489",
"0.5413876",
"0.5393664",
"0.5362005",
"0.5355463",
"0.53091854",
"0.52705073",
"0.52264273",
"0.5225747",
"0.51989... | 0.5867238 | 2 |
Metodo que se encarga de establecer el orden de seleccion de nodos, a amplitud, como una cola | def orden_nodos(g,d)
return Cola.new(g.grafo[d])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_nodo\n @nodo = Nodo.find(params[:id])\n end",
"def nodes_field\n define_nodes_field\n end",
"def nodes; end",
"def nodes; end",
"def nodes; end",
"def select_tiporelacion\n [ \n [\"BENEFICIARIO\",\"BENEFICIARIO\"],\n [\"INTEGRANTE\",\"INTEGRANTE\"],\n ... | [
"0.6109085",
"0.5839115",
"0.58126074",
"0.58126074",
"0.58126074",
"0.5656962",
"0.563768",
"0.562642",
"0.55502814",
"0.5378887",
"0.53547335",
"0.53398037",
"0.53398037",
"0.5333035",
"0.53010136",
"0.53010136",
"0.5266738",
"0.5266738",
"0.5266738",
"0.5266738",
"0.526673... | 0.5598456 | 8 |
the latest version for an arch | def latest_version
file_to_semver(sorted_files.first)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest_version\n versions.reverse_each.detect do | version|\n version_dir = SERVER_TOP_DIR + \"r#{version}\"\n path = Pathname.new(\"bin.tools\") + @s.p4ruby.basename\n if remote_file_exists?(version_dir, path)\n puts \"Found latest version: #{version}\"\n return version\n ... | [
"0.72523206",
"0.7240508",
"0.71286607",
"0.70722586",
"0.7007121",
"0.69233453",
"0.6922551",
"0.6919609",
"0.68670034",
"0.68378097",
"0.68378097",
"0.6805216",
"0.67920077",
"0.6771112",
"0.67514414",
"0.67386895",
"0.6727143",
"0.6724081",
"0.66945034",
"0.66863734",
"0.6... | 0.6477596 | 38 |
Path to the latest version file | def latest_version_file
sorted_files.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_file\n version_rb_file = File.dirname(Buildr.application.buildfile.to_s) + '/version.rb'\n return version_rb_file if File.exists?(version_rb_file)\n return Buildr.application.buildfile.to_s\n end",
"def version_file(path)\n \"#{@home}/versions/#{@version_name}/#{path}\"\nend",
"... | [
"0.76433986",
"0.7533043",
"0.75058204",
"0.74071854",
"0.73726135",
"0.72696847",
"0.7214093",
"0.71074533",
"0.71063036",
"0.7094853",
"0.7051181",
"0.6912419",
"0.6873001",
"0.68061113",
"0.674797",
"0.6681523",
"0.6672067",
"0.66288394",
"0.6627863",
"0.6627252",
"0.65947... | 0.7454595 | 3 |
the stable version for an arch | def stable_version
file_to_semver(stable_version_file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installed_version(package_name, arch = nil)\n version(package_name, arch, false, true)\n end",
"def available_version(package_name, arch = nil)\n version(package_name, arch, true, false)\n end",
"def major_version; end",
"def major ; version.major ; end",
"def pu... | [
"0.69710195",
"0.6918939",
"0.6880857",
"0.67727673",
"0.6712274",
"0.6694753",
"0.6691395",
"0.66514057",
"0.6564809",
"0.6541128",
"0.65160656",
"0.65109646",
"0.6480528",
"0.6460373",
"0.64552826",
"0.6448745",
"0.6448745",
"0.6448745",
"0.6433415",
"0.642618",
"0.64186364... | 0.7203963 | 0 |
Path to the stable version file | def stable_version_file
return sorted_files.first unless @stable_version
sorted_files.select { |f| file_to_semver(f) <= SemVersion.new(@stable_version) }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_file(path)\n \"#{@home}/versions/#{@version_name}/#{path}\"\nend",
"def version_path\n @version_path ||= \"lib/#{namespaced_path}/version.rb\"\n end",
"def version_file\n version_rb_file = File.dirname(Buildr.application.buildfile.to_s) + '/version.rb'\n return version_rb_file if Fi... | [
"0.7688079",
"0.75211436",
"0.7431875",
"0.7225663",
"0.72082466",
"0.71825916",
"0.71460676",
"0.7064063",
"0.7033087",
"0.6954744",
"0.6667542",
"0.66573197",
"0.66371155",
"0.66125596",
"0.66042584",
"0.65919435",
"0.6590597",
"0.6538413",
"0.6537724",
"0.6524206",
"0.6500... | 0.68116367 | 10 |
List of file paths to files for an arch | def sorted_files
sort_file_name_by_semver(all_files.select { |f| semver_file?(f) })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files\n return [] unless meta?\n filename = meta['path'] + '/' + meta['filename']\n [\n Inch::Utils::CodeLocation.new('', filename, meta['lineno'])\n ]\n end",
"def files\n entries.map(&:filepath)\n ... | [
"0.68836737",
"0.67421097",
"0.6610879",
"0.65680915",
"0.6563259",
"0.6537558",
"0.65311784",
"0.6521776",
"0.6489398",
"0.64449745",
"0.6442347",
"0.64116",
"0.64002156",
"0.63689107",
"0.63644266",
"0.6361036",
"0.635886",
"0.631622",
"0.63104004",
"0.6300347",
"0.6274454"... | 0.0 | -1 |
Full number separated by hyphens: +CNPANXXXXXX | def nanp_format
strfphone(NANP_FORMAT)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_phone_nbr_scrp\n if self[0] == \"0\"\n self[0].gsub(\"0\", \"+33\") + self[1..-1]\n end\n end",
"def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end",
"def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end",
"def card_number_mask\n \"XXX XXXX XXX #{l... | [
"0.7542221",
"0.7117238",
"0.7117238",
"0.6917929",
"0.6871692",
"0.6851438",
"0.6851438",
"0.6851438",
"0.6841452",
"0.670953",
"0.66610277",
"0.66542673",
"0.66371846",
"0.6621047",
"0.6612475",
"0.66077554",
"0.6513791",
"0.6500495",
"0.64806277",
"0.64442706",
"0.64272785... | 0.0 | -1 |
Full number with area code in parens: C (NPA) NXXXXXX | def npa_format
strfphone(NPA_FORMAT)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_code\n number[0..2]\n end",
"def to_s\n \"(#{ self.area_code }) #{ @number.slice(3,3) }-#{ @number.slice(6,4) }\"\n end",
"def phone_number(area_code = nil)\n area_code ||= CITIES.rand[1]\n length = 10 - area_code.length\n \"#{area_code} #{numerify('#' * length)}\"\n ... | [
"0.74355906",
"0.7143018",
"0.6837467",
"0.68071026",
"0.67850125",
"0.67527354",
"0.66984653",
"0.6675516",
"0.66716236",
"0.6346984",
"0.6323377",
"0.6288547",
"0.6285897",
"0.6225724",
"0.6212159",
"0.6212159",
"0.61959535",
"0.619488",
"0.6147661",
"0.6144221",
"0.6131723... | 0.6605528 | 9 |
Full Number with no division: +CNPANXXXXXX | def mobile_format
strfphone(MOBILE_FORMAT)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_phone_nbr_scrp\n if self[0] == \"0\"\n self[0].gsub(\"0\", \"+33\") + self[1..-1]\n end\n end",
"def card_number_mask\n \"XXX XXXX XXX #{last4}\"\n end",
"def build_normalized_number\n return sanitized_number unless country_data\n\n number_with_correct_prefix = parse_prefi... | [
"0.63068646",
"0.6270115",
"0.61637694",
"0.6122781",
"0.60899043",
"0.5994221",
"0.59786075",
"0.59633917",
"0.5962473",
"0.59429157",
"0.5932987",
"0.5887804",
"0.5887804",
"0.5884491",
"0.58751684",
"0.5866215",
"0.58273035",
"0.58162916",
"0.5802966",
"0.576706",
"0.57533... | 0.0 | -1 |
Build a format using portionkeys preceded by a "%" sign. If the portionkey is not present in the primitive number and no defaults are available, then an error is raised. | def strfphone(formatter)
flags = formatter.split("%")
return if flags.empty?
flags.each_with_object([]) do |f, result|
next unless flag = f.match(/(\+|C|NPA|NXX|XXXX)/)
result << construct(flag)
end.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scaffold_auto_complete_search_format_string\n {:substring=>'%%%s%%', :starting=>'%s%%', :ending=>'%%%s', :exact=>'%s'}[scaffold_auto_complete_options[:format_string]] || scaffold_auto_complete_options[:format_string]\n end",
"def scaffold_auto_complete_search_format_string\n {:substring=>'%%... | [
"0.57318884",
"0.570925",
"0.5659149",
"0.5413017",
"0.5348788",
"0.52810436",
"0.5226507",
"0.52245605",
"0.51746744",
"0.5146042",
"0.51429623",
"0.5137723",
"0.51320136",
"0.513068",
"0.51251525",
"0.5099376",
"0.5056916",
"0.50512624",
"0.49827307",
"0.4979292",
"0.497389... | 0.0 | -1 |
parses a primitive phone number string into readable sections | def parse_primitive(primitive)
# ensure string and strip all non-digit characters and whitespace
raw_string = primitive.to_s.gsub(/(\s|\D)/, "%")
raw_sections = raw_string.split("%")
raw_sections.flat_map { |rs| parse_section(rs) }.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_phone(phone_string)\n if phone_string =~ REGEX_PHONE\n if $2\n area_code = $2\n else\n area_code = $3\n end\n exchange = $4\n number = $5\n extension = $6\n return area_code, exchange, number, extension\n else\n return ni... | [
"0.7073062",
"0.6768403",
"0.67385346",
"0.67385346",
"0.67385346",
"0.67292976",
"0.6667707",
"0.6661417",
"0.6580361",
"0.6517985",
"0.6475405",
"0.64261544",
"0.64123994",
"0.6335408",
"0.6279236",
"0.6246221",
"0.62262166",
"0.619539",
"0.619539",
"0.6186279",
"0.615427",... | 0.0 | -1 |
slices up raw section strings into readable units | def parse_section(raw_section)
case raw_section.length
when 11 then [raw_section.slice!(0), parse_section(raw_section)].flatten
when 7, 10 then [raw_section.slice!(0..2), parse_section(raw_section)].flatten
else raw_section unless raw_section.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sections\n (1..section_size).inject([]) do |array, row_offset|\n (1..section_size).inject(array) do |array, column_offset|\n array << section_coordinates(row_offset - 1, column_offset - 1)\n end\n end\n end",
"def calculate_offsets\n\n # Maintain the offset into the t... | [
"0.57699215",
"0.54463744",
"0.54048693",
"0.53521574",
"0.53178406",
"0.5317429",
"0.53046274",
"0.5300799",
"0.52946556",
"0.5262474",
"0.5262043",
"0.52590126",
"0.5252865",
"0.52449715",
"0.5244859",
"0.5163307",
"0.5148951",
"0.5148902",
"0.5147315",
"0.51243454",
"0.512... | 0.66680473 | 0 |
helper method to process a provided flag | def construct(flag)
return "+" if flag.string == "+"
portion_key = flag.captures.first
substitution_alias = portion_key.downcase
flag.string.sub(portion_key, send(substitution_alias))
rescue TypeError
raise FormatError, "invalid format"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_flag(p, flag)\n breakdown = flag.split(\"*\")\n if flag.match(/^---.*/)\n parse_error! p, \"Flags must be prefixed with two hyphens (-); #{flag} has more than that.\"\n end\n\n if breakdown.length > 2\n parse_error! p, \"The flag #{flag} can have only one *. * is used... | [
"0.63841707",
"0.63714045",
"0.6068502",
"0.604452",
"0.6037222",
"0.59690166",
"0.59173846",
"0.588692",
"0.58787745",
"0.58622706",
"0.5849877",
"0.583896",
"0.5807509",
"0.5798447",
"0.5785396",
"0.57739323",
"0.57703257",
"0.57687217",
"0.5765563",
"0.57627016",
"0.575845... | 0.0 | -1 |
C: Is the single digit country code | def load_country_code(sections)
# For now we assume all phone numbers are USA centric. If we wish to support other country
# codes in the future we will need to enforce the presence of a country code when entering
# a phone number
return USA unless sections.first.length == 1
raise "Unsupported Country Code" unless COUNTRY_CODES.include?(sections.first)
sections.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country_code_alpha2\n country_code == 'EL' ? 'GR' : country_code\n end",
"def country_code\n cc = carmen_country\n\n cc ? \"#{cc.code.upcase}\" : nil\n end",
"def country_code\n @country_code.to_s\n end",
"def country_code\n decode hash[\"CountryCode\"]\n end",
"d... | [
"0.75659704",
"0.743822",
"0.7129545",
"0.70511544",
"0.7016695",
"0.7016695",
"0.69956106",
"0.69554996",
"0.69367754",
"0.69078064",
"0.6882226",
"0.68709755",
"0.68602145",
"0.68389374",
"0.67984563",
"0.67909163",
"0.67797333",
"0.67797333",
"0.67797333",
"0.67797333",
"0... | 0.61453706 | 77 |
NPA: Is the three digit area code | def load_area_code(sections)
return if sections.empty? || sections.first.length != 3
raise "invalid area code" unless sections.second&.length == 3
sections.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_code\n number[0..2]\n end",
"def north_american_area_code_for(some_number)\n some_number = clean(some_number)\n\n itu_code = parse_code(some_number)\n\n return nil if itu_code.nil? || !north_american?(itu_code)\n\n code = itu_code\n\n north_american_codes.each { |_, v| code... | [
"0.7461201",
"0.6923697",
"0.6481079",
"0.6362705",
"0.61572266",
"0.61572266",
"0.61035156",
"0.6085843",
"0.6050945",
"0.60254705",
"0.5970763",
"0.5955381",
"0.5949065",
"0.59439784",
"0.59212613",
"0.59085655",
"0.58808327",
"0.5879034",
"0.5853856",
"0.5813902",
"0.58060... | 0.53156 | 99 |
NXX: Subscriber prefix for the local central office | def load_prefix(sections)
return if sections.empty? || sections.first.length < 3
raise "invalid prefix" unless sections.second.to_s&.length >= 4
sections.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe_address\n address.split('@').join(\"-subscribe@\")\n end",
"def base_prefix\n HaridsyncHelpers.ensure_uppercase_dn_component(group['ou'] || DEFAULT_PREFIX)\n end",
"def prefix\n 'oai_dc' \n end",
"def general_prefix\n parts = []\n parts << label\n parts << ttl if ttl\n p... | [
"0.6616509",
"0.64829344",
"0.63628554",
"0.6213307",
"0.61588824",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.5985596",
"0.59708154",
"0.5906431",
"0.5890808",
"0.58396006",
"0.57766384",
"0.5776638... | 0.0 | -1 |
XXXX: Is the specific subscriber number | def load_subscriber(sections)
raise "invalid subscriber" unless sections.first&.length == 4
sections.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_subscribe?()\n \treturn !(self.phoneNumber.nil?)\n\tend",
"def subscriber?\n self.subscription.plan_id != nil && self.subscription.plan_id >= 1\n end",
"def has_subscriber?(user_id)\r\n self.subscribers.include?(user_id.to_i)\r\n end",
"def subscriber?(email_address)\n !subscriber... | [
"0.7238132",
"0.72134674",
"0.70263726",
"0.68242574",
"0.66986984",
"0.65762275",
"0.65564805",
"0.6528525",
"0.6526422",
"0.6522412",
"0.64857155",
"0.64778644",
"0.646712",
"0.646712",
"0.64646447",
"0.64598984",
"0.64586705",
"0.62836367",
"0.62742096",
"0.6266379",
"0.62... | 0.0 | -1 |
Lets us call simple ruby methods Ruby.IO_read(file) Ruby.puts('hi') Ruby.require('uri') | def invokeUndefinedMethodFromWebScript(name, withArguments:args)
if respond_to? name
send(name, *args)
elsif Kernel.respond_to? name
Kernel.send(name, *args)
elsif name =~ /^([A-Z][A-Za-z]+)_(.+)/
const = Kernel.const_get($1)
method = $2
if const.respond_to? method
const.send(method, *args)
elsif const.respond_to?("#{method}?")
const.send("#{method}?", *args)
elsif const.respond_to?("#{method}!")
const.send("#{method}!", *args)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(path); end",
"def read(*args) IO.read(path, *args) end",
"def read(*args)\n IO.read(@path, *args)\n end",
"def test_facade_io\n assert_respond_to(@fpath, :foreach)\n assert_respond_to(@fpath, :read)\n assert_respond_to(@fpath, :readlines)\n assert_respond_to(@fpath, :sysopen)... | [
"0.6673703",
"0.65724087",
"0.6401275",
"0.6357482",
"0.62268686",
"0.6164835",
"0.6100783",
"0.6070439",
"0.5953502",
"0.59466696",
"0.59466696",
"0.59466696",
"0.59466696",
"0.58967286",
"0.58693427",
"0.58693427",
"0.5863902",
"0.5863902",
"0.5863902",
"0.5863902",
"0.5863... | 0.0 | -1 |
Ruby('$LOAD_PATH') => array... Ruby('1 + 1') => 2 | def invokeDefaultMethodWithArguments(args)
eval(args[0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def to_ruby\n%{#!#{ File.join(rbconfig('bindir'), rbconfig('ruby_install_name')) }\n#\n# This file was generated by Mi... | [
"0.5320106",
"0.51867074",
"0.5132815",
"0.50947624",
"0.5088099",
"0.5066404",
"0.5013266",
"0.5010071",
"0.49687636",
"0.4967937",
"0.49582472",
"0.49564058",
"0.4908995",
"0.4908468",
"0.4880789",
"0.4879549",
"0.4869284",
"0.4865217",
"0.48410589",
"0.4835345",
"0.4831848... | 0.0 | -1 |
GET /players GET /players.xml | def index
# If the user is an admin, it loads all players by default, not just the active ones
@players = @players.joins(:team).where(:players => { :active => true }, :teams => { :active => true }) unless user_signed_in? && current_player.is_admin?
@players = @players.paginate(:page => params[:page])
# filter the players if the user limited the search to certain conditions
@player_params = filter_params
if @player_params.any?
# the email field is part of the users table, so map it accordingly
if @player_params[:email]
@players = @players.joins(:user).where(users: { email: @player_params[:email] })
end
player_fields = @player_params.dup
# We already processed the email, so ignore it
player_fields.delete(:email)
# We don't want an exact match, instead we would like to do a "starts with" comparison
conditions = [player_fields.keys.map { |field| "players.#{field} LIKE ?" }.join(' AND ')]
conditions += player_fields.values.map { |value| "#{value}%" }
@players = @players.where(*conditions)
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @players }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @players }\n end\n end",
"def index\n puts params.inspect\n @api_players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n forma... | [
"0.72922504",
"0.7263118",
"0.70862687",
"0.7037247",
"0.69708604",
"0.6885909",
"0.6816886",
"0.67661655",
"0.6748295",
"0.6728074",
"0.6703784",
"0.66162705",
"0.659559",
"0.65758777",
"0.6574077",
"0.6508855",
"0.64749986",
"0.6432559",
"0.642174",
"0.63565373",
"0.6356537... | 0.0 | -1 |
GET /players/1 GET /players/1.xml | def show
# show all the accepted infractions created by this player
@player_infractions = @player.infractions.accepted
# but hide the anonymous infractions when seeing by any person other than the creator
unless @player.user == current_user
@player_infractions = @player_infractions.where.not(anonymous: true)
end
# also show all the information regarding this player being a witness
@witnesses = @player.witnesses
@pending_witnesses = @witnesses.select { |witness| pending?(witness) }
@accepted_witnesses = @witnesses.select { |witness| accepted?(witness) }
@rejected_witnesses = @witnesses.select { |witness| rejected?(witness) }
if params['tooltip'].nil?
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @player }
end
else # show ajax tooltip
render :partial => 'shared/tooltip', :locals => {
:image => @player.avatar.url(:thumb), :simple_data => {
'Player name' => @player.full_name, 'Team' => @player.team.to_s
}, :collection => nil
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n puts params.inspect\n @api_players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @api_players }\n end\n end",
"def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n f... | [
"0.7151264",
"0.7148797",
"0.6967249",
"0.69646686",
"0.6842",
"0.6823654",
"0.68182886",
"0.67391425",
"0.66512305",
"0.6517467",
"0.65137875",
"0.6431865",
"0.6431117",
"0.64302284",
"0.6298674",
"0.62985486",
"0.6282829",
"0.6243095",
"0.6243095",
"0.6243095",
"0.6243095",... | 0.0 | -1 |
GET /players/new GET /players/new.xml | def new
@player.user = current_user
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @player }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def new\n @player = Player.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @player }\n e... | [
"0.74016696",
"0.74016696",
"0.74016696",
"0.74016696",
"0.74016696",
"0.71394205",
"0.6890059",
"0.68175906",
"0.6799033",
"0.67592144",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
... | 0.6597632 | 26 |
POST /players POST /players.xml | def create
@player = Player.new(player_params)
@player.user = current_user
# automatically create a new team for the user if there isn't one already
unless @player.team || @player.name.blank?
team = Team.find_or_initialize_by(name: "#{@player.name}'s Team", code: @player.name.upcase)
@player.team = team if team.save
end
respond_to do |format|
if @player.save
format.html { redirect_to(@player, :notice => 'Player was successfully created.') }
format.xml { render :xml => @player, :status => :created, :location => @player }
else
team.destroy if team
format.html { render :action => "new" }
format.xml { render :xml => @player.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Api::Player was successfully created.'\n format.html { redirect_to(@player) }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n ... | [
"0.63541746",
"0.63206035",
"0.62791467",
"0.6272312",
"0.617638",
"0.61691254",
"0.6136266",
"0.6127254",
"0.604063",
"0.60159147",
"0.5981008",
"0.5970689",
"0.5968838",
"0.5953603",
"0.59328616",
"0.59220684",
"0.591973",
"0.59063375",
"0.5903768",
"0.58991253",
"0.5897015... | 0.5619678 | 65 |
PUT /players/1 PUT /players/1.xml | def update
respond_to do |format|
if @player.update_attributes(player_params)
format.html { redirect_to(@player, :notice => 'Player was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @player.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update_attributes(params[:player])\n flash[:notice] = 'Player was successfully updated.'\n format.html { redirect_to(@player) }\n format.xml { head :ok }\n else\n format.html { rende... | [
"0.6518195",
"0.6518195",
"0.64573336",
"0.6432195",
"0.6350137",
"0.63201773",
"0.62731624",
"0.62502843",
"0.6207475",
"0.6164538",
"0.6144399",
"0.61200637",
"0.6075441",
"0.60736656",
"0.60673934",
"0.60672265",
"0.60672265",
"0.60672265",
"0.60672265",
"0.60672265",
"0.6... | 0.6350109 | 5 |
DELETE /players/1 DELETE /players/1.xml | def destroy
@player.user.destroy
respond_to do |format|
format.html { redirect_to(players_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(players_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n f... | [
"0.7140511",
"0.7140511",
"0.7140511",
"0.7140511",
"0.7140511",
"0.70677996",
"0.68334705",
"0.67315525",
"0.6675455",
"0.6625119",
"0.65786517",
"0.6490818",
"0.64758426",
"0.64732134",
"0.6432913",
"0.6432913",
"0.64187455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
... | 0.7024825 | 6 |
method to find the index of desired vowel, whether it be first or last vowel char_idx represents index for the letter that you want to start iterating at | def find_vowel_index(word, char_idx, count_direction)
vowel_index = char_idx
word.length.times do
if is_vowel?(word[char_idx])
vowel_index = char_idx
break
end
char_idx += count_direction
end
return vowel_index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_of_the_first_vowel(str)\n #v = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n #v.map { |c| [str.index(c)] }.first\n s = string.chars.count {|char| vowels.include? (char)}\nend",
"def vowel_indices(word)\n word.enum_for(:scan, /[aeiouy]/i).map { Regexp.last_match.offset(0).first + 1 }\nend",
"def indexOfVowe... | [
"0.75067115",
"0.7491045",
"0.7436783",
"0.7400599",
"0.7387604",
"0.73089206",
"0.7258034",
"0.7235617",
"0.72234875",
"0.7220279",
"0.7216102",
"0.7213291",
"0.71981895",
"0.7163101",
"0.71281564",
"0.7049705",
"0.7042665",
"0.7018124",
"0.70123214",
"0.6998974",
"0.6901769... | 0.81555533 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
function to process each line of a file and extract the song titles | def process_file(file_name)
puts "Processing File.... "
begin
if RUBY_PLATFORM.downcase.include? 'mswin'
file = File.open(file_name)
unless file.eof?
file.each_line do |line|
# do something for each line (if using windows)
# do not touch this! You have a Mac!
end
end
file.close
else
IO.foreach(file_name, encoding: "utf-8") do |line|
title = cleanup_title line
if title != nil
addtoB(title)
end
end
end
search = ""
# while search != "q" # continues while user doesn't enter 1
# puts("Enter a word [Enter 'q' to quit]:") # prompts for user input
# search = $stdin.gets.chomp # get input from user
# if (search != "q") # if they typed in q, we don't want to create a title
# print(create_title(search)) # creates and prints title
# end
# puts "" # extra line for prettiness! ~
# end
end
puts "Finished. Bigram model built.\n"
rescue
STDERR.puts "Could not open file"
exit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file\n #needs begin rescue exception handling \n \tbegin \n \t\traise FileNotFoundException.new(\"File not Found\") unless File.exists?(@file_path)\n\t\n \t\tFile.open(@file_path).slice_before(@delimiter).each do |chunk|\n \t\t\tchunk.reject! {|item| item =~ @delimiter }\n \t\ttitle = c... | [
"0.6714873",
"0.6630048",
"0.6611997",
"0.65586936",
"0.6512545",
"0.64183843",
"0.6374483",
"0.6367709",
"0.636028",
"0.63112456",
"0.62856114",
"0.6271064",
"0.62342274",
"0.6211231",
"0.6186046",
"0.61524856",
"0.6140001",
"0.61309475",
"0.60823405",
"0.6074228",
"0.603611... | 0.0 | -1 |
This method "cleans up" the title. In here, we remove the preceding characters, the additional characters that don't make up song titles but are present, strip all punctuation, and remove titles with nonenglish characters. | def cleanup_title(songTitle)
title = songTitle.gsub(/(.)+<SEP>/, "") # strips everything but title
title = title.gsub(/(([\(\[\{\\\/\_\-\:\"\`\+\=\*]|(feat\.)).*)/, "") # strips non-song title items
title = title.gsub(/[\?\¿\!\¡\.\;\&\@\%\#\|]/, "") # strips punctuation
if title =~ (/[^\x00-\x7F]+/) # eliminates (most) non-english titles
return nil
end
title = title.downcase # converts title to lowercase
return title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup_title(line)\n\t#deletes everything but the song title\n\tline.gsub!(/.+>/, '')\n\t#deletes superfluous text\n\tline.gsub!(/(\\(|\\[|\\{|\\\\|\\/|\\_|\\-|\\:|\\\"|\\`|\\+|\\=|\\*|feat\\.).+$/,'')\n\t\t#deletes punctuation\n\t\tline.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/,'')\n\t\t#determi... | [
"0.8250895",
"0.8169725",
"0.79890746",
"0.7648154",
"0.7614066",
"0.72484034",
"0.7181977",
"0.71770334",
"0.7167685",
"0.71130884",
"0.7018225",
"0.6974727",
"0.6948313",
"0.69473577",
"0.6934119",
"0.6820438",
"0.673152",
"0.673031",
"0.6650999",
"0.66297793",
"0.66297793"... | 0.8432576 | 0 |
In this function, we add the title to the bigram. We do this by adding the first word and creating its own hash, and adding the words that come directly after to its own hash map. We do this for every word that appears in the title, adding only the word following directly after. This tripped me up at first, as i tried adding every word behind the current word for the entire sentence. | def addtoB(title)
#title = "let's see what this is doing"
stops = [" a ", " an ", " and ", " by ", " for ", " from ", " in ", " of ", " on ", " or ", " out ", " the ", " to ", " width "] # list of stop words
for word in stops do # go through the stop words: if they exist in the sentence, we will...
title = title.gsub(word, " ") # changes word to NOTHING! Well, a space I guess. but still.
end
title_words = title.split(" ") # splits title into various words
while (title_words.length > 1)
first_word = title_words[0] # saves the first word to title bigram
next_wrd = title_words[1] # the next word in the title is the one we want to add
title_words = title_words[1..-1] # chops off the first word and proceeds through
if ($bigrams.has_key?(first_word)) # if we already have a key, we don't need a new hash
# do nothing
else
$bigrams[first_word] = Hash.new # if word hasn't been encountered before, give it a new hash
end
if ($bigrams[first_word].has_key?(next_wrd)) # if the next word exists for the current word...
$bigrams[first_word][next_wrd] = $bigrams[first_word][next_wrd] + 1 # then all we're doing is incrementing the count for that word by one.
else
$bigrams[first_word].merge!(next_wrd => 1) # otherwise, we will set the count of that word to one.
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_bigram(title)\n\t#eliminate stop words before creating bigram counts\n\tpattern = /a\\b|an\\b|and\\b|by\\b|for\\b|from\\b|in\\b|of\\b|on\\b|or\\b|out\\b|the\\b|to\\b|with\\b/ #\\b to match the end of the word so it doesnt grab an when the word is and\n\ttitle.gsub!(pattern,\"\")\n\n\ttitle_array = ti... | [
"0.78585094",
"0.74380904",
"0.7127775",
"0.70467144",
"0.6391681",
"0.6135563",
"0.6128655",
"0.6107555",
"0.61066437",
"0.6058284",
"0.6054686",
"0.6008358",
"0.5997587",
"0.5995167",
"0.59641355",
"0.5947776",
"0.59471",
"0.594637",
"0.5927017",
"0.59247243",
"0.5915286",
... | 0.81643814 | 0 |
this function finds the most common following word, if the word exists in the bigram hash map. If not, it returns nil and breaks out of the title consruction while loop. | def mcw(search)
if !$bigrams.has_key?(search) # if the search word doesn't exist in the bigram...
most_common = nil # we're going to return nil.
else most_common = $bigrams[search].max_by{|word, number| number}[0] # search for max by # of maxes
end
return most_common
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_frequent_word(string)\n hash = {}\n splitstring = string.split(\" \")\n splitstring.each {|element| element.downcase!}\n p splitstring\n splitstring.each{|element| if hash[element].nil?\n hash[element]=1\n else\n ... | [
"0.66333085",
"0.65915364",
"0.6535529",
"0.65190136",
"0.6506259",
"0.6469732",
"0.6431242",
"0.64109266",
"0.6405207",
"0.6391836",
"0.6369845",
"0.636951",
"0.6352801",
"0.6351449",
"0.63248354",
"0.63130134",
"0.6309259",
"0.63034236",
"0.62805134",
"0.6263435",
"0.626150... | 0.70501477 | 0 |
This function creates a song title beginning with a given word, based on the return values of the MCW function above. IT doesn't allow for titles longer than 20 words. | def create_title(word)
current = word
word_num = 1 # begin word number at one
title = "" # title begins as empty
title += word # add current word
while word_num !=20 # while we have less than 20 words...
if ($bigrams.has_key?(current)) # if the word exists in the bigram
if (mcw(current) == nil)
# do nothing and exit
word_num = 20
else
addition = mcw(current) # thing to add is mcw
title += " " # add space for readability
title += addition # add addition to the title
current = addition # set current to the new wordtitle += addition # add the mcw
word_num += 1 # increment by one and then go throuh
end
else word_num = 20 # otherwise, we exit
end
end
return title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_title(word)\n\t\t#prevents Nil.class errors\n\t\tsongTitle = ''\n\t\t#sets first word in title\n\t\tsongTitle = songTitle + word\n\t\tinWord = ''\n\t\tinWord = word\n\t\t#while loop set to 100000 to create a loop as a failsafe, but a song title should never get anywhere close to that large.\n\t\t(0..100... | [
"0.86625135",
"0.7790542",
"0.7706074",
"0.7446804",
"0.73739004",
"0.690948",
"0.66070724",
"0.66061556",
"0.6573464",
"0.6554424",
"0.6541823",
"0.65343",
"0.65020937",
"0.6355156",
"0.63534194",
"0.623167",
"0.6231402",
"0.62284875",
"0.6211667",
"0.6186175",
"0.6173618",
... | 0.77315557 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.