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 |
|---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_atividade
@atividade = Atividade.where(id: params[:id]).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def atividade_params
params.require(:atividade).permit(:nome, :status, :professor, :motivo)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
validates :username, :email, :password, presence: true validates :email, uniqueness: true | def token
begin
self.token = SecureRandom.hex
end while self.class.exists?(token: auth_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_username\n if User.where(email: username).exists? || User.where(username: username).exists? \n errors.add(:username, :invalid)\n end\n end",
"def validate_username\n if User.where(email: username).exist?\n errors.add(:username, :invalid)\n end\n end",
"def validate_username... | [
"0.80677277",
"0.801401",
"0.79443276",
"0.79443276",
"0.73529476",
"0.7144113",
"0.7136573",
"0.707155",
"0.7065116",
"0.7009148",
"0.69021666",
"0.6876276",
"0.6831508",
"0.6820489",
"0.6793573",
"0.6775119",
"0.67530286",
"0.673399",
"0.67119706",
"0.6708525",
"0.6701131",... | 0.0 | -1 |
FIXME: Eventually add a feature where they can choose between 5,10 and 20 questions. Then have a leaderboard to match each of those numbers This function is the quiz. It begins by reading the capital cities from a json file. Then cycles through randomised values to ask the user for the capital cities of certain countries. | def quiz_function
read_data_from_file
#establish an array to hold the randomised keys of our hash. The purpose of this, is to ensure that every key is unique, so the user is not being asked the same country repeatadly
randomised_capitals = []
n = 10
@count = 0
#time-loop to go through our hash n times. It generates a random integer between 0 and the length of the hash, and uses that integer to chose a country of that index. An array is used to store the value of the countries that have been randomly generated. This is to ensure there is no duplication. The length of unique is compared to the length of the array. If they are not equal, there is a duplicate. The last value is popped out, and a new country is put in. This is repeated until all are unique
n.times do
random_index_number = rand(@countries_capitals_as_hash.length-1)
randomised_capitals << @countries_capitals_as_hash[random_index_number]["country"]
unique_array = false
while unique_array == false do
if randomised_capitals.uniq.length == randomised_capitals.length
unique_array = true
else
randomised_capitals.pop
random_index_number = rand(@countries_capitals_as_hash.length-1)
randomised_capitals << @countries_capitals_as_hash[rand(@countries_capitals_as_hash.length-1)]["country"]
end
end
#The user is asked for the capital of the randomised country, with their answer checked, and the appropriate message dispalyed. If they are correct, the count variable will increment by 1. The function then calls result, so that the user can save the result
system("clear")
matching_capital = @countries_capitals_as_hash[random_index_number]["city"]
puts "##################################"
puts "# "
puts "# What is the Capital of "
puts "# #{randomised_capitals[-1]}? "
puts "#"
puts "##################################"
puts ""
answer = gets.chomp.capitalize
if answer == matching_capital
@count += 1
puts "Correct!"
puts "Total correct answers: #{@count}"
else
puts "Incorrect. Better luck next time!"
puts "The correct answer was #{matching_capital}"
end
puts ""
any_key
end
result
menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cities opt, graph\n\n\tp opt, graph\n\t#first try all cities spread over USA, should be easy to figure out if the correct tour was picked\n\tcities = 'd,DC,77.01,38.90;l,Los_Angeles,118.25,34.05;c,Chicago,87.68,41.83;m,Memphis,89.97,35.11;h,Houston,95.36,29.76;\n\t\t\t\t L,Las_Vegas,115.17,36.12;k,Kansas_city,... | [
"0.57529217",
"0.57430625",
"0.57345414",
"0.57303435",
"0.5636026",
"0.5605779",
"0.5550946",
"0.55206776",
"0.53912854",
"0.53684527",
"0.53544956",
"0.534879",
"0.5315587",
"0.5308442",
"0.52905416",
"0.52788824",
"0.5271134",
"0.5256388",
"0.5255151",
"0.52498955",
"0.524... | 0.7288106 | 0 |
This grabs the JSON from 'condensed_capitals.JSON' and converts it to a hash. The hash is saved in a classinstance variable, so that it is accessible across the rest of this instance | def read_data_from_file
file = File.read("condensed_capitals.json")
@countries_capitals_as_hash = JSON.parse(file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capital(capitals_hash_array)\n return_array = capitals_hash_array.reduce Hash.new, :merge\n if return_array.has_key?(:state || 'state').to_s\n \"The capital of #{return_array['state']} is #{return_array[:capital]}\"\n else return_array.key?(:country || 'country').to_s\n \"The capital of #{return_array['c... | [
"0.53769726",
"0.53343743",
"0.5191626",
"0.5170708",
"0.51274246",
"0.5112649",
"0.505052",
"0.5048098",
"0.49903524",
"0.49437973",
"0.49085334",
"0.49039766",
"0.49012655",
"0.48590946",
"0.48520198",
"0.4834855",
"0.4827472",
"0.48215252",
"0.48184407",
"0.4810502",
"0.48... | 0.7413648 | 0 |
Display the user's name and results. Calls upon the function send_to_leaderboard and send_to_file to store the score | def result
system("clear")
puts "##############################"
puts "# Congratulations #{@@name}! "
puts "# #"
puts "# You got #{@count} answers correct! #"
puts "# #"
puts "# Check the leaderboard #"
puts "# to see if you made #"
puts "# the top 10! #"
puts "# #"
puts "##############################"
any_key
send_to_leaderboard
send_to_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_scoreboard\n puts \"The score is\"\n puts \"#{@player_1_name}\"+\" #{@player_1_score}\" \n puts \"#{@player_2_name}\"+\" #{@player_2_score}\"\n puts\n end",
"def send_to_leaderboard\n @date = Time.now.strftime(\"%d/%m/%Y\")\n @new_score = Hash.new\n @new_... | [
"0.6993038",
"0.698269",
"0.69531184",
"0.6919737",
"0.69170386",
"0.68024874",
"0.6727945",
"0.6723125",
"0.66678303",
"0.6614759",
"0.65661395",
"0.6512712",
"0.65119845",
"0.6509058",
"0.65017724",
"0.64660853",
"0.6452335",
"0.6443413",
"0.6437809",
"0.6388549",
"0.638725... | 0.7070312 | 0 |
convert date, username and score, from a hash, to a json, then append to the leaderboard file. This will keep track of all scores attempted by all users | def send_to_leaderboard
@date = Time.now.strftime("%d/%m/%Y")
@new_score = Hash.new
@new_score["date"] = @date
@new_score["username"] = @@username
@new_score["score"] = @count
File.open("userDetails/leaderboard.json", "a") do |f|
f.puts JSON.generate(@new_score)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_points_records(game)\n #updates the data in the json file to reflect the results of each round\n data_hash = json_parser\n arr = data_hash['users']\n arr.each do |user|\n #if player username matches the player\n if user['username'] == @player.name\n #change their rou... | [
"0.6965621",
"0.67962486",
"0.6538375",
"0.6285001",
"0.62251776",
"0.606435",
"0.5979059",
"0.59790516",
"0.58575726",
"0.58208203",
"0.570941",
"0.5666259",
"0.5660728",
"0.5642698",
"0.5639954",
"0.56264395",
"0.56264055",
"0.5597375",
"0.5580877",
"0.5572009",
"0.5571158"... | 0.78505033 | 0 |
Send date, username and score to users own file. This will come in handy later, when a feature is implemented for users to check their own best scores | def send_to_file
File.open("userDetails/#{@@username}.json", "a") do |f|
f.puts JSON.generate(@new_score)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_to_leaderboard\n @date = Time.now.strftime(\"%d/%m/%Y\")\n @new_score = Hash.new\n @new_score[\"date\"] = @date\n @new_score[\"username\"] = @@username\n @new_score[\"score\"] = @count\n File.open(\"userDetails/leaderboard.json\", \"a\") do... | [
"0.7421128",
"0.69816774",
"0.680896",
"0.6541783",
"0.6475139",
"0.6229717",
"0.61544013",
"0.6064524",
"0.6052509",
"0.6045606",
"0.6045606",
"0.60432166",
"0.60035944",
"0.5961518",
"0.593527",
"0.5934592",
"0.5914476",
"0.5884001",
"0.58671933",
"0.57991767",
"0.5787604",... | 0.7684812 | 0 |
A basic display for the leaderboard. It sends users to the leaderboard_info function, where the data is filled. At the end of the function, the any_key function is called, so nothing will happen until the user touches a key, then the menu is called for recursion | def display_leaderboard
system("clear")
puts "##############################"
puts "# L E A D E R B O A R D "
puts "#-----------------------------"
puts "# | | "
puts "# DATE | SCORE | USERNAME "
puts "#------------|-------|----------"
leaderboard_info
puts "# "
puts "##############################"
any_key
menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaderboard\n update_user_data\n font = font_instance\n prompt = prompt_instance\n system('clear')\n puts font.write(\"LEADERBOARD\")\n puts \"--------------------------------------------------------------------------\"\n scores = []\n $users.each do |x|\n scores << {username: x[... | [
"0.7548248",
"0.7228294",
"0.6404029",
"0.6258345",
"0.6235043",
"0.6233451",
"0.6232264",
"0.62009275",
"0.61757255",
"0.6168789",
"0.6124833",
"0.61037433",
"0.60535926",
"0.6025433",
"0.6008562",
"0.60028625",
"0.5969052",
"0.59662324",
"0.59457505",
"0.59413385",
"0.59353... | 0.8596268 | 0 |
The leaderboard file is read, and each line is added to our new empty array user_hash. This hash is then sorted by 'score', reversed and sliced, so the top 10 scores will remain. The remaining array will be passed through a while loop, with each element of each line being printed. Its done this way, so that the leaderboard will never exceed 10. If there are less than 10, its set up in such a way that an error will not be thrown | def leaderboard_info
#ADD rspec test here, so if there is no file, it goes to rescue
user_hash = []
File.open("userDetails/leaderboard.json", 'r') do |f|
f.each_line do |line|
user_hash.push(JSON.parse(line))
end
end
sorted_user_hash = user_hash.sort_by { |k| k["score"]}
top_ten_scores = sorted_user_hash.reverse!.slice(0,9)
i = 0
while i < top_ten_scores.length do
puts "# #{sorted_user_hash[i]["date"]} | #{sorted_user_hash[i]["score"]} | #{sorted_user_hash[i]["username"]} "
i += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_leaderboard(score)\n count = 0\n leaderboard = []\n\n File.foreach(\"leaderboard.txt\") do |line| \n if count < 4\n leaderboard += [line]\n else\n break\n end\n count += 1\n end\n\n leaderboard.e... | [
"0.68885106",
"0.6556808",
"0.64592904",
"0.62144446",
"0.6207725",
"0.6206693",
"0.6157254",
"0.61037445",
"0.6008324",
"0.5961171",
"0.5948932",
"0.58817756",
"0.5850144",
"0.5838144",
"0.58021283",
"0.5638121",
"0.56324416",
"0.5621784",
"0.56174225",
"0.56007946",
"0.5590... | 0.7312942 | 0 |
Function where the user can press any key to continue | def any_key
puts ""
puts "Press any key to continue.."
STDIN.getch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pressKeyToContinue\n puts \"\\n-- press any key to continue --\"\n gets\nend",
"def enter_to_continue\r\n @prompt.keypress('Press space or enter to continue', keys: %i[space return])\r\n end",
"def pressToContinue\n puts \"\\n\"\n print \"Press enter to continue. \"\n gets.chomp\n end",
"... | [
"0.8547809",
"0.78597206",
"0.7844068",
"0.75419533",
"0.7241591",
"0.7241024",
"0.7226608",
"0.71959287",
"0.7095423",
"0.70458585",
"0.7019892",
"0.69794744",
"0.69064355",
"0.68736476",
"0.68241096",
"0.6740803",
"0.66718554",
"0.6664298",
"0.66461277",
"0.6645293",
"0.664... | 0.8108583 | 1 |
Function create_ssh_session establishes ssh connection to jump server. | def create_ssh_session
return Net::SSH.start(JUMPSRV_NMC, JUMPSRV_NMC_USER, password: JUMPSRV_NMC_PW, timeout: 40) # verbose: :info,
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_ssh_session\n @ssh_session.close if !(@ssh_session.nil? or !@ssh_session.closed?)\n ssh_opts = ssh_connection_options\n @log.info(\"Opening ssh connection to #{ssh_opts[:host]} as user #{ssh_opts[:user]}\")\n @ssh_session = ::Net::SSH.start(ssh_opts[:host], ssh_opts[:user])\n ... | [
"0.70543665",
"0.6994476",
"0.69455504",
"0.6587479",
"0.6465352",
"0.64460945",
"0.6330062",
"0.6277622",
"0.6218434",
"0.6180591",
"0.61676896",
"0.61670405",
"0.6136053",
"0.61271846",
"0.6089783",
"0.6068749",
"0.5960136",
"0.5922247",
"0.58441675",
"0.58385825",
"0.57736... | 0.7891024 | 0 |
Function disconnect closes the host session. | def close_ssh_session(session)
session.close
session = nil
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def disconnect\n _logout\n @connection.close\n end",
"def disconnect\n @connection.logout\n end",
"def disconnect(host)\n shutdown\n end",
"def disconnect\n command 'QUIT'... | [
"0.81036305",
"0.7551525",
"0.74263775",
"0.7418265",
"0.7404558",
"0.73549294",
"0.73307353",
"0.72902584",
"0.72902584",
"0.72902584",
"0.72902584",
"0.72707105",
"0.7209355",
"0.71704257",
"0.7162572",
"0.7162572",
"0.71567917",
"0.7117403",
"0.7112897",
"0.7100698",
"0.70... | 0.0 | -1 |
Function connect establishes final host connection over ssh session. | def connect(host, retrying)
sample = ''
@telnet = Net::SSH::Telnet.new('Session' => ssh_session, 'Prompt' => LOGIN_PROMPT, 'Timeout' => 60)
# sends telnet command
@telnet.puts format('telnet %s', host[:ip])
@telnet.waitfor('Match' => LOGIN_PROMPT) { |rcvdata| sample << rcvdata }
case retrying
when false
@telnet.puts RADIUS_USERNAME
@telnet.waitfor('Match' => PASSWORD_PROMPT) { |rcvdata| sample << rcvdata }
@telnet.puts RADIUS_PW
@telnet.waitfor('Match' => /(?:\w+[$%#>]|Login incorrect)/) { |rcvdata| sample << rcvdata }
when true
@telnet.puts 'admin'
@telnet.waitfor('Match' => PASSWORD_PROMPT) { |rcvdata| sample << rcvdata }
@telnet.puts 'admin'
@telnet.waitfor('Match' => /(?:\w+[$%#>]|Login incorrect)/) { |rcvdata| sample << rcvdata }
end
sample.match(PROMPT) ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect!\n @ssh = Net::SSH.start(@host, @user, :password => @pass)\n end",
"def connect(&block)\n @output = []\n @channel_data = ''\n\n begin\n Puppet.debug(\"connecting to #{host} as #{user}\")\n @ssh = Net::SSH.start(host, user, port: port, password: password,... | [
"0.7515243",
"0.74648094",
"0.72069806",
"0.6968217",
"0.6928046",
"0.69096804",
"0.68271506",
"0.68074334",
"0.67267597",
"0.66937166",
"0.6631089",
"0.66052336",
"0.6603274",
"0.65374905",
"0.649283",
"0.6490946",
"0.6467609",
"0.6454056",
"0.64266676",
"0.6366609",
"0.6288... | 0.55668 | 95 |
Function disconnect closes the host session. | def disconnect
@telnet.close
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def disconnect\n _logout\n @connection.close\n end",
"def disconnect\n @connection.logout\n end",
"def disconnect(host)\n shutdown\n end",
"def disconnect\n command 'QUIT'... | [
"0.81036305",
"0.7551525",
"0.74263775",
"0.7418265",
"0.7404558",
"0.73549294",
"0.73307353",
"0.72902584",
"0.72902584",
"0.72902584",
"0.72902584",
"0.72707105",
"0.7209355",
"0.71704257",
"0.7162572",
"0.7162572",
"0.71567917",
"0.7117403",
"0.7112897",
"0.7100698",
"0.70... | 0.0 | -1 |
Function get_host_data executes low level commands over the connection | def get_low_level_data(cmd, regex, splitter_regex)
sample = ''
# sends cmd to host
@telnet.puts(cmd) { |str| print str }
# waits for cli prompt and stores returned data into sample variable
@telnet.waitfor('Match' => PROMPT) { |rcvdata| sample << rcvdata }
#print "\n Return of low level command:\n #{sample}"
(sample.scan(regex)[0].nil? ? nil : sample.scan(regex)[0].split(splitter_regex))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_host_info\n json { execute_prlctl('server', 'info', '--json') }\n end",
"def do_command\n _, cmd, _, atype, addr_length = @data.unpack(\"C5\")\n header_length = 0\n\n case atype\n when 1, 4 # 1: ipv4, 4 bytes / 4: ipv6, 16 bytes\n ip_length... | [
"0.66292816",
"0.65121615",
"0.6180704",
"0.60869515",
"0.6063496",
"0.60498446",
"0.6011651",
"0.5967319",
"0.5887242",
"0.584129",
"0.5800581",
"0.57885045",
"0.57726556",
"0.5761909",
"0.5682992",
"0.56692004",
"0.56531096",
"0.5614264",
"0.5596975",
"0.55923516",
"0.55781... | 0.0 | -1 |
Function get_transceivers_detail gets transceivers detail | def get_transceivers_detail
cmd = 'sh hardware-status transceivers detail'
regex = /((\w\/\w+)|-\d+\.\d+)/
data_splitter = /\s+/
get_low_level_data(cmd, regex, data_splitter)
# sample text
# D2BRE36BBR01#sh hardware-status transceivers detail
# Information of port 1/25
# Vendor information:
# Vendor Name: OEM
# Manufacturer: OEM
# Part Number: WDM-0210BD
# Serial Number: 6C1501V450
# Media: Single Mode (SM)
# Ethernet Standard: [Not available]
# Connector: LC
# Digital Diagnostic:
# Temperature: 30 C
# Voltage 3.3V: 3.3V
# Current: 31.6mA
# Tx-Power: -4.2dBm
# Rx-Power: -13.0dBm
#
# Information of port 1/26
# Vendor information:
# Vendor Name: OEM
# Manufacturer: OEM
# Part Number: WDM-0210-AD-C
# Serial Number: 1404L00759
# Media: Single Mode (SM)
# Ethernet Standard: [Not available]
# Connector: LC
# Digital Diagnostic:
# Temperature: 31 C
# Voltage 3.3V: 3.3V
# Current: 30.0mA
# Tx-Power: -7.4dBm
# Rx-Power: -8.1dBm
#
# D2BRE36BBR01#
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtered_receivers\n @receivers\n end",
"def get_transaction_items\n transaction.transaction_details\n end",
"def receivers\n @receivers\n end",
"def index\n @receivers = Receiver.current.order(trees: :desc)\n end",
"def get_recipients(obj)\n @store.get_recipients(o... | [
"0.6208302",
"0.6044029",
"0.60390174",
"0.59709567",
"0.56974226",
"0.5665101",
"0.5479649",
"0.54702395",
"0.54636705",
"0.54364276",
"0.54034555",
"0.5393635",
"0.53869045",
"0.5307813",
"0.5264679",
"0.5264679",
"0.52641666",
"0.5240281",
"0.5239921",
"0.5238738",
"0.5237... | 0.6925886 | 0 |
Function get_eaps_status gets eaps redundancy protocol status. | def get_eaps_status
cmd = 'show eaps'
regex = /\b\d\s.+/
data_splitter = /\s+/
result = get_low_level_data(cmd, regex, data_splitter)
result.map { |e| e || '' } if !result.nil? # replaces nil values
result.nil? ? ["", "", "no eaps configured", "", "", "", "", ""] : result
# sample text
# D2SPO10CDR01#sh eaps
# EAPS information:
#
# Mode: M - Master
# T - Transit
#
# Pri Sec Ctrl Protected
# ID Domain State Mode Port Port VLAN Groups/VLANs
# -- --------------- --------------- ---- ------ ------ ---- ------------
# 0 gvt Links-Up T 1/25 1/26 4094 1/4093
#
# D2SPO10CDR01#
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elb_status_code\n self[:elb_status_code].to_i\n end",
"def get_status status_code\n status = STATUSES[status_code]\n if status\n status\n else\n status = STATUSES['IV']\n end\n end",
"def get_status\n send_command(0x79)\n end",
"def fetch_status\n return :green if fe... | [
"0.5877286",
"0.5861396",
"0.57177955",
"0.57015383",
"0.56501615",
"0.5628293",
"0.5602224",
"0.55186707",
"0.5517481",
"0.5517279",
"0.5511589",
"0.5509127",
"0.5509109",
"0.5492461",
"0.5465025",
"0.5452896",
"0.5449722",
"0.5445004",
"0.5443237",
"0.540069",
"0.5387664",
... | 0.7491588 | 0 |
Complete the 'pairs' function below. The function is expected to return an INTEGER. The function accepts following parameters: 1. INTEGER k 2. INTEGER_ARRAY arr | def pairs(k, arr)
# set = Set.new(arr)
set = arr.to_h { |num| [num, true] }
result = 0
arr.each do |num|
target = num + k
if set.include?(target)
result += 1
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_pairs(array, k)\n # write your code here\n pairs = []\n \n array.each_with_index do |x, index|\n array[(index + 1)..-1].each do |y|\n pairs.push([x, y]) if x + y == k\n end\n end\n \n pairs\nend",
"def pair_sum(array, k)\nend",
"def pairs(k, arr)\n pair = 0\n i = 0\n j = 1\n n = arr.... | [
"0.7261237",
"0.722429",
"0.68775797",
"0.6498221",
"0.64762837",
"0.6429681",
"0.63611096",
"0.6345208",
"0.6315403",
"0.63150495",
"0.62222445",
"0.6221024",
"0.62155247",
"0.62155247",
"0.61954546",
"0.61930096",
"0.61835116",
"0.6181048",
"0.6123869",
"0.61215454",
"0.608... | 0.64379567 | 5 |
DELETE /favorite_movies/1 DELETE /favorite_movies/1.xml | def destroy
@favorite = Favorite.find(params[:id])
@movie = @favorite.movie
@favorite.destroy
notice = "#{@movie.title} removed from your favorite list."
respond_to do |format|
format.js do
render :update do |page|
page.replace_html 'message', notice
page.hide dom_id(@movie) + '_row'
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @movies.each do |movie|\n #@movie = Movie.find(params[:id])\n movie.destroy\n end\n\n # respond_to do |format|\n \n # format.xml { head :ok }\n # end\n end",
"def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n form... | [
"0.687501",
"0.6794308",
"0.6794308",
"0.6794308",
"0.6763691",
"0.670928",
"0.66914564",
"0.66384465",
"0.65777814",
"0.65642416",
"0.6523611",
"0.65198696",
"0.6435121",
"0.63383913",
"0.63378966",
"0.6337238",
"0.6336012",
"0.6333781",
"0.6261995",
"0.626047",
"0.6248599",... | 0.0 | -1 |
GET /uitgelichts GET /uitgelichts.xml | def index
@uitgelichts = Uitgelicht.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @uitgelichts }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @uitgelicht = Uitgelicht.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end",
"def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { re... | [
"0.64757204",
"0.61658496",
"0.603984",
"0.5972503",
"0.59234715",
"0.5912517",
"0.589592",
"0.5797773",
"0.5795771",
"0.5779589",
"0.57497346",
"0.57242215",
"0.57167107",
"0.5696756",
"0.5693198",
"0.56665397",
"0.56604934",
"0.563896",
"0.56316006",
"0.56221724",
"0.561862... | 0.7285785 | 0 |
GET /uitgelichts/1 GET /uitgelichts/1.xml | def show
@uitgelicht = Uitgelicht.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @uitgelicht }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end",
"def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { rende... | [
"0.7184369",
"0.6220625",
"0.6023085",
"0.5957455",
"0.59568226",
"0.5911945",
"0.5895476",
"0.5881204",
"0.5875103",
"0.585242",
"0.5842237",
"0.5803596",
"0.57879555",
"0.576358",
"0.5757036",
"0.5728966",
"0.57258177",
"0.57139575",
"0.56975675",
"0.5676582",
"0.56603247",... | 0.67411876 | 1 |
GET /uitgelichts/new GET /uitgelichts/new.xml | def new
@uitgelicht = Uitgelicht.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @uitgelicht }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n res... | [
"0.71286917",
"0.7000771",
"0.69651204",
"0.69471675",
"0.6926441",
"0.68815273",
"0.68478936",
"0.6823427",
"0.6806458",
"0.6798746",
"0.6781792",
"0.67748094",
"0.67748094",
"0.6763844",
"0.67517483",
"0.6751515",
"0.6745804",
"0.67330146",
"0.6716187",
"0.6684667",
"0.6665... | 0.76262295 | 0 |
POST /uitgelichts POST /uitgelichts.xml | def create
@uitgelicht = Uitgelicht.new(params[:uitgelicht])
respond_to do |format|
if @uitgelicht.save
flash[:notice] = 'Uitgelicht was successfully created.'
format.html { redirect_to(@uitgelicht) }
format.xml { render :xml => @uitgelicht, :status => :created, :location => @uitgelicht }
else
format.html { render :action => "new" }
format.xml { render :xml => @uitgelicht.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n... | [
"0.59255093",
"0.5734502",
"0.54636675",
"0.5382713",
"0.53812575",
"0.5366539",
"0.5325981",
"0.52914155",
"0.5270619",
"0.5265313",
"0.5238145",
"0.5224512",
"0.5218932",
"0.5197775",
"0.5190891",
"0.51828957",
"0.512819",
"0.5120513",
"0.5117129",
"0.5106387",
"0.5093005",... | 0.6197072 | 0 |
PUT /uitgelichts/1 PUT /uitgelichts/1.xml | def update
@uitgelicht = Uitgelicht.find(params[:id])
respond_to do |format|
if @uitgelicht.update_attributes(params[:uitgelicht])
flash[:notice] = 'Uitgelicht was successfully updated.'
format.html { redirect_to(@uitgelicht) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @uitgelicht.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start... | [
"0.65937084",
"0.619209",
"0.61658585",
"0.61470705",
"0.61192083",
"0.5915406",
"0.5867243",
"0.57461524",
"0.5721806",
"0.57134825",
"0.5682877",
"0.5646636",
"0.56340635",
"0.56157887",
"0.55978537",
"0.5580624",
"0.5563756",
"0.5562571",
"0.55426276",
"0.55314",
"0.553050... | 0.6175485 | 2 |
DELETE /uitgelichts/1 DELETE /uitgelichts/1.xml | def destroy
@uitgelicht = Uitgelicht.find(params[:id])
@uitgelicht.destroy
respond_to do |format|
format.html { redirect_to(uitgelichts_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete()\n response = send_post_request(@xml_api_del... | [
"0.7110754",
"0.68970466",
"0.6586678",
"0.65494496",
"0.6522572",
"0.64488226",
"0.64409024",
"0.6413644",
"0.64105874",
"0.6408852",
"0.6398867",
"0.6398867",
"0.63679695",
"0.6366505",
"0.6365412",
"0.6362425",
"0.63615006",
"0.63606495",
"0.6355479",
"0.6331282",
"0.63060... | 0.71049803 | 1 |
These methods were borrowed mostly from ActiveSupport::Cache::FileStore Translate a key into a file path. | def key_file_path(key)
fname = URI.encode_www_form_component(key)
hash = Zlib.adler32(fname)
hash, dir_1 = hash.divmod(0x1000)
dir_2 = hash.modulo(0x1000)
fname_paths = []
# Make sure file name doesn't exceed file system limits.
begin
fname_paths << fname[0, FILENAME_MAX_SIZE]
fname = fname[FILENAME_MAX_SIZE..-1]
end until fname.nil? || fname == ""
File.join(@root_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, *fname_paths)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_to(key)\n key = key.gsub(/[<>:\\\\|?*%]/) {|c| \"%%%03d\" % c.ord}\n File.join(cache_location, key)\n end",
"def convert_path_to_key\n self.key = URI.decode(self.key)\n self.key = self.key[1..-1] if self.key[0] == '/'\n end",
"def path(key, parent_path = nil)\n ... | [
"0.759029",
"0.74594736",
"0.6823198",
"0.68102807",
"0.6717591",
"0.6572764",
"0.6571891",
"0.64730203",
"0.64730203",
"0.64730203",
"0.6390462",
"0.62462807",
"0.6197443",
"0.618549",
"0.6182554",
"0.6138421",
"0.6091116",
"0.60869837",
"0.6080149",
"0.60706484",
"0.6070518... | 0.7109089 | 2 |
Make sure a file path's directories exist. | def ensure_cache_path(path)
FileUtils.makedirs(path) unless File.exist?(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_directory_exists!(path)\n dir = File.dirname(path)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n end",
"def ensure_directory(path)\n FileUtils.mkdir_p(path) unless File.directory?(path)\n end",
"def verify_file_path(file)\n FileUtils.mkdir_p(File.dirname(... | [
"0.79064745",
"0.7441312",
"0.73610723",
"0.73610723",
"0.73502016",
"0.73139507",
"0.7219038",
"0.72031075",
"0.7169845",
"0.7048524",
"0.7023815",
"0.6919219",
"0.69109476",
"0.68576056",
"0.6823415",
"0.671731",
"0.6684012",
"0.668282",
"0.6676702",
"0.66500694",
"0.664558... | 0.61270124 | 80 |
Delete empty directories in the cache. | def delete_empty_directories(dir)
return if File.realpath(dir) == File.realpath(@root_path)
if Dir.entries(dir).reject{ |f| EXCLUDED_DIRS.include?(f) }.empty?
Dir.delete(dir) rescue nil
delete_empty_directories(File.dirname(dir))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.si... | [
"0.74484736",
"0.72695273",
"0.7224882",
"0.7192137",
"0.7184417",
"0.717975",
"0.7045817",
"0.702756",
"0.702756",
"0.6993643",
"0.6937358",
"0.6897493",
"0.68648356",
"0.68648356",
"0.6786617",
"0.67501533",
"0.674533",
"0.6713126",
"0.67045105",
"0.6661749",
"0.6617657",
... | 0.6597416 | 22 |
Adding more comments just to test git Part 1 | def sum arr
# YOUR CODE HERE
lSum = 0
arr.each {|x| lSum += x}
return lSum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def add_comment comment\n \"\\n###### #{comment} ######\\n\" \n end",
"def add_comments_to_issue message, hash, issue, user, cookies, http\n\t# Remove issue# from commit m... | [
"0.66106534",
"0.66106534",
"0.66106534",
"0.66106534",
"0.66106534",
"0.66106534",
"0.65229225",
"0.6486078",
"0.64249206",
"0.637052",
"0.6347806",
"0.6341609",
"0.6313819",
"0.6287324",
"0.62720335",
"0.62720335",
"0.62720335",
"0.62720335",
"0.62720335",
"0.62720335",
"0.... | 0.0 | -1 |
GET /bills (.xml .json) | def index
@bills = current_user_or_guest.bills \
.includes(:user, participations: :person) \
.order("bills.date DESC, bills.created_at DESC")
respond_to do |format|
format.html { @bills = @bills.decorate }
format.xml { render xml: @bills }
format.json { render json: @bills }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bills(options = {})\n get('/bills', options)\n end",
"def index\n @bills = Bills.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bills }\n end\n end",
"def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n form... | [
"0.7811213",
"0.70845217",
"0.70712876",
"0.6872916",
"0.66306514",
"0.6628255",
"0.66280156",
"0.6548527",
"0.6504838",
"0.65031147",
"0.6501341",
"0.6403052",
"0.63609535",
"0.63539654",
"0.62702894",
"0.6267262",
"0.62309045",
"0.62309045",
"0.62309045",
"0.62309045",
"0.6... | 0.63713247 | 12 |
GET /bills/1 (.xml .json) | def show
@bill = current_user_or_guest.bills \
.includes(participations: :person) \
.find(params[:id])
respond_to do |format|
format.html { @bill = @bill.decorate }
format.xml { render xml: @bill }
format.json { render json: @bill }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bills(options = {})\n get('/bills', options)\n end",
"def index\n @bills = Bills.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bills }\n end\n end",
"def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n form... | [
"0.7344486",
"0.7021778",
"0.687081",
"0.6665107",
"0.65328836",
"0.6520921",
"0.65086734",
"0.6450678",
"0.6415788",
"0.6329322",
"0.62344366",
"0.6196069",
"0.6196069",
"0.61886775",
"0.6176276",
"0.6156514",
"0.6150009",
"0.6150009",
"0.6132214",
"0.6120569",
"0.6096582",
... | 0.5892495 | 47 |
GET /bills/new (.xml .json) | def new
friend = params[:friend] ? current_user_or_guest.friends.where(name: params[:friend]).first : nil
@bill = current_user_or_guest.bills.new
@bill.participations.build(person: current_user_or_guest)
@bill.participations.build(person: friend)
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bill }
format.json { render json: @bill }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @bill = Bill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bill }\n end\n end",
"def new\n @bill = Bill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bill }\n end\n end",
... | [
"0.6986785",
"0.69085413",
"0.69085413",
"0.6890151",
"0.6887985",
"0.6881446",
"0.6864652",
"0.68206966",
"0.66963893",
"0.66610456",
"0.6656929",
"0.6653098",
"0.66408324",
"0.66144973",
"0.6572743",
"0.6545941",
"0.65418684",
"0.6536568",
"0.6530602",
"0.65223175",
"0.6515... | 0.0 | -1 |
POST /bills (.xml .json) | def create
@bill = current_user_or_guest.bills.new(bill_params)
respond_to do |format|
if @bill.save
format.html { redirect_to(@bill, notice: t('bill.created')) }
format.xml { render xml: @bill, status: :created, location: @bill }
format.xml { render json: @bill, status: :created, location: @bill }
else
format.html { render action: "new" }
format.xml { render xml: @bill.errors, status: :unprocessable_entity }
format.xml { render json: @bill.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_bill(params)\n build_header_auth('/bills', API_VERSION_1, 'POST')\n build_request()\n p_hash = {}\n p_hash[\"bill\"] = {\"identifier\" => params['id'],\n \"amount_cents\" => params['amount_cents'],\n \"bill_template_id\" => params['bill_template_id'],\n \"memo\" ... | [
"0.6678438",
"0.6421283",
"0.61010283",
"0.59788495",
"0.59672874",
"0.59646213",
"0.59632844",
"0.5908783",
"0.5864968",
"0.5849658",
"0.5849658",
"0.5849658",
"0.5820811",
"0.5819572",
"0.5812822",
"0.579552",
"0.579475",
"0.5745413",
"0.573679",
"0.5729811",
"0.57275474",
... | 0.64690673 | 1 |
PUT /bills/1 (.xml .json) | def update
@bill = current_user_or_guest.bills.find(params[:id])
respond_to do |format|
if @bill.update_attributes(bill_params)
format.html { redirect_to(@bill, notice: t('bill.updated')) }
format.xml { head :ok }
format.json { head :ok }
else
format.html { render action: "edit" }
format.xml { render xml: @bill.errors, status: :unprocessable_entity }
format.json { render json: @bill.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @bill = Bill.find_by(uid:params[:id]).extend(Billit::BillRepresenter)\n @bill.from_json(request.body.read)\n @bill.save\n begin\n Sunspot.index!(@bill)\n rescue\n puts \"#{$!}\"\n puts \"unindexed bill: \" + @bill.uid\n end\n respond_with @bill, :represent_with => B... | [
"0.63594943",
"0.62358344",
"0.6192875",
"0.6069344",
"0.60587233",
"0.60390973",
"0.60390973",
"0.5993949",
"0.59900326",
"0.5988319",
"0.59459394",
"0.58852583",
"0.58749056",
"0.58646774",
"0.5854296",
"0.5820938",
"0.57748646",
"0.5773482",
"0.57488936",
"0.5747137",
"0.5... | 0.62396955 | 1 |
Create friends if given a name instead of a person_id | def participations_attributes_change(attributes)
return unless attributes
attributes.each do |index, participation|
person_id = participation[:person_id]
if person_id !~ /^([0-9]+|)$/
friend = current_user_or_guest.friends.where(name: person_id).first_or_create!
attributes[index][:person_id] = friend.id
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_friend(name)\n # If friend does not already exist, create them without a phone number.\n friend = User.find_by_name name.downcase\n if !friend.nil? && !friend.id.nil?\n puts \"Found user, #{friend.id}, creating Friendship\"\n Friendship.create(:user_1_id => self.i... | [
"0.7673109",
"0.68177044",
"0.6781067",
"0.6755421",
"0.6741334",
"0.6617152",
"0.661675",
"0.66005486",
"0.6591847",
"0.6552507",
"0.65248245",
"0.6519276",
"0.64933246",
"0.6441124",
"0.6412022",
"0.6381305",
"0.6380483",
"0.63627356",
"0.63549006",
"0.63531524",
"0.6350978... | 0.62440336 | 26 |
Mio fermat primary test | def prime?(num)
return false if num <= 1
(1..num-1).each {|n| return false if (((n**num)-num)%num == 0) }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_fe_tests\n end",
"def feruchemist; end",
"def test_resta\n \t\tassert_equal(@ma, (@md-@mz)) #densa\n \t\tassert_equal(@a, (@c-@b)) #fraccionales\n\t\tassert_equal(@mp, (@mr-@mq)) #dispersa\n \tend",
"def test_equality\n fm00 = FMatrix.new(TEST_MATRIX0)\n assert_equal(@fm0, fm00)... | [
"0.62591386",
"0.6232384",
"0.5991018",
"0.5928113",
"0.57853526",
"0.57504225",
"0.5693866",
"0.5654657",
"0.5651182",
"0.55997276",
"0.5583548",
"0.55423754",
"0.5479894",
"0.54747367",
"0.5467539",
"0.54331905",
"0.5401442",
"0.5392029",
"0.53908575",
"0.5370732",
"0.53342... | 0.0 | -1 |
helper methods return expected compressed file downloaded from kubernetes URL | def kubernetes_compressed_file
"#{file_cache_path}/kubernetes-#{version}.tar.gz"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file(url); end",
"def get_file(url)\n get(url).body\n end",
"def file_download\n blob_cache(:file_download) do\n raw_download = tiddlywiki_file.download\n is_compressed? ? SiteCommon.decompress_html(raw_download) : raw_download\n end\n end",
"def fetch_file(url)\n url =~ %r{/(... | [
"0.6732484",
"0.6346367",
"0.62693816",
"0.61792976",
"0.6177468",
"0.6138506",
"0.61369336",
"0.5989891",
"0.59839267",
"0.5973501",
"0.59699667",
"0.59278697",
"0.59057945",
"0.59057945",
"0.58995163",
"0.589399",
"0.5889184",
"0.5886732",
"0.5877112",
"0.58578527",
"0.5857... | 0.7176384 | 0 |
return compressed file inside kubernetes compressed one, containing binaries | def kubernetes_server_compressed_file
'kubernetes/server/kubernetes-server-linux-amd64.tar.gz'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kubernetes_compressed_file\n \"#{file_cache_path}/kubernetes-#{version}.tar.gz\"\n end",
"def kubernetes_server_compressed_file_binaries\n (kube_commands 'kubernetes/server/bin').join(' ')\n end",
"def save\n return if File.exists?(file)\n\n # Create parent directories\n FileUtils.... | [
"0.78948724",
"0.6699559",
"0.61101323",
"0.6033473",
"0.60111773",
"0.59892106",
"0.5985946",
"0.5968883",
"0.58885664",
"0.58517426",
"0.5850673",
"0.58407485",
"0.58313704",
"0.5825484",
"0.5797574",
"0.57637215",
"0.5743681",
"0.5619071",
"0.5599778",
"0.5590789",
"0.5557... | 0.7102132 | 1 |
return path to binaries inside kubernetes compressed | def kubernetes_server_compressed_file_binaries
(kube_commands 'kubernetes/server/bin').join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kubernetes_path_to_binaries\n kube_commands(kubernetes_bin_prefix)\n end",
"def kubernetes_compressed_file\n \"#{file_cache_path}/kubernetes-#{version}.tar.gz\"\n end",
"def kubernetes_server_compressed_file\n 'kubernetes/server/kubernetes-server-linux-amd64.tar.gz'\n end",
"def t... | [
"0.78651416",
"0.72048104",
"0.6893895",
"0.5927885",
"0.5917259",
"0.5904736",
"0.5904736",
"0.5904736",
"0.5840636",
"0.5817541",
"0.58086556",
"0.5771852",
"0.57384753",
"0.5725946",
"0.5698843",
"0.567229",
"0.56702155",
"0.5664406",
"0.56589085",
"0.56441545",
"0.5606868... | 0.7951533 | 0 |
return path to binaries | def kubernetes_path_to_binaries
kube_commands(kubernetes_bin_prefix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin\n File.join(@root, 'bin')\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path\n @bin_path ||= begin\n path = settings[:bin] || \"bin\"\n path = Pathname.new(path).expan... | [
"0.7922231",
"0.78584373",
"0.78584373",
"0.78584373",
"0.75811356",
"0.740417",
"0.7369284",
"0.7348563",
"0.7306702",
"0.72879195",
"0.7229441",
"0.71817505",
"0.71615523",
"0.71440125",
"0.7128909",
"0.7100147",
"0.709084",
"0.70627755",
"0.7047937",
"0.694061",
"0.6848137... | 0.70274484 | 19 |
used for capture screens use class_name and test_case_method_name to generate the image file name | def save_image(class_name, test_case_method_name)
if (WatirBrowser.ie?)
#see if CC_BUILD_ARTIFACTS is set, used by cruise control server
build_artifacts_folder = ENV['CC_BUILD_ARTIFACTS']
if (not build_artifacts_folder.nil?)
build_artifacts_folder = build_artifacts_folder.gsub("/", "\\")
end
#if not set, see if TORNADO_TEST_IMAGE is set
#developer can set this if they want to capture the images on their own machine
if (build_artifacts_folder.nil?)
build_artifacts_folder = ENV['TORNADO_TEST_IMAGE']
end
# build_artifacts_folder = "c:\\railsproject"
unless (build_artifacts_folder.nil?)
file_name = build_artifacts_folder+ "\\" + class_name + "-" + test_case_method_name.to_s + ".png"
if (File.exists?(file_name))
FileUtils.rm(file_name)
end
begin
width, height, bitmap = Win32::Screenshot.desktop
img = Magick::Image.from_blob(bitmap)[0]
img.write(file_name)
rescue Magick::ImageMagickError => e
puts("cannot capture screen. Exception is " + e.message)
end
# @screen_capture = Watir::ScreenCapture
# @screen_capture.screen_capture(file_name, false, false)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename\n \"#{@user.screen_name}.png\"\n end",
"def snagScreenshot\n thing = waitForObject(@symbolicName)\n image = grabWidget(thing)\n format = \"PNG\"\n ssName = thing.name + \".\" + format\n ssLoc = Log.testLogLocation\n image.save(ssLoc + ssName, format)\n Log.AppendLog(\"Taking... | [
"0.67086506",
"0.66478086",
"0.6559881",
"0.65594697",
"0.65407115",
"0.6533541",
"0.65332514",
"0.6516047",
"0.64918214",
"0.64132136",
"0.63631356",
"0.63410944",
"0.6324116",
"0.6300818",
"0.6278885",
"0.62706053",
"0.6248786",
"0.62438685",
"0.6224132",
"0.62184525",
"0.6... | 0.75935334 | 0 |
Assume lowercase and no punctuation. Preserve spaces. | def caesar_cipher(str, shift)
result = ""
str.each_char do |char|
if char == " "
result += " "
next
else
shift.times { char == "z" ? char = 'a' : char = char.next }
result += (char)
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize( text )\n text.gsub(/\\s/,'').gsub(/[[:punct:]]/, '').gsub(/\\p{S}/,'').downcase\nend",
"def normalize\n self.clean_extra_spaces.split.map{|w| w.size>2 ? w.capitalize : w.downcase}.join(' ')\n end",
"def cleanup(input)\n input.gsub(/[^a-zA-Z]/, ' ').squeeze(' ')\nend",
"def spacify(... | [
"0.78323305",
"0.77495545",
"0.7674232",
"0.7620331",
"0.759941",
"0.75981635",
"0.7442333",
"0.7431537",
"0.74275905",
"0.74226564",
"0.7372273",
"0.7369686",
"0.73286384",
"0.7310808",
"0.72997826",
"0.7294919",
"0.72791",
"0.7275613",
"0.7268324",
"0.72437865",
"0.7238439"... | 0.0 | -1 |
def acceptRequest end def declineRequest end | def edit
sender_email = params[:sender_email]
receiver_email = params[:receiver_email]
trip_id = params[:tripid]
tripInvite = TripInvite.find_by_sender_email_and_receiver_email_and_trip_id(sender_email, receiver_email, trip_id)
accepted = params[:accepted]
tripInvite.accepted = accepted
tripInvite.save
redirect_to(trips_path())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive(request); end",
"def end_accepting\n @res\n end",
"def end_accepting\n @res.compact\n end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
... | [
"0.6919941",
"0.6821308",
"0.6367198",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.6316194",
"0.63021904",
"0.62226546",
"0.61896694",
"0.6186473",
"0.6152519",
"0.61120874",
"0.6093161",... | 0.0 | -1 |
Return a new instance of RubyRabbitmqJanus. | def initialize
@option = Tools::Option.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rmq_manager\n @rmq_manager ||= ::RabbitMQManager.new(management_api_url, verify: verify_ssl)\n end",
"def initialize(prefetch: nil, connection_name: nil)\n @configuration = Pwwka.configuration\n connection_options = {automatically_recover: false}.merge(configuration.options)\n ... | [
"0.5669384",
"0.53285277",
"0.53073794",
"0.5276815",
"0.5236017",
"0.5221002",
"0.51587546",
"0.5126813",
"0.49921927",
"0.49868736",
"0.49649885",
"0.49265394",
"0.4922982",
"0.48997906",
"0.48863277",
"0.4885391",
"0.4880731",
"0.48548386",
"0.48105583",
"0.48079863",
"0.4... | 0.0 | -1 |
Delete all resources to JanusInstance reference. Warning: All data in database and Janus Instance is delete | def cleanup_connection!
Models::JanusInstance.destroys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def destroy_all\n all.each do |n|\n n.destroy\n ... | [
"0.7130875",
"0.6857411",
"0.68486476",
"0.67774284",
"0.6736851",
"0.6693895",
"0.6668574",
"0.6668574",
"0.65727186",
"0.6545657",
"0.64972115",
"0.64972115",
"0.64898527",
"0.64898527",
"0.64405733",
"0.6405277",
"0.6400245",
"0.6373441",
"0.6362034",
"0.6336777",
"0.63366... | 0.7270197 | 0 |
allows val to have spaces '1 000,50' and ',' instead of '.' | def forced_val=(val)
if val.is_a? String
val.gsub!(/\s+/, "")
val.sub!(/,/, ".")
end
super(val)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_price(val, ele)\n val.gsub(/[ ,]/, ' ' => '', ',' => '.')\n end",
"def parse_price(val, ele)\n val.gsub(/[ ,]/, ' ' => '', ',' => '.')\n end",
"def entero_pelado(num)\n if num.is_a? String\n num.replace(',', '') if num.include? ','\n num = num.to_f if num.include? '.'\n end\n num.to_... | [
"0.7277193",
"0.7277193",
"0.6636243",
"0.6628169",
"0.6591848",
"0.6590755",
"0.65869313",
"0.6287123",
"0.62481785",
"0.6233119",
"0.6214753",
"0.6144031",
"0.61433196",
"0.6134363",
"0.61289126",
"0.6113969",
"0.60773665",
"0.60593665",
"0.60565686",
"0.6037225",
"0.600869... | 0.6414225 | 7 |
returns currency value fetched from it's source | def fetch
self.send(code + '_value')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\r\r\n @currency[:amount]\r\r\n end",
"def get_Currency()\n \t return @outputs[\"Currency\"]\n \tend",
"def currency\n money.currency\n end",
"def getCurrencyValue(entry)\r\n\r\n # if entry is formatted as currency\r\n if isEntryCurrency?(entry)\r\n\r\n # ... | [
"0.7768419",
"0.7752079",
"0.7472707",
"0.7468096",
"0.74359065",
"0.7320468",
"0.7320468",
"0.7274282",
"0.72417253",
"0.7232182",
"0.7225405",
"0.7202046",
"0.7200516",
"0.7199966",
"0.71754116",
"0.71185833",
"0.71053326",
"0.7100508",
"0.70932984",
"0.70568174",
"0.705681... | 0.0 | -1 |
fetches currency value from it's source and updates the db | def fetch!
self.val = fetch
self.last_updated = Time.zone.now
self.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency_rates\n @currency_rates = fetch_currency_rates\n end",
"def currency; end",
"def currency; end",
"def fetch_updated_currency_rate(currency_type)\n currency_rate = nil\n ApplicationController.new.fetch_currency_rates.select{ |currency| currency_rate = currency if currency[:currency] =... | [
"0.683809",
"0.6582201",
"0.6582201",
"0.6570611",
"0.6483227",
"0.6430546",
"0.64001024",
"0.64001024",
"0.64001024",
"0.64001024",
"0.64001024",
"0.64001024",
"0.63753736",
"0.6360551",
"0.63019407",
"0.63019407",
"0.62939566",
"0.6292627",
"0.62859213",
"0.62785536",
"0.62... | 0.0 | -1 |
fetches exchange rate for the 'usd' currency from cbr.ru | def usd_value
# CBR.ru may not update exchange rate on holidays
# so the we need the most recent exchange rate up to date.
# It is assumed here that exchange rate is updated at least once a month
Time.use_zone('Europe/Moscow') do
today = Time.zone.now
date1 = (today-1.month).strftime("%d/%m/%Y")
date2 = today.strftime("%d/%m/%Y")
url = "http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=#{date1}&date_req2=#{date2}&VAL_NM_RQ=R01235"
begin
page = Net::HTTP::get(URI(url))
xml = Nokogiri::XML(page)
val = xml.xpath('//ValCurs//Record//Value').last.content
m = val.match(/(?<rubl>\d+)(.|,)(?<cop>\d+)/)
BigDecimal("#{m[:rubl]}.#{m[:cop]}")
rescue StandardError => error
# rescuing StandardError is a bad practice
# but for the sake of a simplification
# we don't care here if it's a timeout, 503 or the response xml is malformed
nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rates_for_usd\n rates_for 'USD'\n end",
"def get_usd_exchange_rate\n Sidekiq.logger.debug \"get_usd_exchange_rate\"\n begin\n today = Time.now.strftime '%d/%m/%Y'\n uri = \"http://www.cbr.ru/scripts/XML_daily.asp?date_req=#{today}\"\n doc = Nokogiri::XML(open(uri))\n ... | [
"0.7965585",
"0.7875051",
"0.77092934",
"0.76406807",
"0.7303335",
"0.72802454",
"0.7236889",
"0.72345155",
"0.7223905",
"0.7157926",
"0.71284616",
"0.71086377",
"0.709451",
"0.7080802",
"0.7050337",
"0.7050337",
"0.7050337",
"0.7050337",
"0.70262355",
"0.70211214",
"0.701245... | 0.6789997 | 30 |
runs BroadcastChangeJob when a currency is updated | def broadcast_change
# don't broadcast submits from /admin when nothing changed
BroadcastChangeJob.perform_now(self) unless previous_changes.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_currency_rate\n current_rate = CurrencyRate.current_rate ||\n CurrencyRate.create(rate: 57.00, is_force: false)\n return if current_rate.force?\n current_rate.update!(rate: actual_rate.to_f)\n ActionCable.server.broadcast 'actual_rate', rate: current_rate.rate, from: 'Update currency ... | [
"0.654031",
"0.60242623",
"0.5823485",
"0.56981236",
"0.5661573",
"0.5654395",
"0.5646562",
"0.5618993",
"0.55831015",
"0.5570277",
"0.55492926",
"0.55345833",
"0.55275923",
"0.5458093",
"0.5440395",
"0.54165274",
"0.54142654",
"0.540491",
"0.539972",
"0.5392471",
"0.5391348"... | 0.6422325 | 1 |
Couple of notes about this test. It checks that fluid variable names can be strings or symbols. It checks that the values can be complex objects or references. | def test_multiple_variables
dval = ["dval"]
Fluid.let([:a, 1],
:b,
["c", [1, 2]],
[:d, dval]) {
assert_equal(1, Fluid.a)
assert_equal(nil, Fluid.b)
assert_equal([1, 2], Fluid.c)
assert_equal(dval, Fluid.d)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unknown_type\n assert_raise TypeError do\n DefineVariableEval.new(\"FAKE\", \"name\").eval\n end\n end",
"def check_vars\n @to_load.each do |hash|\n assert_not_nil(instance_variable_get(hash[:name]))\n end\n end",
"def expect_string name, value\n expect_type name,\n ... | [
"0.5879811",
"0.5698975",
"0.5600958",
"0.55845845",
"0.5580763",
"0.55114394",
"0.5482631",
"0.5454025",
"0.5366952",
"0.53304607",
"0.5291465",
"0.52825683",
"0.5261755",
"0.525611",
"0.52526355",
"0.523142",
"0.5231332",
"0.52223414",
"0.5197227",
"0.51800203",
"0.51788986... | 0.64346164 | 0 |
Assignment is parallel, as in Lisp let, not let This is inherent in Ruby arg evaluation, but thought I would document it here. let is impossible, I think. | def test_assignment_is_parallel
Fluid.let([:dawn, "best beloved"]) {
assert_equal("best beloved", Fluid.dawn)
Fluid.let([:dawn, "wife"],
[:paul, "child of #{Fluid.dawn}"]) {
assert_equal("wife", Fluid.dawn)
assert_equal("child of best beloved", Fluid.paul)
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def let(name, &block); end",
"def assignment\n name = get_name\n comment name\n define_variable name\n match \"=\"\n comment \"=\"\n expression\n emitln \"leaq #{name}(%rip), %rdx\"\n emitln \"movl %eax, (%rdx)\"\nend",
"def let_op(arr, variables, l_n)\n keyword_ops = KeywordOperations.new\n line... | [
"0.67674935",
"0.6317832",
"0.62309235",
"0.6170764",
"0.6089923",
"0.60597473",
"0.6013463",
"0.5991442",
"0.5990811",
"0.5975124",
"0.5967482",
"0.5929644",
"0.5929644",
"0.5919614",
"0.5919614",
"0.5919614",
"0.5919614",
"0.5919614",
"0.5919614",
"0.5919614",
"0.5919614",
... | 0.68226624 | 0 |
Test that pushing and popping of values works correctly. Note that this also checks whether the noop form (no vars) in fact has no effect. | def test_nesting_behavior_simple_within_method
Fluid.let([:a, 1]) {
assert_equal(1, Fluid.a)
Fluid.let {
assert_equal(1, Fluid.a)
Fluid.let([:a, 2]) {
assert_equal(2, Fluid.a)
}
assert_equal(1, Fluid.a)
}
assert_equal(1, Fluid.a)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_push_and_pop\n\tn = Stack.new()\n\tn.push(3)\n\tn.push(4)\n\tn.push(5)\n\tassert_equal(5, n.pop)\n\tassert_equal(4, n.pop)\n\tassert_equal(3, n.pop)\n\tassert_raise(RuntimeError) {n.pop}\n end",
"def test_pushing_and_popping_arrays\n array = [1,2]\n array.push(:last)\n\n assert_equal [1, 2, :l... | [
"0.6955326",
"0.6925275",
"0.6675631",
"0.66119087",
"0.64337415",
"0.59526527",
"0.5938363",
"0.5797402",
"0.5778314",
"0.57496893",
"0.568005",
"0.56755",
"0.5667313",
"0.561686",
"0.56167626",
"0.55682635",
"0.5552581",
"0.5535908",
"0.5535908",
"0.5535908",
"0.5535908",
... | 0.0 | -1 |
Check that multiple variables are pushed and popped appropriately. | def test_nesting_behavior_complex_within_method
Fluid.let([:a, 1], :b) {
assert_equal(1, Fluid.a)
assert_equal(nil, Fluid.b)
Fluid.let(:a) {
assert_equal(nil, Fluid.a)
assert_equal(nil, Fluid.b)
Fluid.let([:b, 'b'],
[:a, [1, 2]]) {
assert_equal([1,2], Fluid.a)
assert_equal('b', Fluid.b)
}
assert_equal(nil, Fluid.a)
assert_equal(nil, Fluid.b)
}
assert_equal(1, Fluid.a)
assert_equal(nil, Fluid.b)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_push_and_pop\n\tn = Stack.new()\n\tn.push(3)\n\tn.push(4)\n\tn.push(5)\n\tassert_equal(5, n.pop)\n\tassert_equal(4, n.pop)\n\tassert_equal(3, n.pop)\n\tassert_raise(RuntimeError) {n.pop}\n end",
"def pop()\n @VAR_STACK.pop()\n end",
"def pop()\n return @VAR_STACK.pop()\n end",
"def ... | [
"0.624122",
"0.6038729",
"0.5745766",
"0.5745766",
"0.57289654",
"0.557238",
"0.55151826",
"0.5454296",
"0.54541624",
"0.544573",
"0.5418951",
"0.54056144",
"0.5390609",
"0.5353107",
"0.5344005",
"0.5344005",
"0.53366864",
"0.5329589",
"0.5324784",
"0.5321852",
"0.528429",
... | 0.0 | -1 |
UNWINDING This is an example that shows how bindings are unwound or not unwound as control passes out of a block in various ways that involve calls to other methods. Shows how variable bindings are independent of the call stack. | def test_nesting_behavior_across_methods
Fluid.let([:paul, 6],
[:sophie, 5]) {
ordinary_subfunction # add one to age.
assert_equal(7, Fluid.paul)
assert_equal(6, Fluid.sophie)
# Values are unwound in presence of catch.
catch_value = catch(:catcher) {
Fluid.let([:paul, 66]) {
assert_equal(66, Fluid.paul)
assert_equal(6, Fluid.sophie)
throwing_subfunction
# This changes both variables, but only
# the change to Sophie will be visible outside the let block
}
}
assert_equal(55600, catch_value)
assert_equal(7, Fluid.paul)
assert_equal("sophster", Fluid.sophie)
# Values are unwound with exceptions as well
begin
Fluid.let([:sophie, "leewit"]) {
assert_equal(7, Fluid.paul)
assert_equal("leewit", Fluid.sophie)
raising_subfunction
# This changes both variables, but only
# the change to Paul will be visible outside the let block
}
rescue RuntimeError
assert_equal(nil, Fluid.paul)
assert_equal("sophster", Fluid.sophie)
return
end
fail("Should not reach here.")
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f\n x = 3\n b = binding()\n b\nend",
"def double_bind; 1; end",
"def breakpoint binding; IRB.start_with_binding binding end",
"def local_binding\n binding\n end",
"def without_bindings_below_raise(bindings); end",
"def binding() end",
"def binding() end",
"def begin_bind\n bind_stack.... | [
"0.64411145",
"0.600972",
"0.59777695",
"0.59641457",
"0.5914064",
"0.58271205",
"0.58271205",
"0.5733877",
"0.5687858",
"0.5684123",
"0.56325054",
"0.56325054",
"0.5592392",
"0.5585462",
"0.55039763",
"0.5498924",
"0.5495972",
"0.5472778",
"0.5398814",
"0.53819984",
"0.53803... | 0.0 | -1 |
the bonus for a given salary. If the boolean is true, the bonus should be half of the salary. If the boolean is false, the bonus should be 0. Understand the problem: MEthod takes two arguments, pos int and boolean If boolean is true, return integer/2 Else return 0 Questions: Can bonus value be a float? Inputs: integer, boolean Outputs: float Data Structures Integer and boolean for inputs Float for output Boolean to verify bonus Logical flow: START GET integer, boolean IF boolean == true RETURN integer / 2.0 ELSE RETURN 0 END END | def bonus integer, boolean
boolean == true ? (integer / 2.0) : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n else\n 0\n end\nend",
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n else\n 0\n end\nend",
"def calculate_bonus(salary,boolean)\n \n if boolean == true\n return (salary / 2) \n else\n return 0\n... | [
"0.8429453",
"0.83985406",
"0.838818",
"0.8375707",
"0.8340893",
"0.8311719",
"0.83005166",
"0.82834655",
"0.8269639",
"0.8174287",
"0.8151206",
"0.79485184",
"0.78952163",
"0.7891715",
"0.7880669",
"0.78725785",
"0.7866871",
"0.7866871",
"0.7866871",
"0.7866871",
"0.7866871"... | 0.7815185 | 25 |
if number < 0 return true end return false end puts negative?(2) puts negative?(4) puts negative?(12) | def is_even?(number)
if number % 2 == 0
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_negative(number)\n if number < 0\n output = true\n else\n output = false\n end\n return output\nend",
"def is_negative(number)\n output = false\n if number < 0\n output = true\n end\n return output\nend",
"def negative(num)\n return num<0\nend",
"def is_... | [
"0.82651836",
"0.82501745",
"0.80713546",
"0.80706084",
"0.8017121",
"0.8015311",
"0.8005302",
"0.7940057",
"0.7933048",
"0.78372455",
"0.7780027",
"0.77239215",
"0.7694345",
"0.7646903",
"0.7640619",
"0.76131034",
"0.75996476",
"0.75265825",
"0.74962056",
"0.7462815",
"0.746... | 0.0 | -1 |
Use `app.config.log_tags` to inject propagation tags into the default Rails logger. | def configure_log_tags(app_config)
# When using SemanticLogger, app_config.log_tags could be a Hash and should not be modified here
return unless app_config.log_tags.nil? || app_config.log_tags.respond_to?(:<<)
app_config.log_tags ||= [] # Can be nil, we initialized it if so
app_config.log_tags << proc { Tracing.log_correlation if Datadog.configuration.tracing.log_injection }
rescue StandardError => e
Datadog.logger.warn(
"Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class.name} #{e.message}"
)
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_logger(**tags)\n logger_tags =\n { url: request.url,\n ip: request.ip,\n user_id: current_user.id,\n params: params.to_unsafe_h }.merge(tags)\n\n Helli::Logger.new(logger_tags)\n end",
"def log_tags; end",
"def log_tags; end",
"def log_tags; end",
"def new_tagged_lo... | [
"0.6897192",
"0.6872864",
"0.6872864",
"0.6872864",
"0.6400524",
"0.63183826",
"0.6192875",
"0.6163894",
"0.6116013",
"0.6094201",
"0.6086219",
"0.59977186",
"0.59972477",
"0.5981637",
"0.5981637",
"0.5981637",
"0.5923562",
"0.57789665",
"0.57723796",
"0.56779903",
"0.5658338... | 0.7845741 | 0 |
This is pulled out into a separate method so that users can subclass and implement custom behavior if they'd like to work around this step. | def run_provisioner(env)
env[:provisioner].provision
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def overrides; end",
"def custom; end",
"def custom; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def internal; end",
"def original; end",
"def process_fix\n... | [
"0.7241512",
"0.60846287",
"0.6056202",
"0.6056202",
"0.60271096",
"0.60271096",
"0.58853877",
"0.5866056",
"0.5866056",
"0.5866056",
"0.5866056",
"0.584321",
"0.5740588",
"0.57262146",
"0.5688628",
"0.5688628",
"0.5688628",
"0.5680744",
"0.56605154",
"0.5634049",
"0.56283134... | 0.0 | -1 |
def create POST /en/support/amx_itg_new_module_request Callback after uploading a file directly to S3. Adds the temporary S3 path to the form before creating new amx itg module request. | def upload
@direct_upload_url = params[:direct_upload_url]
respond_to do |format|
format.js { render template: "#{website.folder}/module_requests/upload.js", layout: false }
end # respond_to do |format|
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_upload_request\n call(:post, upload_path)\n end",
"def create_multipart_upload\n self.s3_object||= Upload.get_s3_object(self.object_key)\n self.multipart_upload = s3_object.multipart_upload(\n content_type: params[:type],\n server_side_encryption: S3BrowserMultipart... | [
"0.6322573",
"0.607222",
"0.58934987",
"0.58785343",
"0.5743943",
"0.5697533",
"0.5692353",
"0.5675924",
"0.5652646",
"0.56524426",
"0.55999273",
"0.5561951",
"0.5559457",
"0.55449754",
"0.55340856",
"0.55320096",
"0.5524004",
"0.55081475",
"0.54802203",
"0.54580396",
"0.5425... | 0.5190217 | 49 |
A radio button that acts like a link | def filter_radio_link(title, key, value=nil)
url = params.permit(AdminController::FILTER_PARAMS)
url.merge!(key => value)
content_tag :label do
radio_button_tag(key, value, params[key] == value, onclick:
"window.location.href = '#{url_for(url)}'") + ' ' + title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def radio_button; end",
"def radio_button(method, tag_value, options = T.unsafe(nil)); end",
"def radio_button(object_name, method, tag_value, options = T.unsafe(nil)); end",
"def radio_button_tag(name, value, checked = T.unsafe(nil), options = T.unsafe(nil)); end",
"def format_radio\n @attr[:checked]... | [
"0.70422125",
"0.6949882",
"0.6874103",
"0.6693451",
"0.6669212",
"0.6609878",
"0.6525756",
"0.6501904",
"0.6428139",
"0.6346062",
"0.6326436",
"0.63139105",
"0.62571514",
"0.6201526",
"0.6196277",
"0.61740965",
"0.61072874",
"0.6087432",
"0.6082776",
"0.60304135",
"0.6022103... | 0.69649583 | 1 |
GET /blivots GET /blivots.json | def index
@blivots = Blivot.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }... | [
"0.66646254",
"0.6615394",
"0.652966",
"0.6408298",
"0.6397785",
"0.6354702",
"0.62993634",
"0.62981606",
"0.6297946",
"0.6294464",
"0.6220694",
"0.62067705",
"0.6193752",
"0.61787546",
"0.61720645",
"0.6170109",
"0.616915",
"0.6161167",
"0.6139413",
"0.6136271",
"0.61239314"... | 0.7370544 | 0 |
GET /blivots/1 GET /blivots/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @blivots = Blivot.all\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb... | [
"0.73242116",
"0.67954916",
"0.6696014",
"0.66148645",
"0.65188634",
"0.64744216",
"0.647049",
"0.64361906",
"0.6424152",
"0.63581425",
"0.635288",
"0.6330699",
"0.6324082",
"0.6301763",
"0.63016695",
"0.6300192",
"0.6284967",
"0.626521",
"0.62469107",
"0.6186154",
"0.6185889... | 0.0 | -1 |
POST /blivots POST /blivots.json | def create
@blivot = Blivot.new(blivot_params)
respond_to do |format|
if @blivot.save
format.html { redirect_to @blivot, notice: 'Blivot was successfully created.' }
format.json { render :show, status: :created, location: @blivot }
else
format.html { render :new }
format.json { render json: @blivot.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blivot_params\n params.require(:blivot).permit(:name, :description, :priority)\n end",
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n ... | [
"0.6202293",
"0.61269224",
"0.61128575",
"0.6090744",
"0.6017969",
"0.59347695",
"0.58586186",
"0.5840211",
"0.57936454",
"0.5787843",
"0.5769099",
"0.5751852",
"0.5741881",
"0.57357204",
"0.57198143",
"0.5708181",
"0.57061625",
"0.56945807",
"0.5668452",
"0.5667658",
"0.5664... | 0.7383293 | 0 |
PATCH/PUT /blivots/1 PATCH/PUT /blivots/1.json | def update
respond_to do |format|
if @blivot.update(blivot_params)
format.html { redirect_to @blivot, notice: 'Blivot was successfully updated.' }
format.json { render :show, status: :ok, location: @blivot }
else
format.html { render :edit }
format.json { render json: @blivot.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @boolio.update( boolio_params )\n format.html { redirect_to @boolio, notice: 'Boolio was succes... | [
"0.6649964",
"0.62834567",
"0.62797236",
"0.6250795",
"0.6241681",
"0.62191737",
"0.6216971",
"0.62164456",
"0.62023056",
"0.6197287",
"0.6169659",
"0.6162733",
"0.6142059",
"0.6139831",
"0.61369777",
"0.6118562",
"0.6085268",
"0.60801166",
"0.60784477",
"0.6077421",
"0.60774... | 0.71614224 | 0 |
DELETE /blivots/1 DELETE /blivots/1.json | def destroy
@blivot.destroy
respond_to do |format|
format.html { redirect_to blivots_url, notice: 'Blivot was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |... | [
"0.6892205",
"0.67797726",
"0.6763826",
"0.66973627",
"0.66879976",
"0.66584986",
"0.66343397",
"0.6616035",
"0.6613325",
"0.6610674",
"0.6594684",
"0.6594684",
"0.6594684",
"0.6594684",
"0.6585603",
"0.6573828",
"0.6564528",
"0.65382445",
"0.6530527",
"0.653042",
"0.65243936... | 0.729978 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_blivot
@blivot = Blivot.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def blivot_params
params.require(:blivot).permit(:name, :description, :priority)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Get all Basic and MK resources linked to the given InsurancePlan | def get_related_basic_and_medicationknowledge(formulary_id, output_directory)
p "==============================================================="
p "Getting all Basic and MedicationKnowledge related to Formulary with ID= #{formulary_id}..."
id_digits = formulary_id.split("-").last
basic_files = get_resource_json_files("output/Basic").select { |f_name| f_name.include?(id_digits) }
basic_resources = basic_files.map { |json_f| JSON.parse(File.read(json_f), symbolize_names: true) }
# Get the reference ids to retrieve related medication_knowledge_resources
ref_ids = basic_resources.map { |resource| resource[:id].split("-").last }
medication_knowledge_files = get_resource_json_files("output/MedicationKnowledge").select { |f_name| ref_ids.any? { |id| f_name.include?(id) } }
medication_knowledge_resources = medication_knowledge_files.map { |json_f| JSON.parse(File.read(json_f), symbolize_names: true) }
p "There are #{basic_resources.size} Basic resources and #{medication_knowledge_resources.size} MedicationKnowledge resources related to Formulary with ID = #{formulary_id}"
generate_ndjson("Basic", basic_resources, output_directory)
generate_ndjson("MedicationKnowledge", medication_knowledge_resources, output_directory)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n ... | [
"0.6476862",
"0.61637306",
"0.59969175",
"0.59577227",
"0.5957677",
"0.59026456",
"0.59026456",
"0.5887725",
"0.5883082",
"0.5823908",
"0.5782987",
"0.57603323",
"0.57583386",
"0.5753293",
"0.57437235",
"0.5737668",
"0.5717098",
"0.57101125",
"0.57063633",
"0.5689049",
"0.567... | 0.0 | -1 |
Retrieve location resources with given ids | def get_related_locations(location_ids, output_directory)
specific_locations = LOCATIONS.find_all { |loc| location_ids.include?(loc[:id]) }
generate_ndjson("Location", specific_locations, output_directory)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLocationMultiple( location_ids)\n params = Hash.new\n params['location_ids'] = location_ids\n return doCurl(\"get\",\"/location/multiple\",params)\n end",
"def locations id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/locations?date=#{date}\"\n fetch uri\n end",
"def... | [
"0.71915305",
"0.66039115",
"0.6514846",
"0.63564366",
"0.6350984",
"0.63336354",
"0.6306222",
"0.62899995",
"0.626391",
"0.62232095",
"0.6202738",
"0.61738664",
"0.61065996",
"0.60780036",
"0.6059994",
"0.6047095",
"0.6042544",
"0.60152715",
"0.59960157",
"0.5983438",
"0.597... | 0.7088666 | 1 |
Writing ndjson files for a given resource type | def generate_ndjson(resource_type, resource_list, output_directory)
p "==============================================================="
p "Generating ndjson file of type #{resource_type}..."
outfile = File.join(output_directory, "#{resource_type}.ndjson")
ndout = {
type: resource_type,
url: "#{FHIR_SERVER}/resources/#{output_directory.split("/").last}/#{resource_type}.ndjson",
}
NDOUTS << ndout
begin
o = File.open(outfile, "w")
p "Writing #{resource_list.size} #{resource_type} resource instances to #{outfile}..."
resource_list.each { |instance| o.puts(JSON.generate(instance)) }
rescue StandardError => e
puts "An error occured when generating file #{outfile}: #{e.message}"
ensure
o.close
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_example\n results = @example.to_h\n results[\"resourceType\"] = @resource_name\n\n FileUtils.mkdir_p(\"examples/#{@ig_name}\") unless File.exist?(\"examples/#{@ig_name}\")\n File.open(\"examples/#{@ig_name}/#{@example_num}_#{@resource_id}.json\", \"w+\") do |f|\n f.print JSON.p... | [
"0.6428719",
"0.62160623",
"0.6064104",
"0.60448027",
"0.57028365",
"0.56984794",
"0.5661703",
"0.5628166",
"0.56227505",
"0.5612708",
"0.56051254",
"0.5579941",
"0.5548465",
"0.54908013",
"0.5468651",
"0.54446054",
"0.5440777",
"0.5403764",
"0.5394517",
"0.53881127",
"0.5366... | 0.79356575 | 0 |
Constructs and write the export.json file to the specified destination | def generate_export_json(output_directory, request, output)
export = {
transactionTime: Time.now.strftime("%FT%T%:z"),
request: request,
requiresAccessToken: false,
output: output,
}
file_path = File.join(output_directory, "export.json")
File.open(file_path, "w") do |file|
file.write(JSON.pretty_generate(export))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destination(lang)\n output_path.mkpath\n\n path = output_path.join(\"#{lang}.json\")\n path.open(\"w\") do |f|\n f.write yield\n end\n\n puts \"Created #{path}\"\n end",
"def guarda nombre, data\n fname = \"#{$outDir}/#{nombre}.json\"\n puts \"Creando #{fname}\"\n FileUt... | [
"0.66782683",
"0.6615198",
"0.65695995",
"0.65356046",
"0.64995867",
"0.64946556",
"0.6475175",
"0.64228755",
"0.64063466",
"0.6399282",
"0.63698274",
"0.6356521",
"0.6356521",
"0.6345739",
"0.62830836",
"0.628093",
"0.6176779",
"0.612171",
"0.612171",
"0.60403967",
"0.603894... | 0.6973751 | 0 |
Group payer insurance resources with their associated Formulary, Basic, MK, and Location resources | def generate_payer_bulk_data
p "There are no payer resources available to generate bulk data." if PAYERS.empty?
PAYERS.each do |payer|
NDOUTS.clear
request = "#{FHIR_SERVER}/fhir/InsurancePlan/#{payer[:id]}/$export"
output_directory = File.join("bulk_export", payer[:id])
FileUtils.mkdir_p(output_directory)
related_formularies_id = []
payer[:coverage].each do |coverage|
formulary = coverage[:extension].find { |ext| ext[:url] == "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-FormularyReference-extension" }
unless formulary.nil?
related_formularies_id << formulary[:valueReference][:reference].split("/").last
end
end
related_formularies = FORMULARIES.find_all { |formulary| related_formularies_id.include?(formulary[:id]) }
related_formularies.prepend(payer)
generate_ndjson("InsurancePlan", related_formularies, output_directory)
related_formularies_id.each { |id| get_related_basic_and_medicationknowledge(id, output_directory) }
location_ids = extract_location_id_from_reference(payer[:coverageArea])
get_related_locations(location_ids, output_directory)
generate_export_json(output_directory, request, NDOUTS)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associate_records_to_groups\n put_isos_into_iso_group\n put_agents_into_iso_group\n put_merchants_into_iso_group\n end",
"def contract_other_people\n result = []\n booking_line_resources.each do |resource|\n result << { :name => resource.resource_user_name,\n ... | [
"0.56529367",
"0.5573831",
"0.53878367",
"0.5209391",
"0.520747",
"0.52067286",
"0.5163551",
"0.5127861",
"0.50617254",
"0.50435954",
"0.50365245",
"0.5021574",
"0.501354",
"0.49727845",
"0.4972702",
"0.49628776",
"0.49492425",
"0.49205112",
"0.4919505",
"0.4919505",
"0.49177... | 0.5971659 | 0 |
Group each formulary resource with its associated Location, Basic, and MedicationKnowledge resources. | def generate_formulary_bulk_data
p "There are no Formulary resources available to generate bulk data." if FORMULARIES.empty?
FORMULARIES.each do |formulary|
NDOUTS.clear
request = "#{FHIR_SERVER}/fhir/InsurancePlan/#{formulary[:id]}/$export"
output_directory = File.join("bulk_export", formulary[:id])
FileUtils.mkdir_p(output_directory)
generate_ndjson("InsurancePlan", [formulary], output_directory)
get_related_basic_and_medicationknowledge(formulary[:id], output_directory)
location_ids = extract_location_id_from_reference(formulary[:coverageArea])
get_related_locations(location_ids, output_directory)
generate_export_json(output_directory, request, NDOUTS)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resources\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:resources] || {})\n rescue NoMethodError\n memo\n end\n end\n end",
"def get_related_basic_and_medicationknowledge(formul... | [
"0.58098537",
"0.5705369",
"0.5703479",
"0.5459368",
"0.5427924",
"0.542095",
"0.5381391",
"0.5381391",
"0.53582186",
"0.53415126",
"0.5331894",
"0.5321933",
"0.5315519",
"0.53016007",
"0.52754885",
"0.52667004",
"0.5250493",
"0.52483225",
"0.5236072",
"0.5220954",
"0.5154887... | 0.5455224 | 4 |
Generates the grouped bulk data export | def generate_bulk_export
# Delete the bulk_export directory if it exists.
FileUtils.rm_rf("bulk_export")
get_all_insurance_plans
get_all_location_resources
p "==============================================================="
p "Creating the Bulk export folder output ..."
generate_payer_bulk_data
generate_formulary_bulk_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bulk_generate\n\n end",
"def export\n group.each do |date, records|\n save_date(date.strftime(\"%Y%m%d\"), records)\n end\n end",
"def export_csv\n\n group_array = []\n @page = 1\n @per_page = 50\n\n groups = @context.get(:groups, :page => @page, :per_page => @... | [
"0.722556",
"0.67511034",
"0.6655338",
"0.6630081",
"0.6617904",
"0.65185386",
"0.65010893",
"0.64019436",
"0.63209665",
"0.631272",
"0.6207422",
"0.618417",
"0.6183393",
"0.610469",
"0.6067625",
"0.6052679",
"0.6020156",
"0.60189766",
"0.5998681",
"0.59928143",
"0.5958197",
... | 0.7328246 | 0 |
NOTE The ordering of latitude and longitude for indexing geo points is different based on whether a string or an array is used. The order when using an array should be [longitude, latitude] versus for a string where it should be "latitude,longitude". See The elasticsearch documentation for more information. | def lat_lon
[latitude, longitude].join(',')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mongoize\n\t{:type => 'Point', :coordinates => [@longitude, @latitude]}\nend",
"def elasticsearch_sample\n results = Tweet.all\n if params[:geo]\n results = results.collect do |redis_arr|\n tweet = JSON.parse redis_arr[-1]\n [tweet['lat'].to_f, tweet['lon'].to_f]\n end\n re... | [
"0.61990637",
"0.5952278",
"0.5918241",
"0.5810913",
"0.57830584",
"0.57430404",
"0.5637625",
"0.5584147",
"0.55765593",
"0.55291766",
"0.551273",
"0.55113834",
"0.54967433",
"0.54886264",
"0.54856694",
"0.5479625",
"0.5445003",
"0.54300994",
"0.54293096",
"0.54228437",
"0.54... | 0.0 | -1 |
Merge address, city, state code in one line | def full_address
[address, city, state_code, zip].compact.uniq.join ' '
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_address\n [address, city, state].join(' ')\n end",
"def full_address\n city.present? ? city_delim = city + \",\" : city_delim = city\n [address_1, address_2, city_delim, state, zip].reject(&:nil? || empty?).join(' ')\n end",
"def address\n [address_line_1, address_line_2, town_city... | [
"0.75243205",
"0.74115664",
"0.7405797",
"0.73689073",
"0.73159707",
"0.7263147",
"0.7243508",
"0.7227665",
"0.7221227",
"0.7220683",
"0.71895576",
"0.71181184",
"0.71174675",
"0.7114949",
"0.71078986",
"0.71066874",
"0.70994955",
"0.70692885",
"0.70681167",
"0.7046961",
"0.7... | 0.7561961 | 0 |
return name + ful_address | def name_and_full_address
[name, full_address].join ' - '
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_address; end",
"def full_address\n return\"#{self.client},#{self.rep_address_one} #{self.rep_address_two},#{self.city},#{self.state},#{self.zipcode}\"\n end",
"def address_full\n \"#{self.address.titleize}, Toronto, ON\"\n end",
"def recipient_full_name\n ship_address.first_name + ' ' + s... | [
"0.73559994",
"0.7327775",
"0.73193264",
"0.73162967",
"0.72764516",
"0.72445035",
"0.7240377",
"0.7222262",
"0.71292114",
"0.7124992",
"0.71209425",
"0.71108836",
"0.71071815",
"0.7098568",
"0.70387244",
"0.70351535",
"0.70340186",
"0.7026232",
"0.6974387",
"0.69627213",
"0.... | 0.77244085 | 0 |
Trying to use perform but not sure of the result | def perform
multiples_3_and_5()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform(*args); end",
"def perform; end",
"def perform; end",
"def _perform(args); end",
"def perform\n \n end",
"def perform(*args)\n\tend",
"def perform(&block); end",
"def perform(*args)\n # Do something\n puts \"perform successfully\"\n end",
"def perform\n begin\n su... | [
"0.759665",
"0.7517607",
"0.7517607",
"0.74676913",
"0.7206969",
"0.7160798",
"0.70237947",
"0.70168084",
"0.6957003",
"0.68415606",
"0.6793601",
"0.67056286",
"0.67056286",
"0.6664065",
"0.6648958",
"0.6632513",
"0.65746474",
"0.65746474",
"0.65746474",
"0.6569491",
"0.65277... | 0.0 | -1 |
main pairsgame is spawned with 5 ports as arguments first two ports are REP ports for the GameSession next two ports are REQ ports for each of the Players final port is PUB port for GameSession (SUB port for all Players) | def abort_on_bad_reply(reply)
if reply != 'ready'
$LOG.error "Illegal reply from ready command"
exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n @s = TCPSocket.open(@server, @port)\n @s.puts \"USER internbot 0 * InternBot\"\n @s.puts \"NICK #{@nick}\"\n @s.puts \"JOIN #{@channel}\"\n\n # main receive loop\n until @s.eof? do\n msg = @s.gets\n msg_pieces = msg.split(':')\n ... | [
"0.57408184",
"0.5633571",
"0.5627457",
"0.56103295",
"0.55918866",
"0.5556806",
"0.55499077",
"0.548616",
"0.54717773",
"0.5468648",
"0.5458161",
"0.5413021",
"0.53576887",
"0.5294726",
"0.52809864",
"0.5272816",
"0.5271951",
"0.5253805",
"0.5250142",
"0.5222915",
"0.5208279... | 0.0 | -1 |
What would be output by this code? | def test_mutate_array_pop
numbers = [1, 2, 3, 4]
output = capture_io do
numbers.each do |number|
p number
numbers.pop(1)
end
end
assert_equal ["1\n2\n", ""], output
assert_equal [1, 2], numbers
=begin
this follows the same pattern as the last example but since
elements are take from the back end of the array, the first
two p statement do print the first two elements of the array.
after 2 pop operations the array index exceeds the index of
the last element in the array.
=end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"... | [
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.6470049",
"0.64449507",
"0.62543577",
"0.6136811",
"0.6136811",
"0.6136811",
"0.6136811",
... | 0.0 | -1 |
write the register to database | def write(db)
register_id = nil
db.transaction do
result = db[:registers].where(name: @name).first
register_id = if result
result[:id]
else
db[:registers].insert(name: @name)
end
end
dupe_count = 0
@values.each do |data|
begin
# simulate insert ignore
db.transaction do
count = db[:series].where(time: data[:time], register_id: register_id).count
if count < 1
db[:series].insert(time: data[:time], watt_hours: data[:wh],
joules: data[:joules], register_id: register_id)
else
dupe_count += 1
end
end
rescue Sequel::UniqueConstraintViolation => e
dupe_count += 1
end
end
LOGGER.warn "#{dupe_count} duplicate metrics not recorded for register #{@name}." if dupe_count > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register()\n\tentry = {\"userid\" => @userid, \"username\" => @username, \"email\" => @email, \"password\" => @password}\n\tDATABASE.newEntry(\"users\", entry)\n\tend",
"def register\n \n end",
"def register\r\n \r\n end",
"def register\n end",
"def register\n end",
"def register\n end... | [
"0.700723",
"0.65425074",
"0.64734465",
"0.63128257",
"0.62700653",
"0.62700653",
"0.62700653",
"0.6245012",
"0.62379044",
"0.62292737",
"0.61903054",
"0.6182793",
"0.6160409",
"0.6159142",
"0.6121475",
"0.61172676",
"0.6101468",
"0.6045362",
"0.6044337",
"0.60349023",
"0.602... | 0.57803243 | 40 |
normalize the register name and turn it into a symbol with underscores plus a shortened sha1 hash this can cause name collisions, in theory "Date & Time" => 'date_time_a9993e36470' "Register 1 [kWh]" => 'register_1_kwh_a9993e36470' | def normalize_name
lower = @name.downcase
non_word = lower.gsub(/\W/,'_').gsub(/_+/,'_')
normalized = non_word.split('_').compact.join('_')
[normalized, Digest::SHA1.hexdigest(@name)[0..10]].join('_')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digest_short_name(name)\n Digest::SHA2.hexdigest(name)[0..24]\n end",
"def _unique_name\n string = aliases.split(\",\").sort_by{|x| x.downcase}.join(\", \")\n Digest::SHA1.hexdigest string\n end",
"def digest_name(name)\n Digest::SHA2.hexdigest(short_name(name))[0..24]\n ... | [
"0.6875645",
"0.6745856",
"0.6724027",
"0.649508",
"0.63414395",
"0.6153128",
"0.6062882",
"0.6050871",
"0.60379636",
"0.5998948",
"0.5968762",
"0.5953332",
"0.5947962",
"0.59396636",
"0.59115773",
"0.59078354",
"0.58825237",
"0.58535343",
"0.58226633",
"0.57975394",
"0.57970... | 0.7283341 | 0 |
for each day, get the last data point | def last_points_in_day(values)
values = values.sort { |a,b| a[:time] <=> b[:time] }
values = values.group_by { |data| data[:time].to_date }
values.map { |date,data| data.last }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_temp_avg\n today = @avg_dataset[@name].keys.sort.last\n raise \"Do not have data for today #{today}\" if today != Date.today\n @avg_dataset[@name][today].reverse.each do |record|\n return record[:temp] if record[:count] > 0\n end\n end",
"def weather_data_point(datetime)\n @we... | [
"0.6703849",
"0.6537533",
"0.64799017",
"0.618458",
"0.6180273",
"0.6092255",
"0.6026364",
"0.59843653",
"0.59344643",
"0.59197015",
"0.59146285",
"0.59016603",
"0.58091486",
"0.5808842",
"0.5799382",
"0.5794625",
"0.57908946",
"0.57814896",
"0.5774663",
"0.5762141",
"0.57582... | 0.74750805 | 0 |
This method assumes you have images that corespond to the filetypes. For example "image/png" becomes "imagepng.png" | def icon
"#{data_content_type.gsub(/[\/\.]/,'-')}.png"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_types\n [\"image/jpeg\", \"image/png\", \"image/jpg\", \"image/gif\", \"image/tif\"]\n end",
"def image_types\n [\"image/jpeg\", \"image/png\", \"image/jpg\", \"image/gif\", \"image/tif\"]\n end",
"def get_file_type\n\n @image.uploads.each do |upload|\n filename_arr = upload.content_t... | [
"0.72885925",
"0.72885925",
"0.7029008",
"0.69402",
"0.6916943",
"0.68895185",
"0.6854331",
"0.6793129",
"0.6790768",
"0.6790768",
"0.6746672",
"0.67440504",
"0.6711254",
"0.6701217",
"0.6693227",
"0.6642003",
"0.66264385",
"0.6622911",
"0.6613347",
"0.65933853",
"0.65905166"... | 0.0 | -1 |
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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:firstname, :lastname, :email, :password, :password_confirmation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Assert using the `cmp` matcher. | def assert_cmp(expect, actual)
# expect(Account.new.balance).to eq(Money.new(0))
# => expect(actual).to cmp expect
actual = rspec_expect actual
expect = cmp expect
assert_operator actual, :to, expect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_compare(expected, operator, actual, message=nil)\n _wrap_assertion do\n assert_send([[\"<\", \"<=\", \">\", \">=\"], :include?, operator.to_s])\n case operator.to_s\n when \"<\"\n operator_description = \"less than\"\n when \"<=\"\n operat... | [
"0.64894986",
"0.63850105",
"0.63841337",
"0.6204311",
"0.6057152",
"0.58989996",
"0.5880966",
"0.5866177",
"0.585944",
"0.5849229",
"0.5808797",
"0.57711446",
"0.5754653",
"0.5746344",
"0.56715167",
"0.5665837",
"0.56469315",
"0.5619121",
"0.560444",
"0.5604253",
"0.5579667"... | 0.73434156 | 0 |
Refute using the `cmp` matcher. | def refute_cmp(expect, actual)
actual = rspec_expect actual
expect = cmp expect
assert_raises RSpec::Expectations::ExpectationNotMetError do
actual.to expect
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_cmp(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n mem_addr = get_mem_addr(addr, i_reg)\n\n reg_value = reg.word.to_i\n mem_value = @computer.memory.read(mem_addr, m_spec[:l], m_spec[:r]).to_i\n\n if reg_value > mem_value\n @registers['CMP'].value = ['+',1]\n elsif reg_... | [
"0.5388081",
"0.535953",
"0.53347236",
"0.53305334",
"0.51966476",
"0.5159371",
"0.5111812",
"0.5074694",
"0.5031424",
"0.5028192",
"0.5024414",
"0.5012007",
"0.50081307",
"0.4941708",
"0.4936639",
"0.48789895",
"0.48732436",
"0.48724493",
"0.4868592",
"0.4868592",
"0.4845104... | 0.5145691 | 6 |
QUIT WITH FUNNY/ANNOYING GOODBYE OPTIONS | def quit
puts "Come on #{@name} Are you joking?"
puts "If you want to leave me you will have to ask it kindly"
puts "Tell me in good manner that you want to leave"
print ">> "
variable_with_no_use = gets
@list = @funny_list
roll_the_dice
chao
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_quit; @quit = 2 end",
"def display_options\n puts \"Please, write a type of request you want to send: GET or POST.\"\n puts \"Write EXIT to exit.\"\n end",
"def seeYa()\n abort(\"\\nQuiting now. Bye!\") \nend",
"def forced_exit?; @quit > 1 end",
"def quit; end",
"def quit; end",
"de... | [
"0.6862943",
"0.68200827",
"0.66627824",
"0.6575611",
"0.64353776",
"0.64353776",
"0.64316154",
"0.6422533",
"0.640313",
"0.6268251",
"0.6267525",
"0.62663424",
"0.6231531",
"0.6201738",
"0.6199681",
"0.6155906",
"0.6137721",
"0.6109523",
"0.6077054",
"0.60334677",
"0.6013119... | 0.0 | -1 |
NEW ANSWERS AND CHECKING IF THEY ALREADY EXIST | def help_me
puts "Add an answer"
@sum_of_all_arrays << @answer_list.concat(@user_list)
answer = gets.strip
if @sum_of_all_arrays.flatten.include?(answer) == true
puts "It's already on the list"
else
@user_list << answer
puts @user_list
end
menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def existent; end",
"def previously_existed?\n true\n end",
"def taxonExists? oldtaxon, seq, seqName\n if oldtaxon.has_key?(\"#{seqName}\")\n if seq.to_s != oldtaxon[\"#{seqName}\"].to_s\n # puts \"---------------= VS =------------------\"\n addNewSeq(seqName,seq)\n end\n else... | [
"0.61143935",
"0.5963152",
"0.5910131",
"0.5895227",
"0.58801544",
"0.57984406",
"0.5750953",
"0.56991297",
"0.56736606",
"0.5661294",
"0.5647306",
"0.5632287",
"0.5602899",
"0.5569983",
"0.553537",
"0.55128384",
"0.5512194",
"0.55053055",
"0.5493142",
"0.5493142",
"0.5483641... | 0.0 | -1 |
EXPORT AND PRINTING FUNCTION OF CONCATENATED ARRAYS | def print_options
@answer_list.flatten
@user_list.flatten
@sum_of_all_arrays << @answer_list.concat(@user_list)
File.open("answers.txt", "w") do |f|
f.puts(@sum_of_all_arrays)
end
puts @sum_of_all_arrays
menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_print_10\nend",
"def print_array(array)\n p array\nend",
"def print_elements(input_array)\n # TODO\nend",
"def print_array(array)\n puts \"NOT IMPLEMENTED\"\nend",
"def spy_array(x)\n #spy_repeater\n p real_entry\n p alias_entry\nend",
"def print_array(array)\n raise NotImplementedErro... | [
"0.7429672",
"0.6738172",
"0.65636253",
"0.6465527",
"0.62893105",
"0.6279881",
"0.6242278",
"0.6196886",
"0.61787885",
"0.6086108",
"0.5979714",
"0.597254",
"0.5960957",
"0.5917082",
"0.5892935",
"0.586773",
"0.58651865",
"0.5854311",
"0.5833103",
"0.5823467",
"0.58001447",
... | 0.0 | -1 |
TRIPLE MIXED RANDOM NUMBERS (THE DICE OF FORTUNE) | def roll_the_dice
numbers = [0..9]
puts @list.shuffle[rand(5) + rand(5)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_deck\n SUITS.product(VALUES).shuffle\nend",
"def remix(ingredient_arrays)\n \n mixers = []\n \n ingredient_arrays.each do |array|\n mixers << array[1]\n end\n \n ingredient_arrays.each do |array|\n idx = rand(mixers.length)\n array[1] = mixers[idx]\n mixers.delete_at(idx)\n en... | [
"0.6287587",
"0.62561405",
"0.61764175",
"0.61675376",
"0.61138564",
"0.60657936",
"0.6053318",
"0.6046599",
"0.6022995",
"0.59503776",
"0.59373105",
"0.59258646",
"0.5911024",
"0.59057057",
"0.5888588",
"0.58616555",
"0.5859465",
"0.5822288",
"0.5821363",
"0.5804924",
"0.579... | 0.5436413 | 74 |
TODO: add strike and spare scenario | def start
9.times do |index|
@score = @score + @frames[index][0].to_i + @frames[index][1].to_i
@scores[index] = @score
@score
end
@score = @score + @frames[9][0].to_i + @frames[9][1].to_i + @frames[9][2].to_i
@scores[9] = @score
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_strike?(value)\n\t\tvalue == STRIKE\n\tend",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def mark_up()\n return @retail_price-@buying_cost\n end",
"def dealer_markup\n (origin_... | [
"0.64938974",
"0.5950644",
"0.5950644",
"0.5950644",
"0.5950644",
"0.59433466",
"0.58597916",
"0.5847545",
"0.5796356",
"0.57724124",
"0.575647",
"0.56986386",
"0.5688313",
"0.5686466",
"0.567355",
"0.5657456",
"0.5653869",
"0.56344974",
"0.56219125",
"0.561737",
"0.5601749",... | 0.0 | -1 |
TODO: create last scenario | def tenth_frame; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_steps; end",
"def test_steps; end",
"def running_test_step; end",
"def running_test_case; end",
"def test_step; end",
"def step1\n\n end",
"def step_result; end",
"def scenarios\n @@scenarios ||= (\n ss = []\n\n feature = feature_build(feature_a)\n examples = run_f... | [
"0.6666838",
"0.6666838",
"0.6470998",
"0.6467753",
"0.63934517",
"0.631699",
"0.62268996",
"0.6217695",
"0.6217695",
"0.6213538",
"0.6183899",
"0.6098992",
"0.60719275",
"0.604033",
"0.6029731",
"0.59846467",
"0.5982548",
"0.5981879",
"0.5977441",
"0.5957623",
"0.59293664",
... | 0.0 | -1 |
TODO: create the scenario when the first try is a strike | def bonus_spare(index)
frame = frames[index + 1]
frame.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_strike?(value)\n\t\tvalue == STRIKE\n\tend",
"def is_strike?\n turn[0] == 10\n end",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def strike?\n @roll == 10\n end",
"def is_strike?(frame)\n @board[frame] == 10\n ... | [
"0.6977817",
"0.6768265",
"0.6275078",
"0.6275078",
"0.6275078",
"0.6275078",
"0.6197312",
"0.6154971",
"0.61328024",
"0.6109509",
"0.6019986",
"0.590905",
"0.5887821",
"0.5868042",
"0.5851653",
"0.5849522",
"0.58489805",
"0.58105356",
"0.57413864",
"0.57189125",
"0.57189125"... | 0.0 | -1 |
Set the configuration for the AWS client +config+ should be an object suitable to pass as the options to create an AWS client from the AWS SDK. | def configure_aws(config)
raise TypeError, "AWS config must be hash" unless config.is_a?(Hash)
@aws_config = config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize options = {}\n @config = options[:config]\n @config ||= AWS.config\n @config = @config.with(options)\n @client = config.send(Inflection.ruby_name(self.class.to_s) + '_client')\n end",
"def configure\n Ros::Platform::Client.configure(client_config.to_h.merge(conn... | [
"0.6734261",
"0.65913147",
"0.6570419",
"0.653479",
"0.6326488",
"0.6141425",
"0.61217004",
"0.6090079",
"0.60545987",
"0.5986543",
"0.59841824",
"0.596975",
"0.5967732",
"0.5934052",
"0.5835843",
"0.5821858",
"0.5808319",
"0.57922477",
"0.5710557",
"0.5700426",
"0.5626363",
... | 0.7347563 | 0 |
Ignore all resources of a given type | def ignore_resource_type(type)
@ignore_rules[type] = "*"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignore_resources(type, *patterns)\n @ignore_rules[type] += patterns\n end",
"def disallow(type: ALL_FHIR_RESOURCES, attributes: [])\n disallowable[type] ||= []\n disallowable[type].concat(attributes)\n end",
"def keep(*args)\n if args.empty?\n super\n else\n ... | [
"0.75119555",
"0.6759312",
"0.63581735",
"0.6264849",
"0.61644447",
"0.6090534",
"0.60239",
"0.59852415",
"0.59408844",
"0.59378386",
"0.5875113",
"0.5863756",
"0.58566195",
"0.5847333",
"0.581628",
"0.58115035",
"0.578501",
"0.5777812",
"0.57674277",
"0.5723174",
"0.5694228"... | 0.8373859 | 0 |
Ignore resources for a given typ that matche one or more patterns. The patterns are strings that are matched as caseinsensitive glob patterns. | def ignore_resources(type, *patterns)
@ignore_rules[type] += patterns
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_resource_ignore_pattern(type, pattern)\n raise TypeError \"Ignore pattern must be a string or an array\" unless pattern.is_a?(String) || pattern.is_a?(Array)\n @ignore_rules[type] = pattern\n end",
"def ignore_resource_type(type)\n @ignore_rules[type] = \"*\"\n end",
"def ignore(*p... | [
"0.79034925",
"0.7184805",
"0.713751",
"0.6496897",
"0.64186954",
"0.63417554",
"0.6329562",
"0.6303917",
"0.6285122",
"0.6274382",
"0.62716997",
"0.6219135",
"0.61662954",
"0.6166043",
"0.5985839",
"0.59307724",
"0.59240884",
"0.5916854",
"0.58946216",
"0.5852545",
"0.584054... | 0.82113546 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.