query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
DELETE /connectors/1 DELETE /connectors/1.json | def destroy
@connector.destroy
respond_to do |format|
format.html { redirect_to connectors_url, notice: 'Connector was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @url_connector = UrlConnector.find(params[:id])\n @url_connector.destroy\n\n respond_to do |format|\n format.html { redirect_to url_connectors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connector = Connector.find(params[:id])\n @connector.des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this could be optimized a tiny bit by only calling superclass.build_kiln but i am le tired | def build_kiln
@build_kiln ||= begin
retval = Hash.new { |hash,key| hash[key] = {} }
klasses = []
klass = self
while klass && klass <= UIView
klasses.unshift(klass)
klass = klass.superclass
end
klasses.each do |klass|
kiln_props = klas... | [
"def build_up\n end",
"def building_construct_abstract(bld)\n case bld.getType\n when :Stockpile\n max = df.world.buildings.other[:STOCKPILE].map { |s| s.stockpile_number }.max\n bld.stockpile_number = max.to_i + 1\n when :Civzone\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Represents the pick of some user and chosen coordinates String player Player picking a coordinate Integer x X coordinate Integer y Y coordinate Exceptions Throws InvalidPickException if player is not valid or if coordinate is out of boundaries | def pick(player, x, y)
fail InvalidPickException.new('Invalid pick') unless valid_pick?(x, y) &&
valid_player?(player)
@game_array[x][y] = PLAYER_MARKS[player.to_sym]
@current_player = if @current_player == :player1
:player2
... | [
"def acquire_player_choice\n output = [-1, -1]\n until valid_input?(output)\n puts \"#{@player_ordered_list[0].name} input x coordinate:\"\n output[0] = gets.chomp.to_i\n output[1] = find_y_coordinate(output[0])\n end\n output\n end",
"def promptAction()\n hasCoordinates = nil\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a hash containing the current state of the game, the current user able to do the next pick. If the last pick resulted in a winner the player is returned. | def current_state
result = { current_state: @game_array,
current_player: @current_player }
mark = winner_mark
if mark
result.merge!(winner: player_by_mark(mark).name)
end
result
end | [
"def winner\n return @winner\n end",
"def winner\n if no_pieces_for_player?(1)\n 2\n elsif no_pieces_for_player?(2)\n 1\n else\n nil\n end\n end",
"def find_winner\n\t\tset_win_hash\n\n\t\tif @win_hash[@p1].include?(@p2)\n\t\t\treturn @player2\n\t\telsif @win_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets player based on his mark | def player_by_mark(mark)
player = if PLAYER_MARKS.key(mark) == :player1
@player1
else
@player2
end
player
end | [
"def get_player(name)\n @players[name]\n end",
"def get_mark(player)\n puts \"#{player}, where would you place your mark ?\".center(50, ' ').center(59, '*')\n gets.chomp\n\n end",
"def find_player_by_student_id(student_id)\n self.players.each do |player|\n if player.user\n return playe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run will validate all inputs; returning on input failures, resolving declared dependencies, then delegate to the handlers call method with its valid inputs and resolved dependencies. Finally it ensure every response is a Response object. | def run(inputs = {}, container = Dry::Container.new)
response = resolve_inputs(inputs)
return response if response.failure?
valid_inputs = response.ok
resolve_dependencies(container)
handler = self.new(container)
result = handler.call(valid_inputs)
... | [
"def run\n @response ||= build_response catch_halt{ @handler.run }\n end",
"def run\n handlers.each do |info, handler|\n matches = matches_options?(info[:type], info[:regexp])\n break if matches && handler.call(options)\n end\n end",
"def try(handlers:, tape:, **args)\n\n handler... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Getting the description of the character from the awoiaf Wiki page. | def char_description(character)
html = open("https://awoiaf.westeros.org/index.php/#{character}")
doc = Nokogiri::HTML(html)
if doc.css("div.hatnote:first-child").empty? #|| doc.css(".mw-parser-output .hatnote:nth-child(2)").empty?
description = doc.css(".mw-parser-output > p:nth-child(2)").text.gsub!(/[^A-Za-z ,.... | [
"def description\n fetch('phobia.descriptions')\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def description\n\t # if the description exists\n\t # return it \n\t # else \n\t # scrape to get the description\n\t # return it\n\t # end\n\tend",
"def cha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checking to see if the character is still alive in the series by scraping the gameofthrones fandom site. | def char_alive?(user, result, character)
html = open("https://gameofthrones.fandom.com/wiki/#{character}")
doc = Nokogiri::HTML(html)
words = doc.css(".pi-item .pi-font a").text.split /(?=[A-Z])/
if words.include?("Alive")
puts "You are still alive!"
else
death = doc.css("div[data-source='Death'] .pi-font").te... | [
"def checks_passed?\n if blacklisted_wifi?\n puts \"Blacklisted Network; Won't go online\"\n return false\n end\n\n # we don't want to spam himawari's site more than once every 10 minutes while running on a schedule\n return false if by_schedule && now.min % 10 != 1\n\n if `fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dependences GET /dependences.json | def index
@dependences = Dependence.all
end | [
"def index\n @service_of_dependences = ServiceOfDependence.all\n end",
"def index\n @dependables = Dependable.all\n end",
"def index\n @dependents = Dependent.all\n end",
"def index\n @dependants = Dependant.all\n end",
"def index\n @depends = Depend.all\n end",
"def index\n @depe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /dependences/1 DELETE /dependences/1.json | def destroy
@dependence.destroy
respond_to do |format|
format.html { redirect_to dependences_url, notice: 'Dependence was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @depend.destroy\n respond_to do |format|\n format.html { redirect_to depends_url, notice: 'Depend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dependable.destroy\n respond_to do |format|\n format.html { redirect_to de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check active state condition id : skill ID | def skill_state_on(id)
if Skill_State_On[id]['include'] != nil
for i in Skill_State[id]['include']
return true if @state.include?(i)
end
end
if Skill_State[id]['set'] != nil
for i in Skill_State[id]['set']
return false unless @state.include?(i)
end
return true
... | [
"def guard_skill_id\r\n return 2\r\n end",
"def skill; $data_skills[(skill? ? current_action.item : last_skill).id]; end",
"def won?\n @state.id == 14\n end",
"def change_itskill_status_to_active\n @itskill = Itskill.find(params[:id])\n if @itskill\n @itskill.update_attributes(:status ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check inactive state condition id : skill ID | def skill_state_off(id)
if Skill_State_On[id]['include'] != nil
for i in Skill_State[id]['include']
return false if @state.include?(i)
end
end
if Skill_State[id]['set'] != nil
for i in Skill_State[id]['set']
return true unless @state.include?(i)
end
return false... | [
"def skill_state_on(id)\n if Skill_State_On[id]['include'] != nil\n for i in Skill_State[id]['include']\n return true if @state.include?(i)\n end\n end\n if Skill_State[id]['set'] != nil\n for i in Skill_State[id]['set']\n return false unless @state.include?(i)\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check active swithc condition id : skill ID | def skill_sw_on(id)
if Skill_Sw_On[id]['include'] != nil
for i in Skill_Sw_On[id]['include']
return true if $game_switches[i]
end
end
if Skill_Sw_On[id]['set'] != nil
for i in Skill_Sw_On[id]['set']
return false unless $game_switches[i]
end
return true
end
... | [
"def guard_skill_id\r\n return 2\r\n end",
"def skill; $data_skills[(skill? ? current_action.item : last_skill).id]; end",
"def attack_skill_id\r\n return 1\r\n end",
"def skill_can_use?(id)\n return @battler.skill_can_use?(id)\n end",
"def skill_learn?(skill_id)\n return @skills.include?(ski... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check inactive swithc condition id : skill ID | def skill_sw_off(id)
if Skill_Sw_Off[id]['include'] != nil
for i in Skill_Sw_Off[id]['include']
return true if $game_switches[i] == false
end
end
if Skill_Sw_Off[id]['set'] != nil
for i in Skill_Sw_Off[id]['set']
return false unless $game_switches[i] == false
end
... | [
"def skill_sw_on(id)\n if Skill_Sw_On[id]['include'] != nil\n for i in Skill_Sw_On[id]['include']\n return true if $game_switches[i]\n end\n end\n if Skill_Sw_On[id]['set'] != nil\n for i in Skill_Sw_On[id]['set']\n return false unless $game_switches[i]\n end\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check variable condition id : skill ID | def skill_var(id)
for var in Skill_Var[id]
return true if eval("$game_variables[#{var[0]}] #{var[1]}")
end
return false
end | [
"def guard_skill_id\r\n return 2\r\n end",
"def skill_learn?(skill_id)\n return @skills.include?(skill_id)\n end",
"def skill; $data_skills[(skill? ? current_action.item : last_skill).id]; end",
"def attack_skill_id\r\n return 1\r\n end",
"def skill_can_use?(id)\n return @battler.skill_can_us... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check HP condition id : skill ID | def skill_hp(id)
if Skill_Hp[id]['integer'] != nil
return true if eval("self.hp #{Skill_Hp[id]['integer']}")
end
if Skill_Hp[id]['rate'] != nil
return true if eval("(self.hp * 100 / self.maxhp) #{Skill_Hp[id]['rate']}")
end
return false
end | [
"def guard_skill_id\r\n return 2\r\n end",
"def attack_skill_id\r\n return 1\r\n end",
"def pokemon_skill_index(id)\n has_skill?(id, true)\n end",
"def skill; $data_skills[(skill? ? current_action.item : last_skill).id]; end",
"def skill_effect_scope(skill)\r\n # If skill scope is for all... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check SP condition id : skill ID | def skill_sp(id)
if Skill_Sp[id]['integer'] != nil
return true if eval("self.sp #{Skill_Sp[id]['integer']}")
end
if Skill_Sp[id]['rate'] != nil
return true if eval("(self.sp * 100 / [self.maxsp, 1].max) #{Skill_Sp[id]['rate']}")
end
return false
end | [
"def guard_skill_id\r\n return 2\r\n end",
"def skill; $data_skills[(skill? ? current_action.item : last_skill).id]; end",
"def attack_skill_id\r\n return 1\r\n end",
"def skill(skill_id)\n skills.select { |skill| skill.real_id == skill_id.to_i}.first\n end",
"def skill_learn?(skill_id)\n ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that takes the name of a file and loads in the stop words from the file. You could return a list from this function, but a hash might be easier and more efficient. (Why? Hint: think about how you'll use the stop words.) | def load_stopwords_file(file)
stop_words = {}
# Looping through the file and adding each word to a hash table after chomping them
File.open(file, "r").each_line do |line|
stop_words[line.chomp] = 1
end
return stop_words
end | [
"def load_stopwords_file(file)\r\n stop_words = Hash.new(0)\r\n file = File.open(file, \"r\")\r\n file.readlines.each do |word|\r\n stop_words[word.chomp] = 1\r\n end\r\n\r\n file.close\r\n return stop_words\r\nend",
"def load_stopwords_file(file) \r\n\r\n\r\n stop_words = Hash.new(0)\r\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that takes the name of a directory, and returns a list of all the filenames in that directory. | def list_files(dir)
# Getting all the files names in the directory
file_names = Dir[dir + "*"]
return file_names
end | [
"def get_filenames(dir)\n Dir.entries(dir).select {|f| !File.directory? f}\n end",
"def list_files_in_directory dir\n files = Dir.glob File.join(dir, \"*\")\n\n normalized_file_list files, false, @options.exclude\n end",
"def get_full_filenames(directory=PROJECTS_PATH)\n files = Dir.chdir(director... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
CUSTOM FUNCTIONS parse_html takes the HTML code of a document and removes all the junk from it in order to return the text content on the page | def parse_html(html)
doc = Nokogiri::HTML(html)
# Removing style and script tag content such as Javascript tags in order to get rid of JUNK text
doc.xpath("//script").remove
doc.xpath("//style").remove
begin
text = doc.at('body').inner_text
rescue NoMethodError
puts "NoMethodError"
# puts file_... | [
"def parse\n #use regex to split\n arr = @html_string.scan(TAGS_AND_TEXT).flatten\n\n #remove nil values and return\n arr.compact!\n\n #remove white spaces\n arr.map! { |s| s.strip}\n end",
"def strip_tags(html) \n\t\t\t\t\treturn html if html.blank?\n\t\t\t\t\tif html.index(\"<\")\n\t\t\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
remove_punc takes a string containing text and removes all the punctuation from it in order to finally return a list of words/tokens in the text | def remove_punc(text)
word_list = []
# Checking for correct encoding and reencoding the string if necessary
if ! text.valid_encoding?
text = text.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
end
# Removing puctuation
words = text.split(/[ ,;{}`~!@#$%^&*<>.:"'|?\\()_+=\/\[... | [
"def remove_punctuation\n gsub /[[:punct:]]/, ''\n end",
"def removeQuotesAndPunc sentence\n\t\tquotes = [\"\\\"\",\"'\",\":\",\",\",\".\",\"(\",\")\",\";\",\"!\",\"&\",\"<\",\">\",\"?\",\"-\",\"_\"]\n\t\twords = sentence.split(' ')\n\t\twords.map! do |w|\n\t\t\tw.slice!(1) if quotes.include?(w[0])\n\t\t\tw.s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that takes the name of an html file stored on disk, and returns a list of tokens (words) in that file. | def find_tokens(filename)
html = File.read(filename)
# Parsing the HTML content of the file
parsed_html = parse_html(html)
# Converting the text into a list of tokens after removing punctuation
tokens = remove_punc(parsed_html)
return tokens
end | [
"def find_tokens(filename)\n return clean_string_list(convert_html_to_list(filename))\nend",
"def find_tokens(filename)\n word_list = []\n rr = Nokogiri::HTML(open(filename))\n rr.css('script, style').each { |node| node.remove }\n words = rr.css('body').text.encode!('UTF-8', :invalid=>:replace).split(/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that takes a list of tokens, and a list (or hash) of stop words, and returns a new list with all of the stop words removed | def remove_stop_tokens(tokens, stop_words)
# Looping through the list of tokens and removing all the stop words from the list
for i in tokens
if stop_words.member?(i)
tokens.delete(i)
end
end
return tokens
end | [
"def remove_stop_tokens(tokens, stop_words)\n \n stop_words.each do |stop|\n tokens.delete(stop)\n end\n\n return tokens\nend",
"def remove_stop_tokens(tokens, stop_words)\n stop_words.each do |word|\n if tokens.include?(word)\n tokens.delete(word)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that takes a list of tokens, runs a stemmer on each token, and then returns a new list with the stems | def stem_tokens(tokens)
stem_list = []
# Looping through the list and finding the stem word for each word
for word in tokens
word = word[/\w*/]
s = word.stem
stem_list.push(s)
end
return stem_list
end | [
"def stem_tokens(tokens)\n stem_tokens = Array.new\n tokens.each do |token|\n stem_tokens.push(Stemmer::stem_word(token))\n end\n return stem_tokens\nend",
"def stem_tokens(tokens)\r\n stem_tokens = Array.new\r\n\r\n tokens.each do |token|\r\n stem_tokens.push(Stemmer.s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get_file_detials takes a file name containg the index and returns the data of the file i.e. its name and url in a hash table | def get_file_details(file_name)
fd = {}
# Looping through the file and updating the name and url variable with the new data
# and then finally adding them to the hash table
File.readlines(file_name).each do |line|
data = line.split(" ")
puts data[2]
name = data[0]
url = data[2]
fd[n... | [
"def file_location(index)\n r = {}\n files = @info_hash['files']\n piece_bytes = @info_hash['piece length']\n\n prev_bytes = calc_file_lengths(files.take(index))\n file_bytes = files[index]['length']\n post_bytes = calc_file_lengths(files.drop(index + 1)) \n\n # Not adding one to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterate over each bigram as an instance of Bigram. | def each
@table.each do |pair, bigram|
yield(bigram)
end
end | [
"def each\n scanner.each_bigram do |bigram|\n yield(bigram)\n end\n end",
"def printBigram\n\t$bigrams.each do |i|\n\t\tputs \"#{i}\"\n\tend\nend",
"def bigram\n\n\t\tend",
"def load_bigrams\n bigrams = []\n\n begin\n sql = \"SELECT bigram_id, word1, word2, count F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a list of second words of bigrams matching the given first word. | def matching_bigrams(word1)
list = @index[word1]
list.map{ |word2| @table[[word1,word2]] }
end | [
"def matching_bigrams(word1)\n list = scanner.bigrams[word1]\n list.values\n end",
"def find_bigrams(str, bigrams)\n letters = str.split(\"\")\n pairs = []\n (0...letters.length-1).each do |idx|\n pairs << letters[idx] + letters[idx+1]\n end\n bigrams.select { |bigram| pai... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Probability of bigram's occurance in the corpus. | def probability(word1, word2=nil)
bigram = (Bigram === word1 ? word1 : get(word1, word2))
BigDecimal.new(bigram.count) / total #size
end | [
"def probability(word1, word2=nil)\n bigram = (Bigram === word1 ? word1 : get(word1, word2))\n BigDecimal.new(bigram.count) / size\n end",
"def compute_probabilities\n @tag_trigrams.each do |tritags, count|\n @trigram_probs [tritags] = count.to_f / @tag_bigrams[t2b(tritags)].to_f\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if a given word should be considered an acceptable bigram. | def good_bigram?(word)
return false if REJECT_BIGRAMS.include?(word)
return false if word.size < 2
true
end | [
"def good_bigram?(word)\n return false if REJECT_BIGRAMS.include?(word)\n return false if word.size < 2\n true\n end",
"def validate_word(word)\n return false if word.nil?\n\n word = normalize_word(word)\n word.length <= MAX_WORD_LENGTH && word =~ /^[a-z]{2,}$/\n end",
"def valid_wor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether a single unique match was found. | def found_unique?
@flags.size == 1
end | [
"def match?\n @match\n end",
"def unique?\n check = nil\n is_unique { |pipe| check = pipe }.each do\n return false unless check.isUnique\n end\n true\n end",
"def include?(match)\n any? { |m| m.eql?(match) }\n end",
"def unique?\n @unique\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether multiple matches were found (i.e. ambiguous input). | def found_multiple?
@flags.size > 1
end | [
"def match_all(args)\n args.all?{|arg| match(arg)}\n end",
"def matched?( other = nil )\n return full? if other.nil?\n matches.include? other\n end",
"def all_matches_accepted?(matches)\n matches_accepted = true\n\n matches.each do |match|\n if match.p1_accepted == false ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return whether the unique match was a hit on the negative (`no`) case, or `nil` if not found or not unique. | def unique_flag_negative?
found_unique? ? @flags.first[2] : nil
end | [
"def found_unique?\n @flags.size == 1\n end",
"def select?(record)\n return true unless match\n not match =~ record.to_s\n end",
"def negative_match?(rule, search_criteria)\n rule.criteria.any? do |criterium, values|\n values.is_a?(Hash) && values[:not]&.any?(searc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of the matching full flag strings. | def matching_flag_strings
@flags.map do |_flag, flag_syntax, negative|
negative ? flag_syntax.negative_flag : flag_syntax.positive_flag
end
end | [
"def flags_names\n flags_list(true)\n end",
"def get_flags(*files)\n matches = []\n begin\n files.each do |f|\n file = File.new(f, 'r')\n while (line = file.gets)\n m = line.match(/(^.*=)?/)\n matches << m[0] if m\n end\n file.close\n end\n rescue => err\n puts 'E... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether to include short flags | def include_short?
@include_short
end | [
"def short_flag_syntax\n @short_flag_syntax ||= flag_syntax.find_all { |ss| ss.flag_style == :short }\n end",
"def short_flag_exist?(flag)\n flags.select { |f| f.short == flag }.any?\n end",
"def extract_short_flag(objects, config); end",
"def short_flag_exist?(flag)\n flags.any? { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether to include long flags | def include_long?
@include_long
end | [
"def long_flag_syntax\n @long_flag_syntax ||= flag_syntax.find_all { |ss| ss.flag_style == :long }\n end",
"def extract_long_flag(objects, config); end",
"def long\n @long.present? ? \"--#{@long}\" : nil\n end",
"def flags\n [long, negative_long, short].compact\n end",
"def flags... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
An array of Flag::Syntax including only short (single dash) flags. | def short_flag_syntax
@short_flag_syntax ||= flag_syntax.find_all { |ss| ss.flag_style == :short }
end | [
"def dashed_flags *settings_and_names\n settings_and_names.map{|args| dashed_flag_for(*args) }.compact\n end",
"def matching_flag_strings\n @flags.map do |_flag, flag_syntax, negative|\n negative ? flag_syntax.negative_flag : flag_syntax.positive_flag\n end\n end",
"def flags... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
An array of Flag::Syntax including only long (doubledash) flags. | def long_flag_syntax
@long_flag_syntax ||= flag_syntax.find_all { |ss| ss.flag_style == :long }
end | [
"def matching_flag_strings\n @flags.map do |_flag, flag_syntax, negative|\n negative ? flag_syntax.negative_flag : flag_syntax.positive_flag\n end\n end",
"def flags\n return [] unless options[\"flags\"]\n options[\"flags\"].map do |options|\n Flag.new options\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The list of all effective flags used. | def effective_flags
@effective_flags ||= flag_syntax.flat_map(&:flags)
end | [
"def all_flags\n my_flags = @flag_objects || []\n my_flags += self.superclass.all_flags if self.superclass < HasFlags::InstanceMethods\n return my_flags\n end",
"def get_all_flags\n Flag.all\n end",
"def flags_names\n flags_list(true)\n end",
"def flags\n @flags\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up the flag by string. Returns an object that indicates whether the given string matched this flag, whether the match was unique, and other pertinent information. | def resolve(str)
resolution = Resolution.new(str)
flag_syntax.each do |fs|
if fs.positive_flag == str
resolution.add!(self, fs, false, true)
elsif fs.negative_flag == str
resolution.add!(self, fs, true, true)
elsif fs.positive_flag.start_with?(str)
resol... | [
"def resolve_flag(str)\n result = Flag::Resolution.new(str)\n flags.each do |flag_def|\n result.merge!(flag_def.resolve(str))\n end\n result\n end",
"def find_flaggable(flaggable_str, flaggable_id)\n model = flaggable_str.constantize\n model.respond_to?(:find_flags_for)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A list of canonical flag syntax strings. | def canonical_syntax_strings
@canonical_syntax_strings ||= flag_syntax.map(&:canonical_str)
end | [
"def matching_flag_strings\n @flags.map do |_flag, flag_syntax, negative|\n negative ? flag_syntax.negative_flag : flag_syntax.positive_flag\n end\n end",
"def flags_names\n flags_list(true)\n end",
"def scm_flags\n @flags.join(\" \")\n end",
"def complete_flags cmd\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether this flag is activethat is, it has a nonempty flags list. | def active?
!effective_flags.empty?
end | [
"def flags?\n !@flags.empty?\n end",
"def complete_flags?\n @complete_flags\n end",
"def flags_allowed?\n @flags_allowed\n end",
"def global_flags?\n flags.any? and commands.any?\n end",
"def flag?(flags)\n (all_flags & flags) != 0\n end",
"def is_flagged?\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /agencyfeed.json Get all the agency feed available | def index
@agencyfeeds = AgencyFeed.all
render :index, status: :ok
end | [
"def index\n @hosted_feeds = HostedFeed.all\n end",
"def show_all_posts\n feed_urls = Feed.all.collect(&:feed_url)\n @posts = fetch_all_feeds_posts(feed_urls)\n\n respond_to do |format|\n format.html\n format.json { render json: @feeds }\n end\n end",
"def index\n @feed_sources = F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /agencyfeed.json Create agency with params | def create
@agencyfeed = AgencyFeed.create! agencyfeed_params
render :show, status: :created
end | [
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT/PATCH agencyfeed.json update the configuration of agency and category | def update
@agencyfeed.update! agencyfeed_params
render :show, status: :ok
end | [
"def update\n @refagencycategory = Refagencycategory.find(params[:id])\n\n respond_to do |format|\n if @refagencycategory.update_attributes(params[:refagencycategory])\n format.html { redirect_to @refagencycategory, notice: 'Refagencycategory was successfully updated.' }\n format.json { hea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /agencyfeed/:id/fetch_news.json fetch all the news and update db for a specific agencyfeed. | def fetch_news
@news = News.fetch_and_store_news! @agencyfeed
render template: 'news/list', status: :ok
end | [
"def fetch\n ##\n # an array of { category_id: number, news: array }\n @fetched = News.fetch_and_store_news_from_all_agency_feed!\n render :fetch, status: :ok\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns "STANDARD_CLAIM_PROCESS", "BDD_PROGRAM", or "FDC_PROGRAM" based off of a few attributes in the evss data | def evss_claims_process_type(form526)
if form526['bddQualified']
return 'BDD_PROGRAM'
elsif form526['standardClaim']
return 'STANDARD_CLAIM_PROCESS'
end
'FDC_PROGRAM'
end | [
"def get_system(code)\n return code[2][1][0][1][1][1]\n end",
"def proquest_processing_code\n case submitting_type.first\n when \"Dissertation\"\n \"F\"\n when \"Master's Thesis\"\n \"O\"\n else\n \"F\"\n end\n end",
"def proc_name\n data = read_cpuinfo.matc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns either 'Active', 'Reserves' or 'National Guard' based on the service branch | def convert_to_service_component(service_branch)
service_branch = service_branch.downcase
return 'Reserves' if service_branch.include?('reserves')
return 'National Guard' if service_branch.include?('national guard')
'Active'
end | [
"def hca_branch_of_service\n HCA_SERVICE_BRANCHES[branch_of_service_code] || 'other'\n end",
"def determine_branch_type(branch)\n return branch if (branch.downcase == \"develop\")\n branch =~ /^([a-zA-Z]+)-/\n if $1 && (%w(rc hotfix).member? $1.downcase)\n return $1.downcase\n else\n raise \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /variant_images GET /variant_images.json | def index
@variant_images = VariantImage.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @variant_images }
end
end | [
"def variant_image(variant)\n variant_image = shopify_images.detect { |image| image.variant_ids.include?(variant.id) }\n return if variant_image.blank?\n\n variant_image.to_json\n end",
"def get_variant\n @product = Spree::Product.find_by :slug => params[:product_id]\n @var... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /variant_images/1 GET /variant_images/1.json | def show
@variant_image = VariantImage.find(params[:id])
@variant = @variant_image.variant
respond_to do |format|
format.html # show.html.erb
format.js
format.json { render json: @variant_image }
end
end | [
"def index\n @variant_images = VariantImage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @variant_images }\n end\n end",
"def show\n @image_variant = ImageVariant.cs(self.current_scope).find(params[:id])\n \n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /variant_images/new GET /variant_images/new.json | def new
@variant_image = VariantImage.new
@variant = Variant.find(params[:variant_id])
@variant_image.variant_id = @variant.id
@product = @variant.product
respond_to do |format|
format.html # new.html.erb
format.js # new.js.erb
format.json { render json: @variant_image }
end
... | [
"def new\n @image_variant = ImageVariant.cs(self.current_scope).new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_variant }\n end\n end",
"def new\n @title = t('view.images.new_title')\n @image = Image.new\n\n respond_to do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /variant_images POST /variant_images.json | def create
params[:variant_image][:image2] = params[:variant_image][:image] # For image replication across two s3 accounts
@variant_image = VariantImage.new(params[:variant_image])
@variant = @variant_image.variant
@product = @variant.product
respond_to do |format|
if @variant_image.save
... | [
"def create\n @image_variant = ImageVariant.cs(self.current_scope).new(params[:image_variant])\n \n respond_to do |format|\n if @image_variant.save\n format.html { redirect_to @image_variant, notice: 'Image variant was successfully created.' }\n format.json { render json: @image_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /variant_images/1 PUT /variant_images/1.json | def update
@variant_image = VariantImage.find(params[:id])
respond_to do |format|
if @variant_image.update_attributes(params[:variant_image])
format.html { redirect_to @variant_image, notice: 'Variant image was successfully updated.' }
format.json { head :ok }
else
format.ht... | [
"def update\n @image_variant = ImageVariant.cs(self.current_scope).find(params[:id])\n \n respond_to do |format|\n if @image_variant.update_attributes(params[:image_variant])\n format.html { redirect_to @image_variant, notice: 'Image variant was successfully updated.' }\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /variant_images/1 DELETE /variant_images/1.json | def destroy
@variant_image = VariantImage.find(params[:id])
@variant = @variant_image.variant
@variant_image.destroy
respond_to do |format|
format.html { redirect_to @variant.product }
format.json { head :ok }
end
end | [
"def destroy\n @image_variant = ImageVariant.cs(self.current_scope).find(params[:id])\n @image_variant.destroy\n \n respond_to do |format|\n format.html { redirect_to image_variants_url }\n format.json { head :ok }\n end\n end",
"def delete_floor_plan(args = {}) \n delete(\"/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an absolute path within the working directory. The working directory is determined: value of BREWED_WORKING_DIR env var When run_mode is :daemon, the working dir is state_dir. Otherwise, the current directory. | def working_dir(*path)
if _working_dir.nil?
@_working_dir = ENV['PROJECT_WORKING_DIR']
if _working_dir != nil
@_working_dir = Pathname.new(expand_variables _working_dir)
Dir.chdir _working_dir.to_s
elsif run_mode == :daemon
@_working_dir = state_dir
... | [
"def working_dir\n ENV['PWD'] || Dir.pwd\n end",
"def working_dir\n ENV['PWD'] || Dir.pwd\n end",
"def working_dir\n if chatterbot_helper?\n Dir.getwd\n else\n File.dirname($0)\n #Dir.pwd\n end\n end",
"def working_directory\n @op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provide the absolute path to this Brewed's lib dir. | def libdir()
LIBDIR
end | [
"def lib_path\n File.dirname(File.expand_path(__FILE__))\n end",
"def lib_path\n File.expand_path '..', File.dirname(__FILE__)\n end",
"def lib\n path '/lib'\n end",
"def _lib_dir\n File.join(get_pref(\"sketchbook.path\"), \"libraries\")\n end",
"def lib_dir\n Fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=============================================================================== Moon phases and Zodiac =============================================================================== Calculates the phase of the moon. 0 New Moon 1 Waxing Crescent 2 First Quarter 3 Waxing Gibbous 4 Full Moon 5 Waning Gibbous 6 Last Quart... | def moonphase(time=nil) # in UTC
time = pbGetTimeNow if !time
transitions = [
1.8456618033125,
5.5369854099375,
9.2283090165625,
12.9196326231875,
16.6109562298125,
20.3022798364375,
23.9936034430625,
27.6849270496875]
yy = time.year-((12-time.mon)/10.0).floor
j = (365.25... | [
"def calcphase(arg)\n \n # some constants to allow for the moon phase calculation. although, using local variables.\n ages = [18, 0, 11, 22, 3, 14, 25, 6, 17, 28, 9, 20, 1, 12, 23, 4, 15, 26, 7]\n offsets = [-1, 1, 0, 1, 2, 3, 4, 5, 7, 7, 9, 9]\n description = [\"new (totally dark)\",\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates the zodiac sign based on the given month and day: 0 is Aries, 11 is Pisces. Month is 1 if January, and so on. | def zodiac(month,day)
time = [
3,21,4,19, # Aries
4,20,5,20, # Taurus
5,21,6,20, # Gemini
6,21,7,20, # Cancer
7,23,8,22, # Leo
8,23,9,22, # Virgo
9,23,10,22, # Libra
10,23,11,21, # Scorpio
11,22,12,21, # Sagittarius
12,22,1,19, # Capricorn
1,20,2,1... | [
"def find_zodiac_sign(birthdate)\n bday_split = birthdate.split(\"/\")\n return Date.new(bday_split[0].to_i,bday_split[1].to_i,bday_split[2].to_i).zodiac_sign\nend",
"def zday; '%02d' % mday; end",
"def zmonth; '%02d' % month; end",
"def zodiacOpposite(sign)\n return (sign+6)%12\nend",
"def absolute_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the opposite of the given zodiac sign. 0 is Aries, 11 is Pisces. | def zodiacOpposite(sign)
return (sign+6)%12
end | [
"def reverse_sign(an_integer)\n return 0 - an_integer\nend",
"def opposite(number)\n 0 - number\nend",
"def opposite(number)\n return 0 - number\nend",
"def flip_sign\n self * -1\n end",
"def get_sign(coefficient)\r\n if coefficient < 0\r\n '-'\r\n else \r\n '+' \r\n end\r\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
unmark a lineitem for refulfillment, chose not to increment the inventory count due possibility that inventory was refreshed, better to err on side of less inventory | def unrefulfill_line_item(line_item_id)
li = Spree::LineItem.find(line_item_id)
li.refulfill = nil
li.save
end | [
"def decrease_ingredients_stock line_items\n line_items.each do |item|\n (item.ingredients + Product.find(item.product_id).ingredients).each do |ingredient|\n ingredient.update_column(:quantity, ingredient.quantity - 1)\n if ingredient.quantity == 0\n ingredient.update_column(:active,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the current rockreleasebased prefix for rock packages | def rock_release_prefix(release_name = nil)
release_name ||= rock_release_name
if release_name
pkg_prefix_base + "-#{release_name}-"
else
pkg_prefix_base + "-"
end
end | [
"def rock_release_prefix(release_name = nil)\n release_name ||= rock_release_name\n pkg_prefix_base + \"-#{release_name}-\"\n end",
"def rock_ruby_release_prefix(release_name = nil)\n rock_release_prefix(release_name) + \"ruby-\"\n end",
"def ro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the current rockreleasebased prefix for rock(ruby) packages | def rock_ruby_release_prefix(release_name = nil)
rock_release_prefix(release_name) + "ruby-"
end | [
"def rock_release_prefix(release_name = nil)\n release_name ||= rock_release_name\n pkg_prefix_base + \"-#{release_name}-\"\n end",
"def rock_release_prefix(release_name = nil)\n release_name ||= rock_release_name\n if release_name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a debian package name from a given plain name according to build type, release name and release_prefix setting | def debianize_name(name, build_type: :cmake, with_rock_release_prefix: true, release_name: rock_release_name)
if build_type == :ruby
if with_rock_release_prefix
rock_release_prefix(release_name) + "ruby-" + Deb.canonize(name)
... | [
"def debian_meta_name(name, with_rock_release_prefix = true)\n if with_rock_release_prefix\n rock_release_prefix + canonize(name)\n else\n pkg_prefix_base + \"-\" + canonize(name)\n end\n end",
"def package_name(buildno=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The debian name of a meta package rock[]meta and the releasename can be avoided by setting with_rock_release_prefix to false | def debian_meta_name(name, with_rock_release_prefix = true)
if with_rock_release_prefix
rock_release_prefix + "meta-" + Deb.canonize(name)
else
pkg_prefix_base + "meta-" + Deb.canonize(name)
end
e... | [
"def debian_meta_name(name, with_rock_release_prefix = true)\n if with_rock_release_prefix\n rock_release_prefix + canonize(name)\n else\n pkg_prefix_base + \"-\" + canonize(name)\n end\n end",
"def debian_name(pkg)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The debian name of a package [rock]ruby and the releasename prefix can be avoided by setting with_rock_release_prefix to false | def debian_ruby_name(name, with_rock_release_prefix = true, release_name = nil)
if with_rock_release_prefix
rock_ruby_release_prefix(release_name) + Deb.canonize(name)
else
"ruby-" + Deb.canonize(name)
end
... | [
"def debian_meta_name(name, with_rock_release_prefix = true)\n if with_rock_release_prefix\n rock_release_prefix + canonize(name)\n else\n pkg_prefix_base + \"-\" + canonize(name)\n end\n end",
"def debian_ruby_name(name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Commit changes of a debian package using dpkgsource commit in a given directory (or the current one by default) | def dpkg_commit_changes(patch_name, directory = Dir.pwd,
prefix: "apaka-",
logfile: nil,
include_removal: false
)
Dir.chdir(directory) do
... | [
"def dpkg_commit_changes(patch_name, directory = Dir.pwd)\n Dir.chdir(directory) do\n Packager.debug (\"commit changes to debian pkg: #{patch_name}\")\n # Since dpkg-source will open an editor we have to\n # take this approach to make it pass d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the debian/ subfolder cindlugin control/rules/install files to prepare the debian package build instructions | def generate_debian_dir(pkginfo, dir, options)
options, unknown_options = Kernel.filter_options options,
:distribution => nil,
:override_existing => true,
:patch_dir => nil
distribution = options[:distributi... | [
"def create_control_files\n sh \"dpkg-gencontrol\"\n end",
"def install_management\n # Needed to play with the configuration database.\n package 'debconf'\n package 'debconf-utils'\n\n # Keys for Debian packages.\n package 'debian-archive-keyring'\n\n # Fetch files via HTTP.\n pac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the debian_dir for a meta package i.e. representing a package set or a full release return [String] the main packages directory | def generate_debian_dir_meta(name, depends, base_dir: Dir.pwd, version: "0.1", distribution: nil)
existing_debian_dir = File.join("#{name}-#{version}","debian-meta")
template_dir =
if File.directory?(existing_debian_dir)
existin... | [
"def generate_debian_dir(pkginfo, dir, options)\n options, unknown_options = Kernel.filter_options options,\n :distribution => nil,\n :override_existing => true,\n :patch_dir => nil\n\n distribution = options[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A tar gzip version that reproduces same checksums on the same day when file content does not change Required to package orig.tar.gz | def tar_gzip(archive, tarfile, pkg_time, distribution = nil,
logfile: nil)
# Make sure no distribution information leaks into the package
if distribution and archive =~ /~#{distribution}/
archive_plain_name = archive.gsub(/~#{d... | [
"def tar_gzip(archive, tarfile, pkg_time, distribution = nil)\n\n # Make sure no distribution information leaks into the package\n if distribution and archive =~ /~#{distribution}/\n archive_plain_name = archive.gsub(/~#{distribution}/,\"\")\n File... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the debian directory with overlay and env.sh/env.yml | def update_debian_dir(pkginfo, options)
# Generate the debian directory
generate_debian_dir(pkginfo, pkginfo.srcdir, options)
if options[:patch_dir] && File.exist?(options[:patch_dir])
if patch_pkg_dir(pkginfo.name, options[:patch_dir]... | [
"def setup debian_repository\n write_config debian_repository\n restart\n end",
"def etc_update \n announcing 'Running etc-update' do\n system(\"chroot #{$chrootdir} /scripts/run.sh update_configs\")\n end\n send_to_state('build', 'etc_update')\n end",
"def apt_update(vm)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Install package name, where pkg is the debian package name | def install(pkg_name)
begin
pkg_build_dir = packaging_dir(pkg_name)
filepath = Dir.glob("#{pkg_build_dir}/*.deb")
if filepath.size < 1
raise RuntimeError, "No debian file found for #{pkg_name} in #{pk... | [
"def install_package host, package_name\n host.install_package package_name\n end",
"def install_package host, package_name, package_version = nil\n host.install_package package_name, '', package_version\n end",
"def package_if_necessary(pkg)\n if !package_is_installed?(pkg)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute the ruby arch setup for passing through sed escaping is required for using with file rendering no escaping is required | def ruby_arch_setup(do_escape = false)
Packager.info "Creating ruby env setup"
if do_escape
setup = Regexp.escape("arch=$(shell gcc -print-multiarch)\n")
# Extract the default ruby version to build for on that platform
... | [
"def ruby_arch_setup(do_escape = false)\n Packager.info \"Creating ruby env setup\"\n if do_escape\n setup = Regexp.escape(\"arch=$(shell gcc -print-multiarch)\\n\")\n # Extract the default ruby version to build for on that platform\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define the default compat level | def set_compat_level(compatlevel = DEBHELPER_DEFAULT_COMPAT_LEVEL, compatfile = "debian/compat")
if File.exist?(compatfile)
existing_compatlevel = `cat #{compatfile}`.strip
Packager.warn "Apaka::Packaging::Debian::set_compat_level: existing '#{compatfi... | [
"def compat\n\t\tmodule_info['Compat'] || {}\n\tend",
"def compatibility_mode(compatibility = 1)\n @compatibility = compatibility\n end",
"def compatibility_mode=(value)\n @compatibility_mode = value\n end",
"def custom_compatibility_version\n @custom_compatibility_version\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute the build dependencies for a packag info object return [Array] list of dependencies | def build_dependencies(pkginfo)
dependencies = []
pkgdeps = pkginfo.dependencies
deps = pkgdeps[:rock_pkginfo].select do |pkginfo|
pkg_name = debian_name(pkginfo, true)
!rock_release_platform.ancestorContains(pkg... | [
"def dependencies options = {}\n return [] unless exist?\n deps = Array.new\n if options.has_key?(:subprojects) and (not options[:subprojects])\n reload_project_info unless @info_file and @info_file.exist?\n info_files = [@info_file]\n else\n info_files = Dir[\"#{local_path}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Newlinedelimited list of actions | def encode(serialized_actions = [])
serialized_actions.join("\n")
end | [
"def get_actions\n\n actions = []\n\n unless self.actions.nil? or self.actions.empty?\n actions = self.actions.split(\"\\n\").collect {|entry| entry.split('-') }\n end\n return actions\n end",
"def action_add(line)\n @actionplan << \"#{line}\"\n end",
"def actions(*list)\n return @act... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Maximum content length before a URL, this is 140 (maximum length of a Twitter message) minus 21 (space plus 20 characters for a t.co URL) or 22 with the https protocol | def max_content_length
@@max_content_length ||= Config.web =~ /^https/ ? 118 : 119
end | [
"def url_char_length\n 23 #assume https for good measure\n end",
"def validate_url_length\n raise UrlLengthError unless to_url(:validation => false).size <= URL_MAX_LENGTH\n end",
"def too_long? content\n content.length > MaxTweetLength\n end",
"def length\n [default&.length, max_cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
wraper for the brand method ActiveMerchant returns master or american_express Banwire requires mastercard and amex | def get_brand(brand)
case brand
when "master"
return "mastercard"
when "american_express"
return "amex"
else
return brand
end
end | [
"def get_brand(card_bin)\n Cielo::API30::Request::QueryBrandRequest.new(merchant, environment).execute(card_bin)\n end",
"def is_brand? brand\n ActiveDevice::Handset.is_brand? request.user_agent, brand\n end",
"def is_brand? brand\n Handset.is_brand? request.user_agent, brand\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /farms GET /farms.json | def index
@farms = Farm.all
respond_with(@users,@farms)
end | [
"def farms\n user = User.find(params[:id])\n\n @farms = []\n # Find which farms this user is authorized to access\n if (user.is_hog_owner?)\n @farms = user.owner.farms\n elsif user.is_barn_manager?\n @farms << user.owner.barn.location.farm\n elsif user.is_site_manager?\n @farms << u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def cache(path, original_filename, output_filename, data=nil) | def cache(input_path, output_path, data=nil)
path = input_path
@new_hashes[input_path] = hash(@input_directory, input_path)
if data
@data[path] = data if data
@wildcard_dependencies[path] = data[:wildcard_dependencies] if data[:wildcard_dependencies]
@dependencies[path] = data... | [
"def cache_stored_file!; end",
"def cache_stored_file!\n cache!\n end",
"def cache_data filename, data, mtime = Iodine.time\n\t\t\tCACHE_LOCK.synchronize { CACHE_STORE[filename] = CacheObject.new( data, mtime ) }\n\t\t\tdata\n\t\tend",
"def caching\n @caching = \"data_update[#{data_path}]\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create L2VPN session Create L2VPN session and bind to a L2VPNService | def create_l2_vpn_session(l2_vpn_session, opts = {})
data, _status_code, _headers = create_l2_vpn_session_with_http_info(l2_vpn_session, opts)
data
end | [
"def create_l2_vpn_session_with_http_info(l2_vpn_session, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.create_l2_vpn_session ...\"\n end\n # verify the required parameter 'l2_vpn_session' is set\n if @api_client.config.client_side_va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create L2VPN session Create L2VPN session and bind to a L2VPNService | def create_l2_vpn_session_with_http_info(l2_vpn_session, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.create_l2_vpn_session ...'
end
# verify the required parameter 'l2_vpn_session' is set
if @api_client.co... | [
"def create_l2_vpn_session(l2_vpn_session, opts = {})\n data, _status_code, _headers = create_l2_vpn_session_with_http_info(l2_vpn_session, opts)\n data\n end",
"def create_l2_vpn_session_with_http_info(l2_vpn_session, opts = {})\n if @api_client.config.debugging\n @api_client.config.logg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete a L2VPN session Delete a specific L2VPN session. If there are any logical switch ports attached to it, those needs to be deleted first. | def delete_l2_vpn_session_with_http_info(l2vpn_session_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.delete_l2_vpn_session ...'
end
# verify the required parameter 'l2vpn_session_id' is set
if @api_clien... | [
"def delete_l2_vpn_session_with_http_info(l2vpn_session_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.delete_l2_vpn_session ...\"\n end\n # verify the required parameter 'l2vpn_session_id' is set\n if @api_client.config.client_sid... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a L2VPN session Get a specific L2VPN session | def get_l2_vpn_session(l2vpn_session_id, opts = {})
data, _status_code, _headers = get_l2_vpn_session_with_http_info(l2vpn_session_id, opts)
data
end | [
"def get_l2_vpn_session_with_http_info(l2vpn_session_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.get_l2_vpn_session ...\"\n end\n # verify the required parameter 'l2vpn_session_id' is set\n if @api_client.config.client_side_vali... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a L2VPN session Get a specific L2VPN session | def get_l2_vpn_session_with_http_info(l2vpn_session_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.get_l2_vpn_session ...'
end
# verify the required parameter 'l2vpn_session_id' is set
if @api_client.conf... | [
"def get_l2_vpn_session_with_http_info(l2vpn_session_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.get_l2_vpn_session ...\"\n end\n # verify the required parameter 'l2vpn_session_id' is set\n if @api_client.config.client_side_vali... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get peer codes for the L2VpnSession Get peer codes for the L2VPN session to program the remote side of the tunnel. | def get_l2_vpn_session_peer_codes(l2vpn_session_id, opts = {})
data, _status_code, _headers = get_l2_vpn_session_peer_codes_with_http_info(l2vpn_session_id, opts)
data
end | [
"def get_l2_vpn_session_peer_codes(l2vpn_session_id, opts = {})\n data, _status_code, _headers = get_l2_vpn_session_peer_codes_with_http_info(l2vpn_session_id, opts)\n return data\n end",
"def get_l2_vpn_session_peer_codes_with_http_info(l2vpn_session_id, opts = {})\n if @api_client.config.debug... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get peer codes for the L2VpnSession Get peer codes for the L2VPN session to program the remote side of the tunnel. | def get_l2_vpn_session_peer_codes_with_http_info(l2vpn_session_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.get_l2_vpn_session_peer_codes ...'
end
# verify the required parameter 'l2vpn_session_id' is set
... | [
"def get_l2_vpn_session_peer_codes(l2vpn_session_id, opts = {})\n data, _status_code, _headers = get_l2_vpn_session_peer_codes_with_http_info(l2vpn_session_id, opts)\n data\n end",
"def get_l2_vpn_session_peer_codes(l2vpn_session_id, opts = {})\n data, _status_code, _headers = get_l2_vpn_session... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all L2VPN sessions Get paginated list of all L2VPN sessions | def list_l2_vpn_sessions(opts = {})
data, _status_code, _headers = list_l2_vpn_sessions_with_http_info(opts)
data
end | [
"def list_l2_vpn_sessions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.list_l2_vpn_sessions ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail A... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all L2VPN sessions Get paginated list of all L2VPN sessions | def list_l2_vpn_sessions_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.list_l2_vpn_sessions ...'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > ... | [
"def list_l2_vpn_sessions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.list_l2_vpn_sessions ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail A... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Edit a L2VPN session Edit a specific L2VPN session | def update_l2_vpn_session_with_http_info(l2vpn_session_id, l2_vpn_session, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ManagementPlaneApiVpnL2VpnSessionsApi.update_l2_vpn_session ...'
end
# verify the required parameter 'l2vpn_session_id' is set
... | [
"def update_l2_vpn_session_with_http_info(l2vpn_session_id, l2_vpn_session, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: VpnApi.update_l2_vpn_session ...\"\n end\n # verify the required parameter 'l2vpn_session_id' is set\n if @api_client.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /mbrackets GET /mbrackets.json | def index
@mbrackets = Mbracket.all
end | [
"def index\n @cnmrbrackets = Cnmrbracket.all\n end",
"def list_assets\n get('/video/v1/assets')\n end",
"def show\n @player_color_bucket = PlayerColorBucket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_color_bucket }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /mbrackets POST /mbrackets.json | def create
@mbracket = Mbracket.new(mbracket_params)
respond_to do |format|
if @mbracket.save
format.html { redirect_to @mbracket, notice: 'Mbracket was successfully created.' }
format.json { render :show, status: :created, location: @mbracket }
else
format.html { render :ne... | [
"def create\n @bucket = Bucket.new(params[:bucket])\n\n respond_to do |format|\n if @bucket.save\n format.html { redirect_to @bucket, notice: 'Bucket was successfully created.' }\n format.json { render json: @bucket, status: :created, location: @bucket }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /mbrackets/1 PATCH/PUT /mbrackets/1.json | def update
respond_to do |format|
if @mbracket.update(mbracket_params)
format.html { redirect_to @mbracket, notice: 'Mbracket was successfully updated.' }
format.json { render :show, status: :ok, location: @mbracket }
else
format.html { render :edit }
format.json { render... | [
"def update\n respond_to do |format|\n if @abucket.update_attributes(params[:abucket])\n flash[:notice] = 'Bucket was successfully updated.'\n format.html { redirect_to(account_abuckets_path(@account)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a save file, and attempt to initialize a game from it | def load_game
print_saves
begin
read_save
rescue IOError, SystemCallError
puts 'File not found'
load_game
end
end | [
"def load_game\n data = File.read(\"save.txt\")\n load_game = Game.from_json data\n request_save = load_game.play\n\n if request_save\n save_file request_save\n end\n end",
"def load_saved_game\n game_data = get_saved_game_file\n if game_data\n @file.secret_word = gam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create slicing planes which are perpendicular to the reference segment. | def slicing_planes(segmenter)
plane_normal = segmenter.segment.line[1]
segmenter.points.map { |point|
[point.clone, plane_normal.clone]
}
end | [
"def get_plane\n Plane.construct_with_three_points(point_a, point_b, point_c)\n end",
"def create_perpendicular\n p1dot = self * P1\n p2dot = self * P2\n p1dot = -p1dot if p1dot < 0\n p2dot = -p2dot if p2dot < 0\n p1dot < p2dot ? (self % P1) : (self % P2)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a date range and breaks it into an array of ranges by month. The first and last items may be partial months (ex starting in the middle and ending at the end) and the intermediate items are always full months (1st to last of month) | def months(date_range)
results = []
results << (date_range.begin..date_range.begin.end_of_month)
current = date_range.begin.end_of_month + 1.day
while current < date_range.end.beginning_of_month
month_start = current.beginning_of_month
month_end = current.end_of_month
... | [
"def range_to_month_array\n Function.new do |range|\n range.select { |date| date.day == 1 }\n end\n end",
"def months\n (Periods::Month.for(start_date)..Periods::Month.for(end_date)).to_a\n end",
"def months\n temporale = CalendariumRomanum::Temporale.new(@config... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET|POST /sites/filter GET|POST /projects/:project_id/sites/filter | def filter
do_authorize_class
get_project_if_exists
do_authorize_instance(:show, @project) unless @project.nil?
filter_response, opts = Settings.api_response.response_advanced(
api_filter_params,
list_permissions,
Site,
Site.filter_settings
)
respond_filter(filter_respon... | [
"def filter\n @project = Project.find(params[:project_id])\n end",
"def filter\n do_authorize_class\n get_project_if_exists\n get_harvest_if_exists\n\n filter_response, opts = Settings.api_response.response_advanced(\n api_filter_params,\n list_permissions,\n HarvestItem,\n Har... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
include Override Objectinclude so that modules extending Module instance can define include. | def include( *modules )
super if defined?( super )
original_include( *modules )
end | [
"def add_include(include)\n object_class.record_location self\n return include unless @document_self\n object_class.add_include include\n end",
"def add_include include\n add_to @includes, include\n\n include\n end",
"def include( *args )\n includeSubobject( *args )\n end",
"def inclu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
extend_object Override Module.extended so that modules extending Module can define extend_object. | def extend_object( hooked_instance )
original_extend_object( hooked_instance )
super if defined?( super )
end | [
"def _extend_(mod)\n mod.__send__(:extend_object, self)\n end",
"def extend_object(obj) end",
"def representer_module_for(object, *args)\n # TODO: cache this!\n evaluate_option(:extend, object) # TODO: pass args? do we actually have args at the time this is called (compile-time)?\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure supplied GitHub usernames are real | def test_github_profile_exists
people.each do |name, info|
github_username = info.fetch("github", false)
if github_username
assert_kind_of Sawyer::Resource, octokit.user(github_username), "#{github_username} is not a real GitHub account"
end
end
end | [
"def username_exists?(github_username)\n !!User.all.find_by(github_username: github_username)\n end",
"def github_usernames\n @github_usernames ||= cloud9_workspaces.map do |ws|\n next unless ws[:scmurl]\n\n info = github_info_from_url(ws[:scmurl])\n\n next unless info\n\n info[:user]\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the next lower item in the list. | def lower_item
return nil unless in_list?
acts_as_list_class.find(:first, :conditions =>
"position = #{(send(:position).to_i + 1).to_s}"
)
end | [
"def lower_item\n return nil unless in_list?\n lower_items(1).first\n end",
"def lower_item\n return nil unless in_list?\n @lower_item ||= self.class.branch(self).find(:first, :conditions => {:position => position+1})\n end",
"def find_lt(list, item, &block)\r\n\t\ti ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decrease the position of this item without adjusting the rest of the list. | def decrement_position
return unless in_list?
update_attribute :position, self.send(:position).to_i - 1
end | [
"def decrement_position\n return unless in_list?\n set_list_position(current_position - 1)\n end",
"def decrement_position\n return unless in_list?\n update_attribute position_column, self.send(position_column).to_i - 1\n end",
"def decrement_position\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.