query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
get total coins value with this route => host/users/total_coins_value?:user_id=user_id | def total_coins_value
json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})
end | [
"def total_value\n coins.reduce(0) do |sum, (coin_name, quantity)|\n sum + coin_value(coin_name) * quantity\n end\n end",
"def get_coins\n get(\"/getcoins\")\n end",
"def calculate_coins_value\n @amount = 0\n\n @coins.each do |coin|\n @amount += COINS[coin.weight]\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
all transactions for a specific user => host/users/user_transactions?:user_id=user_id | def user_transactions
user_deposits = get_user_deposits
user_withdrawals = get_user_withdrawals
json_response({:user_transactions => @user_transactions, :user_deposits => user_deposits, :user_withdrawals => user_withdrawals})
end | [
"def user_transactions params = { 'offset' => 0, 'limit' => 100, 'sort' => 'desc' }\n private_request 'user_transactions', params\n end",
"def get_user_transactions(**options)\n \t\t[options[:page], options[:per_page]].each do |arg|\n \t\t\tif arg && (!arg.is_a?(Integer) || arg < 1)\n \t\t\t\tr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: returns the string "We're playing tennis!" When the game_play object is named. | def to_s
"We're playing tennis!"
end | [
"def game_text(game)\n \"Game #{game.id} - Versus @#{game.opponent.username}\"\n end",
"def game_title\n\t\t\"#{home_team} vs. #{visitor_team}\"\n\tend",
"def to_s\n \"Player #{@name}\"\n end",
"def name\n self[:name] || \"#{player1.name} vs. #{player2.name}\"\n end",
"def name\n @g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: This method is called to start a new game. It asks whether the user would like to play a new game. If answer is 'y' it starts a new game. If 'n' it ends the program. returns: "response not understood" if any other response is received. | def new_game
puts "Would you like to play a new game (y or n)?"
answer = gets.chomp.downcase
if answer == 'y'
@player1.points = 0
@player2.points = 0
puts "Player 1 = #{@player1}"
puts "player 2 = #{@player2}"
self.coin_toss_call
elsif answer
puts "Have a nice day."
else
puts... | [
"def start\r\n\t\tputs \"\\nI am Negaman. Are you ready... Human?\"\r\n\t\t\r\n\t\tprint \"\\nWould you like to go first? (y/n): \"\r\n\t\tcheck = gets.chomp\r\n\r\n\t\twhile !confirm(check)\r\n\t\tcheck = gets.chomp\r\n\t\tend\r\n\r\n\t\tif check == 'n'then @currentPlayer = @player2\r\n else @currentPlayer ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Asks player to call heads or tails, saves response. Calls toss_results if 'heads' or 'tails' is entered. | def coin_toss_call
puts "Please call 'heads' or 'tails'"
call = gets.chomp.downcase
unless call == 'heads' || call == 'tails'
puts "response not understood. Hit 't' to try again."
response = gets.chomp.downcase
if response == "t"
self.coin_toss_call
else
puts "exiting game."
end
... | [
"def toss_results(call)\n\t\t\ttoss = self.cointoss\n\t\t\ttoss_string =\"you called #{call} and the toss returned #{toss}.\"\n\t\t\tif call == toss\n\t\t\t\tputs toss_string\n\t\t\t\tputs \"you won the coin toss.\"\n\t\t\t\tputs \"You get to serve first.\"\n\t\t\t\tputs \" \"\n\t\t\t\tself.hitter2\n\t\t\t\tserver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tossresults takes a call as argument passes it to the results of a call to the cointoss method then determines a winner of the toss | def toss_results(call)
toss = self.cointoss
toss_string ="you called #{call} and the toss returned #{toss}."
if call == toss
puts toss_string
puts "you won the coin toss."
puts "You get to serve first."
puts " "
self.hitter2
server(@player1)
elsif call != toss
puts toss_string
... | [
"def coin_toss\n puts \"#{@new_game.player_1.name}, heads or tails?\"\n if @new_game.player_1.is_a?(Computer)\n call = [\"heads\", \"tails\"].sample\n puts \"#{@new_game.player_1.name} selects #{call}.\"\n else\n call = gets.chomp\n call.downcase\n # binding.pry\n end\n if ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cointoss generates a random number between 1 and 10 and saves it in the 'number' variable. If the number generated is less than or equal to five the method returns "heads". If the random number is greater than 5 coin toss returns "tails." | def cointoss
number = rand(1..10)
return "heads" if number <= 5
return "tails" if number > 5
end | [
"def coin_toss\n toss = SecureRandom.random_number(2)\n if toss == 0\n HEADS_VALUE\n else\n TAILS_VALUE\n end\n end",
"def coin_toss\n puts \"#{@new_game.player_1.name}, heads or tails?\"\n if @new_game.player_1.is_a?(Computer)\n call = [\"heads\", \"tails\"].sample... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
game action uses a random number to determine the result of ball serves. a random number between 5 and 15 is set as a net ball meaning the ball is stopped by the net and does not make it to the other court | def game_action(num)
net_ball = rand(5..15)
return "net" if num == net_ball
return "oob" if num <= 3
return "hit" if num > 3 && num <=17
return "miss" if num > 17
end | [
"def rally\n\t\t\tnum = rand(1..20)\n\t\t\trally_case = game_action(num)\n\t\t\tcase rally_case\n\t\t\t\twhen \"oob\" \n\t\t\t\t\tputs \"oo-oo-oo-oo-oo #{$hitter} hit the ball out of bounds oo-oo-oo-oo-oo\"\n\t\t\t\t\t@current_game.wins_ball($def_num)\n\t\t\t\t\tself.game_stats\n\t\t\t\t\n\t\t\t\twhen \"miss\"\n\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method switches which player is the hitter and which is returning the ball Once a player hits the ball they become the "hitter" and the other player becomes the defender. It also associates player number with "hitter" and "defender" so that the score can be tracked. | def hitter(hitter)
if $hitter == @player1
self.hitter1
self.rally
else
self.hitter2
self.rally
end
end | [
"def switch_players\n \n if @current_asker == @player1\n @current_asker = @player2\n @current_responder = @player1\n else\n @current_asker = @player1\n @current_responder = @player2\n end\n\n end",
"def wins_ball(winner)\n if winner == 1\n winning_playe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method initiates a new serve and calls the rally method. | def new_serve(server)
puts " "
puts ">>>>>>>>>>>>> #{$hitter} serves the ball >>>>>>>>>>>>>>>"
puts "hit any letter to continue 'q' to quit."
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
result = gets.chomp.downcase
if result == 'q'
puts "exiting game"
else
self.ra... | [
"def serve\n @server.start\n end",
"def execute\n @conn = RallyConnection.new\n @conn.connect\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def serve!(overlord, name, plan)\n @overlord = overlord\n @name = name\n @plan = plan\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method alternates which player is the server and then passes the new server to the new_serve method. | def switch_serve(server)
if @current_game.check_status == "#{@player1} wins" || @current_game.check_status == "#{@player2} wins"
self.new_game
else
if $server == @player1
$server = @player2
self.hitter1
else
$server = @player1
self.hitter2
end
new_serve($server)
end... | [
"def update_player_server!(player)\n raise Exceptions::InvalidOperation, 'Player required' unless player\n raise Exceptions::InvalidOperation, 'Invalid type' unless player.is_a? Player\n if match.first_player_server.nil?\n match.first_player_server = player\n match.save!\n elsif ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is the main action of the game rally calls the game_action method to determine what has happened to the ball then it uses a case statement to return results and pick next actions | def rally
num = rand(1..20)
rally_case = game_action(num)
case rally_case
when "oob"
puts "oo-oo-oo-oo-oo #{$hitter} hit the ball out of bounds oo-oo-oo-oo-oo"
@current_game.wins_ball($def_num)
self.game_stats
when "miss"
puts "mmmmmmm #{$defender} missed the ball! mmmmmmmmmm"... | [
"def choose_action\n puts(\"in choose action\")\n puts(\"robot #{@robot.id} has #{@robot.foobars.size} in stock\")\n ::Actions::MineFoo.new(@robot, @manager).perform if @robot.foos.empty? #should it be the manager checking foos or every individual bots\n ::Actions::MineBar.new(@robot, @manager).perform ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an input iterator to use for the request. if arguments are given, uses arguments if the input file option is given, uses file input if none of the previous are given, uses stdin | def input_iterator
return arguments.each unless arguments.empty?
return File.foreach(options[:input]) if options[:input]
$stdin.each_line
end | [
"def input_handle\n if !@options[:message].nil?\n nil\n elsif @options[:input]\n begin\n File.open(@options[:input])\n rescue Errno::ENOENT\n $stderr.puts \"no such file #{@options[:input]}\"\n exit -1\n end\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the default default_batch_size of a command. | def default_batch_size
raise NotImplementedError, 'This must be implemented in a subclass.'
end | [
"def batch_size\n if options[:batch]\n options[:batch].to_i\n else\n default_batch_size\n end\n end",
"def retrieve_batch_size_value(env)\n retrieve_integer_value('BATCH_SIZE', env)\n end",
"def batch_size(value = nil)\n option(value) { |options| options.store(:b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the effective batch_size of a command | def batch_size
if options[:batch]
options[:batch].to_i
else
default_batch_size
end
end | [
"def batch_size\n @of\n end",
"def batch_size\n @of\n end",
"def retrieve_batch_size_value(env)\n retrieve_integer_value('BATCH_SIZE', env)\n end",
"def batch_size_for(value, items = nil)\n batch = batch_option(value) or return\n batch = [batch, MAX_BATCH].min\n batch = [batch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a new batch_iterator based on the batch_size | def batch_iterator
Unipept::BatchIterator.new(batch_size)
end | [
"def process_in_batches(batch_size)\n raise ArgumentError if batch_size.nil? or batch_size <= 0\n \n index = 0\n \n while index < self.size\n yield self[index...index+batch_size]\n index += batch_size\n end\n end",
"def batch_size(batch_size)\n operation.batch_size = batch_size\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of regular expressions containing all the selected fields | def selected_fields
return @selected_fields unless @selected_fields.nil?
fields = [*options[:select]].map { |f| f.split(',') }.flatten
fields.concat(required_fields) if @fasta && !fields.empty?
@selected_fields = fields.map { |f| glob_to_regex(f) }
end | [
"def regex_values\n @values.select do |key, value|\n value.regex?\n end.map do |key, value|\n value.name.source\n end\n end",
"def build_regex(fields)\n fields_or = fields.map { |field| \"#{field}(\\\\[\\\\])?\" }.join('|')\n\n Regexp.new(\"^#{fields_or}$\")\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a formatter, based on the format specified in the options | def formatter
@formatter ||= Unipept::Formatter.new_for_format(options[:format])
end | [
"def formatter\n unless @formatter\n fmt = options.fetch(:formatter, :plain)\n @formatter = case fmt\n when Symbol\n klass = \"Gruf::Instrumentation::RequestLogging::Formatters::#{fmt.to_s.capitalize}\"\n fmt = klass.constantize.new\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs a request body (a Hash) for set of input strings, using the options supplied by the user. | def construct_request_body(input)
names = selected_fields.empty? || selected_fields.any? { |f| f.to_s.include?('name') || f.to_s.include?('.*$') }
{ input: input,
equate_il: options[:equate] == true,
extra: options[:all] == true,
names: options[:all] == true && names }
end | [
"def request_body\n MAPPING.keys.inject({}) do |mem, e|\n next mem unless value = send(e)\n mem.merge!(e.to_s => value.to_json)\n end\n end",
"def make_request_body(opts, headers); end",
"def build_request_body(header_params, form_params, body)\n # http form\n if header_para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves an error to a new file in the .unipept directory in the users home directory. | def save_error(message)
path = error_file_path
FileUtils.mkdir_p File.dirname(path)
File.write(path, message)
warn "API request failed! log can be found in #{path}"
end | [
"def create_error_file\n FileUtils.mkdir_p(File.dirname(error_file))\n File.new(error_file, 'w')\n end",
"def write_error_report_to_file(text)\n File.open(\"errorfile\", \"a\") do |er|\n er.write \"#{text}\"\n end\nend",
"def map_error_output(filename)\r\n\tDir.mkdir(\"#{settings.roo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses the json_response, wraps it in an array if needed and filters the fields based on the selected_fields | def filter_result(json_response)
result = JSON[json_response] rescue []
result = [result] unless result.is_a? Array
key_order = result.first.keys if result.first
result = flatten_functional_fields(result) if formatter.instance_of?(Unipept::CSVFormatter)
result.map! { |r| r.select! { |k, _v... | [
"def getCustomfields(response)\r\n\t\t\t\r\n\t\t\t\tjsonObject = JSON.parse response\r\n\t\t\t\t\r\n\t\t\t\tcustomFields = Array.new\r\n\t\t\t\t\r\n\t\t\t\tif jsonObject.has_key?(\"customfields\")\r\n\t\t\t\t\r\n\t\t\t\t\tcustomfields = jsonObject[\"customfields\"]\r\n\t\t\t\t\t\r\n\t\t\t\t\tfor i in 0...customfiel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /cta_ctes GET /cta_ctes.json | def index
@cta_ctes = CtaCte.all
end | [
"def index\n @cta = Ctum.all\n end",
"def index\n @cta = Cta.all\n end",
"def census_tracts\n self.class.get('/census-tracts', @options)\n end",
"def index\n @ctecs = Ctec.all\n end",
"def index\n @ctos = Cto.all\n end",
"def index\n @cts = Ct.all\n end",
"def list_tenants_fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /cta_ctes POST /cta_ctes.json | def create
@cta_cte = CtaCte.new(cta_cte_params)
respond_to do |format|
if @cta_cte.save
format.html { redirect_to @cta_cte, notice: 'Se creo correctamente.' }
format.json { render :show, status: :created, location: @cta_cte }
else
format.html { render :new }
format.... | [
"def create\n @cta = Cta.new(cta_params)\n\n respond_to do |format|\n if @cta.save\n format.html { redirect_to @cta, notice: 'cta was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cta }\n else\n format.html { render action: 'new' }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /cta_ctes/1 PATCH/PUT /cta_ctes/1.json | def update
respond_to do |format|
if @cta_cte.update(cta_cte_params)
format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }
format.json { render :show, status: :ok, location: @cta_cte }
else
format.html { render :edit }
format.json { render json... | [
"def update\n respond_to do |format|\n if @cta.update(cta_params)\n format.html { redirect_to @cta, notice: 'cta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cta.errors, status: :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
SEND: XMPP General method for sending xmppmessages. Notce! clientparameter contains the client that is used to send the message, not the client that is receving the message | def sendMessage(args, client = @send_client)
jabmsg = Jabber::Message::new(args[:receiver], args[:message]).set_type(:chat).set_id('1')
begin
Timeout::timeout(10) do
client.send(jabmsg)
puts "XMPP TO: " + args[:receiver].to_s
puts "XMPP MESSAGE: " + args[:message].to_s
... | [
"def send_message message\n message = \"#{message}\\n\"\n puts \"client << #{message}\"\n send_data message\n end",
"def send_message(subject, message, recipients, adminEmail, params)\n # execute_operation(:send_message, { nickname: nickname, subject: subject, recipients: recipients, message:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles xmpp2restmessages that are received. | def handleMessage(msg)
if msg != nil and msg.type == :chat and msg.body #and msg.from == @@visualRESTmain
#puts "#{msg.from}:"
#puts "#{msg.body.strip}"
puts "Validating.."
begin
doc = XML::Document.string(msg.body)... | [
"def process_msgs\n end",
"def receive_sms \n sender_tel = params[:From] || \"\"\n body = params[:Body] || \"\"\n body_tokens = body.split(\" \")\n\n logger.debug \"Received a message from tel: #{sender_tel} with body: #{body}\"\n\n if body_tokens.size == 0\n render 'process_bad_party_id.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds context from xml, adds parts to path and returns the both results | def findContext(doc, path)
context = nil
# If user-element is given -> context is user-based, otherwise context is system-based
if doc.find_first('//xmpp2rest/user')
puts "User context"
username = (doc.find_first('//xmpp2rest/user').attributes.get_attribute("username")) ? doc.find... | [
"def find_context_xml\n\t\t@manifest.elements.each do |e|\n\t\t\te.elements.each do |e1|\n\t\t\t\tif(e1.attributes['full-path'] == 'content.xml')\n\t\t\t\t\treturn e1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#Throw exception if it gets this far\n\t\t\"Something has gone terribly wrong :(\"\n\tend",
"def get_context_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses dev_type and password from xml | def parseDeviceData(doc, params)
dev_type = (doc.find_first('//xmpp2rest/user/device/dev_type')) ? doc.find_first('//xmpp2rest/user/device/dev_type').content : nil
password = (doc.find_first('//xmpp2rest/user/device/password')) ? doc.find_first('//xmpp2rest/user/device/password').content : nil
if no... | [
"def parse_xml_fields(xml)\n @xmldoc = xml\n set_field :@id, 'ID'\n set_field :@sid, 'Sid'\n set_field :@name, 'Name'\n set_field :@login_name, 'LoginName'\n set_field :@email, 'Email'\n set_field :@notes, 'Notes'\n set_field :@is_site_admin, 'IsSiteAdmin', 'Boolean'\n set_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses device's online status, and the possible status elements that are given | def parseOnlineStatus(doc, params, path)
status = {}
doc.find('//xmpp2rest/user/device/online/status').each do |status_element|
status_key = (status_element.attributes.get_attribute("status_key")) ? status_element.attributes.get_attribute("status_key").value : nil
if not status_... | [
"def status\n {\n 'device' => :ok,\n 'no device' => :dead,\n 'offline' => :offline\n }[@state]\n end",
"def status\n {\n 'device' => :ok,\n 'no device' => :dead,\n 'offline' => :offline\n }[@state]\n end",
"def sta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses the userspecific metadata from xml to visualREST form. List of updated files is returned, so that xml can contain many metadata changes for different files | def parseUpdatedMetadata(doc, params, path)
path += "/files"
listOfUpdatedFiles = Array.new
doc.find('//user/device/files/file').each do |file|
fullpath = (file.attributes.get_attribute("fullpath")) ? file.attributes.get_attribute("fullpath").value : nil
version = "not_found"... | [
"def files\n @mets.xpath(\"/mets:mets/mets:fileSec/mets:fileGrp[@USE='masters']/mets:file\").map do |f|\n file_info(f)\n end\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
General method for first sending http to visualREST and then returning the response to xmppclient that sent the xmpp2rest message | def httpAndNotify(path, params, msg_from, method)
message = ""
begin
m = ""
if method == :get
m = "GET"
elsif method == :post
m = "POST"
elsif method == :put
m = "PUT"
elsif method == :delete
m = "DELETE"
else
raise Exception.new... | [
"def send_request\n\n # create the connection object\n uri = URI.parse \"#{MoovAtom::API_URL}/#{@action}.#{@format}\"\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # open the connection and send request\n http.st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines whether or not the 2 names match (ignoring parenthesis text) | def exact_match?(name1:, name2:)
return false unless name1.present? && name2.present?
a = name_without_alias(name: name1.downcase)
b = name_without_alias(name: name2.downcase)
a == b
end | [
"def names_match s1, s2\n t1 = ''\n t2 = ''\n s1.each_char do |c|\n t1 << c if c.match /(\\d|[a-zA-Z])/\n end\n s2.each_char do |c|\n t2 << c if c.match /(\\d|[a-zA-Z])/\n end\n t1.upcase == t2.upcase\nend",
"def games_have_same_name?(name1, name2)\n name1 = name1.downcase\n name2 = name2.d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the parenthesis portion of the name. For example: "Foo College (foo.edu)" > "Foo College" | def name_without_alias(name:)
return '' if name.blank?
name.split(' (')&.first&.strip
end | [
"def cleanup_firstname(name)\n name.gsub(/^Dean(\\w+)/) { |s| \"DeAn#{$1}\" }\n end",
"def clean_smpc_name name\n clean_text(\n name.gsub(/\\s\\(.+\\)$/, ''), # parenthesis at the end\n clean_dashes: true,\n clean_punct: true,\n )\n end",
"def unparen( str )\n matc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes any duplicates by comparing the sort names and ids | def deduplicate(records:)
return [] unless records.present? && records.is_a?(Array)
out = []
found = []
records.each do |rec|
next if found.include?(rec[:sort_name]) || found.include?(rec[:id])
found << rec[:sort_name]
found << rec[:id] if rec[:id].present... | [
"def duplicate_ids()\n @traces.select{|id, traceables| traceables.length > 1}.map{|id, traceable| id}.sort\n end",
"def sort_by_id\r\n # Hash#sort will convert each item to an Array of 2 elements [key, value]\r\n sort { |entry1,entry2| entry1[1].id.to_i <=> entry2[1].id.to_i }.collect { |el| el[1] }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
used at filelist inorder to send file info if requested path is file | def send_file_info(last, path)
if not last == nil
user = current_user
path = path.force_encoding("UTF-8")
@file_names = "#{path.split('/').last}" + "\n"
@access_url = "#{HOSTING_URL}" + "/user_files/"+ "#{user.userid}" + path.force_encoding("UTF-8")
else
@f... | [
"def has_file_server\n return @payload.get_path(\"files\"){false}\n end",
"def send_to_fileserver(client, answer, msg)\n if answer.include?('ONE')\n puts \"File in server ONE\"\n @fileServer.puts msg\n fileserver_handler(client, answer)\n elsif answer.include?('TWO')\n puts \"F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends a progress update Inputs: percentage Integer Optional description, this could be displayed to the user e.g. Resizing image | def progress(percentage, description = nil)
reply({:progress => percentage, :description => description}, {:message_type => 'progress'})
end | [
"def update(percentage,text=nil)\n @progressBar.text = text.to_s if text\n @progressBar.fraction = percentage.to_f\n end",
"def avanzamento_progress_bar(nome_step)\n statusbar.push(1, \"#{nome_step}\")\n progress.text = \"%.0f%%\" % @percent\n progress.fraction = @percent / 100.0\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the Site with the given UID. This method does a server request, to get additional property data. | def site(uid)
site_data = request("/web_properties/#{uid}.json")
Site.new self, site_data['uid'], site_data['name']
end | [
"def site\n return @site\n end",
"def site\n @site ||= ::Site.find(@options[:site] || 1)\n end",
"def site(id)\n s = SiteStat.find(id)\n return nil if s.user != self\n s\n end",
"def get_site_data(site_id)\n @conn.get(\"/api/v1/sites/#{site_id}\")\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /likes Mostra todos os likes | def index
@likes = Like.all
render json: @likes, status: 200
end | [
"def index\n @api_v1_likes = Api::V1::Like.all\n end",
"def index\n @likes = Like.all\n render json: @likes\n end",
"def index\n @user_likes = UserLike.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_likes }\n end\n end",
"def lik... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO: If no original_stock_location given, return a stock item according to some priority of the regular stock locations, instead of just the first one we find. | def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)
return super(variant_id) unless reserved_items?
raise(
UserRequiredArgumentError,
Spree.t(:user_id_required_for_reserved_stock_location)
) unless user_id.present?
items = stock_items.where(variant_id: variant_id, use... | [
"def stock_item(variant_id, sub_location=nil)\n # byebug\n stock_items.where(variant_id: variant_id, sub_location: sub_location).order(:id).first\n end",
"def stock_location\n @stock_location ||= Spree::StockLocation.where(default: true).first\n end",
"def stock_item(variant_id)\n stoc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
provides the institution_id from the authentication block | def auth_inst_id
auth[:institution_id]
end | [
"def institution\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end",
"def institution\n unless institution_code.blank?\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end\n end",
"def institution_code\n (from_aleph?) ? aleph_item.institu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
provides the user_id from the authentication block | def auth_user_id
auth[:user_id]
end | [
"def user_id\n instance_variable_get(:@prepared_arguments).dig(:user_id)\n end",
"def user_id\n return nil unless success?\n\n @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id()\n # @TODO: looks for a better way to get user id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check existence of auth params | def auth_params_exist
auth.key?(:user_id) && auth.key?(:api_key)
end | [
"def valid_for_params_auth?; end",
"def authentication_supplied?\n params[:email] && (params[:password] || (params[:oauth] && params[:oauth][:token]))\n end",
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a hash of only the search parameters that apply to the specific model being queried | def model_search_params(model, params)
cols = model.column_names
params.reject { |k, _v| !cols.include?(k) }
end | [
"def search_attributes\n read_inheritable_attribute(:search_attributes) || []\n end",
"def search_attrs_params_hash\n @search_attrs_params_hash ||= if params[:search_attrs].nil? || params[:search_attrs] == '_use_defaults_'\n @runner.using_defaults = true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
to install specific streams and profiles: $ dnf module install modulename:stream/profile $ dnf module install perl:5.24/minimal if unspecified, they will be defaulted (see [d] param in dnf module list output) | def install
# ensure we start fresh (remove existing stream)
uninstall unless [:absent, :purged].include?(@property_hash[:ensure])
args = @resource[:name].dup
case @resource[:ensure]
when true, false, Symbol
# pass
else
args << ":#{@resource[:ensure]}"
end
args << "/#{@resou... | [
"def install\n args = @resource[:name]\n # ensure we start fresh (remove existing stream)\n uninstall unless [:absent, :purged].include?(@property_hash[:ensure])\n case @resource[:ensure]\n when true, false, Symbol\n # pass\n else\n args << \":#{@resource[:ensure]}\"\n end\n if @re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Configure knapsack report Setup variables Fetch latest report | def configure!
ENV["KNAPSACK_TEST_FILE_PATTERN"] ||= "qa/specs/features/**/*_spec.rb"
ENV["KNAPSACK_REPORT_PATH"] = report_path
Knapsack.logger = QA::Runtime::Logger.logger
download_report
end | [
"def buyflow(testrun)\n # Pull this test runs test suite from model query\n suite = TestSuites.find(testrun['test_suites_id'])\n\n # Get the campaign data for the test run requested\n campaign_data = GRDatabase.get_campaign_data(testrun['Brand'], testrun['expectedcampaign'], testrun['Env... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Download knapsack report from gcs bucket | def download_report
logger.debug("Downloading latest knapsack report for '#{report_name}' to '#{report_path}'")
file = client.get_object(BUCKET, report_file)
File.write(report_path, file[:body])
rescue StandardError => e
ENV["KNAPSACK_REPORT_PATH"] = FALLBACK_REPORT
logger.... | [
"def get_usage_export_bucket project:\n projects_client = ::Google::Cloud::Compute::V1::Projects::Rest::Client.new\n project_data = projects_client.get project: project\n export_location = project_data.usage_export_location\n\n if !export_location.nil? && export_location.report_name_prefix.empty?\n puts \"Re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rename and move new regenerated report to a separate folder used to indicate report name | def move_regenerated_report
return unless ENV["KNAPSACK_GENERATE_REPORT"] == "true"
tmp_path = "tmp/knapsack/#{report_name}"
FileUtils.mkdir_p(tmp_path)
# Use path from knapsack config in case of fallback to master_report.json
knapsack_report_path = Knapsack.report.report_path
... | [
"def export_rename(custodian)\n @@dialog.logMessage('Renaming files')\n dir = report_path(custodian)\n FileUtils.mkdir_p(dir)\n Dir.glob(export_path('*')).each do |p|\n if File.file?(p)\n rename_file(p, File.join(dir, File.basename(p))) unless p.end_with?('.pst')\n elsif @naming == 'ite... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge and upload knapsack report to gcs bucket Fetches all files defined in glob and uses parent folder as report name | def upload_report(glob)
reports = Pathname.glob(glob).each_with_object(Hash.new { |hsh, key| hsh[key] = [] }) do |report, hash|
next unless report.extname == ".json"
hash[report.parent.basename.to_s].push(report)
end
return logger.error("Glob '#{glob}' did not contain any va... | [
"def upload_latest_copy\n upload_to_gcs(report_files, prefix)\n end",
"def place_files_in_buckets\n @files.each do |file|\n place_file_in_buckets(file)\n end\n end",
"def process_workspace_bucket_files(files)\n # first mark any files that we already know are study files that haven't c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Base path of knapsack report | def report_base_path
@report_base_path ||= "knapsack"
end | [
"def app_thinning_size_report_path\n Gym.cache[:app_thinning_size_report] ||= File.join(temporary_output_path, \"App Thinning Size Report.txt\")\n end",
"def relative_path\n calculation_directory\n end",
"def file_path_xunit_report\n Noop::Config.dir_path_reports + file_name_xunit_repor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Report name Infer report name from ci job name Remove characters incompatible with gcs bucket naming from job names like ee:instanceparallel | def report_name
@report_name ||= ENV["CI_JOB_NAME"].split(" ").first.tr(":", "-")
end | [
"def job_name\n @job_name ||= QA::Runtime::Env.ci_job_name&.gsub(%r{ \\d{1,2}/\\d{1,2}}, '')\n end",
"def name_with_job\n return name + \"(\" + job.name + \")\"\n end",
"def job_name_from_package_name(package_name)\n \"#{job_prefix}#{package_name.gsub('/', '-')}\"\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
clean the tree, for example, eliminates sequence that have only one child (use the child directly). | def clean_tree(branch)
branch.children = branch.children.inject(Children.new(branch)) do |r, c|
cc = if c.name == 'sequence' and c.children.size == 1
c.children.first
else
c
end
r << clean_tree(cc)
end
branch
end | [
"def clean_tree (branch)\n\n branch.children = branch.children.inject(Children.new(branch)) do |r, c|\n cc = if c.name == 'sequence' and c.children.size == 1\n c.children.first\n else\n c\n end\n r << clean_tree(cc)\n end\n\n branch\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Configuration blocks allow for lists of remote hosts, those are split into seperate configuration blocks here | def split_multi_remotehost_config_blocks(config_block)
split_config = []
config_block['remoteHost'].each do |single_remote_host|
# Clone the block containing the multiple remote hosts
config_block_for_single_remote_host = config_block.clone
# And replace them with a single remote host
config_block_f... | [
"def get_host_options(key, &block)\n opts = {}\n sky_instances.each{|sky_instance|\n merging = configuration_data.keep_merge configuration_data[\"roles\"][sky_instance.role.to_s]\n if block\n value = block.call(merging[key])\n end\n opts[\"hostvar_#{sky_instance.hostna... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an image tag for a Google Maps image with the GPS polyline of the activity. | def polyline_image(polyline, size = 150, color = "blue")
image_tag(polyline_map_url(polyline, size, color),
alt: "Activity map")
end | [
"def map_image location, width=500, height=275, zoom=15\n image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{location.latitude},#{location.longitude}&zoom=#{zoom}&size=#{width}x#{height}&markers=color:blue%7Clabel:1%7C#{location.latitude},#{location.longitude}&sensor=false\", :class => \"map_imag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Detect the player in a specific direction | def detect_player(nb_pas, direction)
return false if $game_switches[Yuki::Sw::Env_Detection]
c = $game_map.events[@event_id]
dx = $game_player.x - c.x
dy = $game_player.y - c.y
case direction
when :right, 6
return (dy == 0 && dx >= 0 && dx <= nb_pas)
when :down, 2
return (dx == 0... | [
"def turn_toward_player\n # get pixel movement rate\n pix = BlizzABS.pixel\n # calculates differences in x and y\n dx, dy = @x - ($game_player.x+pix/2)/pix, @y - ($game_player.y+pix*3/4)/pix\n # determines where to turn according to the x and y differences\n if dx < 0 && dx.abs >= dy.abs # player ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Detect the player in a rectangle around the event | def detect_player_rect(nx, ny)
return false if $game_switches[Yuki::Sw::Env_Detection]
c = $game_map.events[@event_id]
dx = ($game_player.x - c.x).abs
dy = ($game_player.y - c.y).abs
return (dx <= nx && dy <= ny)
end | [
"def pbEventFacesPlayer?(event, player, distance)\r\n return false if !event || !player || distance <= 0\r\n x_min = x_max = y_min = y_max = -1\r\n case event.direction\r\n when 2 # Down\r\n x_min = event.x\r\n x_max = event.x + event.width - 1\r\n y_min = event.y + 1\r\n y_max = event.y + distanc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete the current event forever | def delete_this_event_forever
$env.set_event_delete_state(@event_id)
$game_map.events[@event_id]&.erase
end | [
"def delete_event ev\n @@game.events.delete ev\n @@game.current_state.events.delete ev\n end",
"def gcdelete_event\n cal_event = Event.find_by(gamecall_tag: self.id)\n cal_event.destroy if cal_event\n end",
"def delete\n MoxiworksPlatform::Event.delete(self.to_hash)\n end",
"def fr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wait for the end of the movement of this particular character | def wait_character_move_completion(event_id = @event_id)
@move_route_waiting = true
@move_route_waiting_id = event_id
end | [
"def wait_for_player\n wait_character_move_completion 0\n end",
"def movement_end_anim\n if @update_base_position\n @battler.base_x = @battler.actual_x\n @battler.base_y = @battler.actual_y\n @update_base_position = false\n end\n @battler.initial_x = @battler.actual_x\n @battler.ini... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
URL slug creation logic The steps are roughly as follows 1. If the record hasn't passed its validations, exit immediately 2. If the source_column is empty, exit immediately (no error is thrown this should be checked with your own validation) 3. If the slug is already set we have nothing to do, otherwise a. Strip out pu... | def create_slug
return if self.errors.size > 0
return if self[source_column].blank?
if self[slug_column].to_s.empty?
proposed_slug = self[source_column].to_slug
suffix = ""
existing = true
acts_as_slugable_class.transaction do... | [
"def create_slug\r\n return if self.errors.length > 0\r\n \r\n if self[source_column].nil? or self[source_column].empty?\r\n return\r\n end\r\n\r\n if self[slug_column].to_s.empty? \r\n #remove accents\r\n pro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is the constructor for the Paper class. All dimension parameters to this method are in twips. ==== Parameters name:: The name for the paper object. width:: The width of the paper in portrait mode. height:: The height of the paper in portrait mode. | def initialize(name, width, height)
@name = name
@width = width
@height = height
end | [
"def initialize (name, height = 10)\n @name = name\n @height = height\n end",
"def initialize(width = 0, height = 0)\n @width = width\n @height = height\n end",
"def initialize\n @paper = Paper::A4\n @left_margin = DEFAULT_LEFT_MARGIN\n @right_margin = DEFAULT_RI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assert("RustRegexpcasefold?", '15.2.15.7.6') do assert_false RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustRegexp::MULTILINE).casefold? assert_true RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustRegexp::IGNORECASE | RustRegexp::EXTENDED).casefold? assert_true RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustReg... | def test_match
reg = RustRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
assert_false reg.match("http://masamitsu-murase.12345/hoge.html").nil?
assert_nil reg.match("http:///masamitsu-murase.12345/hoge.html")
end | [
"def prefer_for_regular_expression_match; end",
"def casefold?\n end",
"def casefold?() end",
"def test_match_nocase\r\n\t\t#content with exact match\r\n\t\tcontent = \"first line.\\nthis string contains a case insensitive match on: MyMatch123\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
if RustRegexp.const_defined? :ASCII_RANGE assert('RustRegexpoptions (no options)') do assert_equal RustRegexp::ASCII_RANGE | RustRegexp::POSIX_BRACKET_ALL_RANGE | RustRegexp::WORD_BOUND_ALL_RANGE, OnigRegexp.new(".").options end assert('RustRegexpoptions (multiline)') do assert_equal RustRegexp::MULTILINE | RustRegexp:... | def test_extended_patterns_no_flags
[
[ ".*", "abcd\nefg", "abcd" ],
[ "^a.", "abcd\naefg", "ab" ],
[ "^a.", "bacd\naefg", "ae" ],
[ ".$", "bacd\naefg", "d" ]
].each do |reg, str, result|
m = RustRegexp.new(reg).match(str)
puts m.inspect
unless m.nil?
assert_equ... | [
"def prefer_for_regular_expression_match; end",
"def valid_regex; end",
"def test_regexp\n# (find-node \"(emacs-ja)Regexps\")\n \n conv = lambda{|from,to| assert_equal(to, el4r_conv_regexp(from)) }\n conv[ //, '' ]\n conv[ /a/, 'a' ]\n conv[ /a./, 'a.' ]\n conv[ /a*/, 'a*' ]\n conv[ /a+/, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /requests/1 DELETE /requests/1.json | def destroy
@request.destroy
respond_to do |format|
format.html { redirect_to requests_url }
format.json { head :no_content }
end
end | [
"def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end",
"def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return current user instance, used for authorization. This method can be redefined in ApplicationController if you want to use application's auth system. ex: class ApplicationController < ActionController::Base def current_puffer_user current_user end end In this case returner user model instance should respond to has_... | def current_puffer_user
@current_puffer_user ||= begin
super
rescue NoMethodError
::Admin::SessionsController.model.to_adapter.get(session[:puffer_user_id])
end
end | [
"def current_user\n model = Bolt::Config.user_model_class\n @current_user ||= (logged_in? ? model.find(session[:user_id]) : model.new)\n end",
"def current_user\n return @current_user\n end",
"def current_user\n return @current_user if @current_user\n\n token = request.headers['X-Auth... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute record creation based in quantity input | def execute_customer_record_create(qty)
puts "Starting to create Customer records... Please give the API time to respond...\n"
qty.times do |t|
body = FakeCustomer.new.generate
# puts JSON.pretty_generate(JSON.parse(body.to_json))
FakeRestActions.new(endpoint: "Customers", body: body, access_... | [
"def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end",
"def create(name, price, description, quantity)\n @products.exec(\"INSERT INTO acme_shop (name, price, description, quantity) VALUES (... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bookings GET /bookings.json | def index
@bookings = Booking.all
respond_to do |format|
format.html
format.json { render :json => @bookings }
end
end | [
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n render json: { bookings: @site.bookings.order(d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /student_app_cat_regnos GET /student_app_cat_regnos.json | def index
@student_app_cat_regnos = StudentAppCatRegno.all
end | [
"def index\n @student_app_cat_217127274s = StudentAppCat217127274.all\n end",
"def create\n @student_app_cat_regno = StudentAppCatRegno.new(student_app_cat_regno_params)\n\n respond_to do |format|\n if @student_app_cat_regno.save\n format.html { redirect_to @student_app_cat_regno, notice: 'S... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /student_app_cat_regnos POST /student_app_cat_regnos.json | def create
@student_app_cat_regno = StudentAppCatRegno.new(student_app_cat_regno_params)
respond_to do |format|
if @student_app_cat_regno.save
format.html { redirect_to @student_app_cat_regno, notice: 'Student app cat regno was successfully created.' }
format.json { render :show, status: ... | [
"def index\n @student_app_cat_regnos = StudentAppCatRegno.all\n end",
"def create\n @student_app_cat_217127274 = StudentAppCat217127274.new(student_app_cat_217127274_params)\n\n respond_to do |format|\n if @student_app_cat_217127274.save\n format.html { redirect_to @student_app_cat_217127274... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /student_app_cat_regnos/1 PATCH/PUT /student_app_cat_regnos/1.json | def update
respond_to do |format|
if @student_app_cat_regno.update(student_app_cat_regno_params)
format.html { redirect_to @student_app_cat_regno, notice: 'Student app cat regno was successfully updated.' }
format.json { render :show, status: :ok, location: @student_app_cat_regno }
else
... | [
"def update\n respond_to do |format|\n if @student_app_cat_217127274.update(student_app_cat_217127274_params)\n format.html { redirect_to @student_app_cat_217127274, notice: 'Student app cat 217127274 was successfully updated.' }\n format.json { render :show, status: :ok, location: @student_ap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /student_app_cat_regnos/1 DELETE /student_app_cat_regnos/1.json | def destroy
@student_app_cat_regno.destroy
respond_to do |format|
format.html { redirect_to student_app_cat_regnos_url, notice: 'Student app cat regno was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @student_app_cat_217127274.destroy\n respond_to do |format|\n format.html { redirect_to student_app_cat_217127274s_url, notice: 'Student app cat 217127274 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @congress_memory_has_stude... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /promulher_forms GET /promulher_forms.json | def index
@promulher_forms = PromulherForm.all
end | [
"def retrieve_forms()\n start.uri('/api/form')\n .get()\n .go()\n end",
"def index #retirar\n @pergunta_forms = PerguntaForm.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pergunta_forms }\n end\n end",
"def index\n\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /promulher_forms POST /promulher_forms.json | def create
@promulher_form = PromulherForm.new(promulher_form_params)
respond_to do |format|
if @promulher_form.save
format.html { redirect_to @promulher_form, notice: 'Promulher form was successfully created.' }
format.json { render :show, status: :created, location: @promulher_form }
... | [
"def create_form(form_id, request)\n start.uri('/api/form')\n .url_segment(form_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def create\n @poole_app_form = current_user.poole_app_forms.build(poole_app_form_params)\n\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /promulher_forms/1 PATCH/PUT /promulher_forms/1.json | def update
respond_to do |format|
if @promulher_form.update(promulher_form_params)
format.html { redirect_to @promulher_form, notice: 'Promulher form was successfully updated.' }
format.json { render :show, status: :ok, location: @promulher_form }
else
format.html { render :edit ... | [
"def update_form(form_id, request)\n start.uri('/api/form')\n .url_segment(form_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end",
"def update\n @formulario = Formulario.find(params[:id])\n\n respond_to do |format|\n if @fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /promulher_forms/1 DELETE /promulher_forms/1.json | def destroy
@promulher_form.destroy
respond_to do |format|
format.html { redirect_to promulher_forms_url, notice: 'Promulher form was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @form1.destroy\n respond_to do |format|\n format.html { redirect_to form1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pergunta_form = PerguntaForm.find(params[:id])\n @pergunta_form.destroy\n\n respond_to do |format|\n format.html { redi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /minuts/1 DELETE /minuts/1.json | def destroy
@minut.destroy
respond_to do |format|
format.html { redirect_to minuts_url, notice: 'Minut was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mast.destroy\n respond_to do |format|\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure password and confirm_password are the same on update | def validate_on_update
unless plain_password.blank?
unless plain_password == password_confirmation
errors.add_to_base("Passwords don't match")
end
# Validate password criteria
unless plain_password.length >= 6
errors.add_to_base("Password must be a... | [
"def validate_on_update\n unless plain_password.blank?\n unless plain_password == password_confirmation\n errors.add_to_base(\"Passwords don't match\")\n end\n # Validate password criteria\n unless plain_password.length >= 6\n errors.add_to_base(\"Password must be at least 6 cha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We are going to connect this user object with a facebook id. But only ever one account. | def link_fb_connect(fb_user_id)
unless fb_user_id.nil?
#check for existing account
existing_fb_user = ::User.find_by_fb_user_id(fb_user_id)
#merge the existing account
unless existing_fb_user.nil?
merge_with(existing_fb_user)
end
#link the ... | [
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n # check for existing account\n existing_fb_user = User.find_by_fb_user_id(fb_user_id)\n # unlink the existing account\n unless existing_fb_user.nil?\n existing_fb_user.fb_user_id = nil\n existing_fb_user.save!\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find the user in the database, first by the facebook user id and if that fails through the email hash | def find_by_fb_user(fb_user)
u = ::User.find(:first, :conditions => {_(:fb_user_id, :user) => fb_user.uid}) || ::User.find(:first, :conditions => {_(:facebook_hash, :user) => fb_user.email_hashes})
# make sure we have a person
if u && !u.person
u.create_person_from_fb(fb_user)
... | [
"def existing_facebook_user\n User.find_by_facebook_uid(auth_hash.uid)\n end",
"def find_user_by_bot_id\n @user = User.find_by(:fb_bot_id => params[:fb_bot_id])\n link_facebook unless @user && @user.id\n end",
"def find_friend_by_facebook_id(fb_id)\n if fb_id == external_id\n return user\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
delete the default shipment and create split shipments out of it | def split_shipment!
self.shipments.destroy_all
units = self.inventory_units.includes(:variant=>:product)
units.group_by{|u| u.variant.product.brand_id}.each do |brand_id,units|
s = Spree::Shipment.create!({ :order => self, :shipping_method => shipping_method, :address => self.ship_address,
... | [
"def create_drop_ship_orders\n self.drop_ship_orders.destroy_all\n self.line_items.group_by{ |li| li.product.supplier_id }.each do |supplier_id, supplier_items|\n if supplier_id.present?\n supplier = Spree::Supplier.find(supplier_id)\n dso = supplier.orders.create({:order_id => self.id})\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method combines First name, Middle name & Last name and returns Full Name of Contact | def full_name
return Contact.generate_full_name self.first_name, self.middel_name, self.last_name
end | [
"def get_full_name (contact)\n \"#{contact[\"name\"]} #{contact[\"last_name\"]}\"\n end",
"def full_name\n [first_name, surname].join(' ')\n end",
"def full_name_and_company_name\n \"#{self.fname.downcase.titleize} #{self.lname.downcase.titleize} of #{self.company_name}\"\n end",
"def full_name_la... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method returns the top connector status of Contact | def is_top_connector?
TopConnector.exists? :contact_id => self.id
end | [
"def status\n @connections.status\n end",
"def status\n @client.raw('get', '/status', nil, nil, @contact_v1_url)\n end",
"def status\n self.activities.status_updates.by_newest.first\n end",
"def connector_type\n cable.connector_types[self.end - 1]\n end",
"def getConnectorStart()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method validates a Contact for Manual Update | def validated_for_update?(c)
valid = true
if first_name.blank? && last_name.blank?
c.errors.add_to_base("Must enter contact name")
valid = false
end
ex_email = Contact.find(:first, :include => [:emails], :conditions => ["emails.email_text = ? AND contacts.user_id = ? AND contacts.id != ? AND... | [
"def validate_updated_contact_form_fields\n errors.add(:contact_form_fields, :invalid_contact_form_field) unless contact_form_fields.all? { |s| s.valid? || s.new_record? }\n end",
"def validate_update(comment)\n true\n end",
"def validate_contact\n errors.add(:mail, \"You must fill in at least one co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method Returns Collection of Contacts that are suspected as duplicates in the Merge but not Merged. THis scenario does not occur now. | def duplicates
Contact.find(:all, :conditions => ["id != ? AND merge_id = ?", id, merge_id])
end | [
"def unconnected_contacts\n unconnected = []\n Contact.all.each do |contact|\n unconnected << contact if contacts.exclude? contact\n end\n return unconnected\nend",
"def merge(contacts_with_dupes)\n group_by_email(contacts_with_dupes).flat_map do |_, contacts|\n contacts.sort_by! { |c| c[:date_adde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method To Unmerge Contact | def un_merge
Contact.transaction do
self.parents.each do |contact|
contact.update_attribute('merged_to_form_contact_id', 0)
if contact.contact_type == Constants::CONTACT_TYPE::PROSPECT
ContactProspect.update_all("prospect_old_id = NULL, prospect_id = #{contact.id}", "prospect_old_id ... | [
"def remove_tag_from_contact\n\t\t\t\t# unlike the remove method in account, this only removes the tag from one contact\n\t\t\t\t\n\t\t\tend",
"def unlink_contact(_contact)\n _rc = false\n if self.contacts.detect { |c| c._id ==_contact._id }\n _facility = self.facilities.any_in(consumer_ids: [_contact.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def set_company(company_name) if self.valid? unless company_name.nil? company_name = company_name.strip unless company_name.blank? company = Company.find_or_create_by_name company_name self.company_id = company.id self.company_name = company.name end end end end | def update_company company_name
if self.valid?
unless company_name.nil?
company_name = company_name.strip
if company_name.blank?
self.company_id = 0
self.company_name = ''
else
company = Company.find_or_create_by_name company_name
unless company.... | [
"def company_name=(value)\n if value.present?\n if existing_company = Company.find_by_name(value)\n self.company = existing_company\n else\n self.build_company(:name => value)\n end\n else\n self.company = nil\n end\n end",
"def setCompanyName(companyName)\r\n\t\t\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save titles for contact | def save_contact_titles(positions)
title_str= ''
positions.each_with_index do |position, index|
if position.is_current == 'true'
company = Company.find_or_create_by_name(position.company.name)
title = self.titles.build(:position => position.title, :company_id => company.id)
title_... | [
"def _before_save_title_checks\n populate_title_if_needed(:contents, TITLE_LENGTH)\n end",
"def sync_titles\n # Title was submitted\n if self.title.blank?\n self.title = get_title_from_chartup(chartup) || 'Untitled'\n else\n set_chartup_title(self.title)\n end\n end",
"def nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /transferences GET /transferences.json | def index
@transferences = Transference.all
end | [
"def index\n @payment_transferences = Payment::Transference.all\n end",
"def index\n @transaccions = Transaccion.all\n end",
"def index\n @transits = current_user.transits\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transits }\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /transferences POST /transferences.json | def create
@transference = Transference.new(transference_params)
respond_to do |format|
if @transference.save
format.html { redirect_to @transference, notice: 'Transference was successfully created.' }
format.json { render :show, status: :created, location: @transference }
else
... | [
"def index\n @transferences = Transference.all\n end",
"def create\n @transation = Transation.new(transation_params)\n @stores = Store.all\n @representatives = Representative.all\n\n\n respond_to do |format|\n if @transation.save\n format.html { redirect_to action: \"index\", notice: \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /transferences/1 PATCH/PUT /transferences/1.json | def update
respond_to do |format|
if @transference.update(transference_params)
format.html { redirect_to @transference, notice: 'Transference was successfully updated.' }
format.json { render :show, status: :ok, location: @transference }
else
format.html { render :edit }
... | [
"def update\n\n respond_to do |format|\n if @transact.update(transact_params)\n format.html { redirect_to @transact, notice: 'Transact was successfully updated.' }\n format.json { render :show, status: :ok, location: @transact }\n else\n format.html { render :edit }\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /transferences/1 DELETE /transferences/1.json | def destroy
@transference.destroy
respond_to do |format|
format.html { redirect_to transferences_url, notice: 'Transference was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @transit = Transit.find(params[:id])\n @transit.destroy\n\n respond_to do |format|\n format.html { redirect_to transits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @translantion = Translantion.find(params[:id])\n @translantion.destroy\n\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Amazon's description: > Call the CloseOrderReference operation to indicate that a previously > confirmed order reference has been fulfilled (fully or partially) and that > you do not expect to create any new authorizations on this order > reference. You can still capture funds against open authorizations on the > order... | def close_order_reference
client.close_order_reference(@amazon_order_reference_id)
end | [
"def close_order_reference(options = {})\n requires!(options, :amazon_order_reference_id)\n commit('CloseOrderReference', options)\n end",
"def cancel_order_reference(options = {})\n requires!(options, :amazon_order_reference_id)\n commit('CancelOrderReference', options)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Perform a key lookup in the registered data tables | def table_lookup(key, arg, table = nil)
lookup_key = key[1..-1].to_sym
lookup_table = table || @tables[lookup_key]
if lookup_table.kind_of? Hash
lookup_table[arg.to_sym]
elsif lookup_table.kind_of? Array
if lookup_table.member? arg or lookup_table.member? arg.t... | [
"def lookup_keys\n @lookup_keys ||= %i[id name login email number] & attribute_names.map(&:to_sym)\n end",
"def load_specified(table, key)\n self.table = table\n self.key = key\n load\n end",
"def already_loaded_records_by_key; end",
"def data_key(name, data) ; name end",
"def call... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete tags from a learnerId Delete the specified tags from the learner. Deleting tags that do not exist will still result in a success. | def delete_learner_tags(learner_id, tags, opts = {})
delete_learner_tags_with_http_info(learner_id, tags, opts)
nil
end | [
"def delete_learner_tags_with_http_info(learner_id, tags, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LearnerApi.delete_learner_tags ...'\n end\n # verify the required parameter 'learner_id' is set\n if learner_id.nil?\n fail Argumen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete tags from a learnerId Delete the specified tags from the learner. Deleting tags that do not exist will still result in a success. | def delete_learner_tags_with_http_info(learner_id, tags, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: LearnerApi.delete_learner_tags ...'
end
# verify the required parameter 'learner_id' is set
if learner_id.nil?
fail ArgumentError, "Mi... | [
"def bookmarks_tags_delete(id, *tags)\n request(:bookmarks_tags_delete, :id => id, :tags => tags)\n end",
"def delete_learner_tags(learner_id, tags, opts = {})\n delete_learner_tags_with_http_info(learner_id, tags, opts)\n nil\n end",
"def delete_tags\n @tags.delete_tags(@filename) unl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get tags for a learnerId Returns the tags for the learner. | def get_learner_tags(learner_id, opts = {})
data, _status_code, _headers = get_learner_tags_with_http_info(learner_id, opts)
data
end | [
"def get_learner_tags_with_http_info(learner_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: LearnerApi.get_learner_tags ...'\n end\n # verify the required parameter 'learner_id' is set\n if learner_id.nil?\n fail ArgumentError, \"Mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get tags for a learnerId Returns the tags for the learner. | def get_learner_tags_with_http_info(learner_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: LearnerApi.get_learner_tags ...'
end
# verify the required parameter 'learner_id' is set
if learner_id.nil?
fail ArgumentError, "Missing the re... | [
"def get_learner_tags(learner_id, opts = {})\n data, _status_code, _headers = get_learner_tags_with_http_info(learner_id, opts)\n data\n end",
"def tags(id)\n wf_source_id?(id)\n api.get([id, 'tag'].uri_concat)\n end",
"def tags(id)\n wf_event_id?(id)\n api.get([id, 'tag'].ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add tags to a learnerId Applies the provided tags to the learner. Tags are used to easily identify resources. Adding tags can enable more refined searches when working with Reportage. | def put_learner_tags_with_http_info(learner_id, tags, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: LearnerApi.put_learner_tags ...'
end
# verify the required parameter 'learner_id' is set
if learner_id.nil?
fail ArgumentError, "Missing ... | [
"def bookmarks_tags_add(id, *tags)\n request(:bookmarks_tags_add, :id => id, :tags => tags)\n end",
"def add_tags(*tags)\n @tags += tags\n end",
"def add_tags(tags)\n tags.each { |tag| add_tag(tag) }\n end",
"def get_learner_tags_with_http_info(learner_id, opts = {})\n if @api_client.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
It's important to regularly remove devices that Apple reports as stale. If you continue to try to notify stale devices, Apple may revoke your access to APNS! | def deactivate_stale_devices!
device_tokens = client.devices
Rails.logger.info "Found #{device_tokens.length} stale devices."
device_tokens.each do |device_token|
Rails.logger.debug("deactivating device with token: #{device_token}")
devices = Device.where(notification_token: device_token)
... | [
"def unregister_device\n # In the HTTP request is an Authorization header. Its value is the word ApplePushNotifications and the authentication token, separated by a single space. The authentication token is the same token that’s specified in your package’s website.json file. Your web service can use this authent... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /categorias/1 GET /categorias/1.json | def show
render json: @categoria
end | [
"def show\n @categoria = Categoria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @categoria }\n end\n end",
"def show\n @categoria_cota = CategoriaCota.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.er... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /categorias POST /categorias.json | def create
@categoria = Categoria.new(categoria_params)
if @categoria.save
render json: @categoria
else
render json: @categoria.errors, status: :unprocessable_entity
end
end | [
"def create\n if params[:categoria_producto]\n p = Producto.find(params[:producto_id])\n c = Categoria.find(params[:categoria_id])\n\n if p.categorias << c\n render json: c, status: :created\n else\n render json: {:errors => {categoria: [\"No se ha podido agregar categoria\"]}},... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /categorias/1 PATCH/PUT /categorias/1.json | def update
if @categoria.update(categoria_params)
render json: @categoria
else
render json: @categoria.errors, status: :unprocessable_entity
end
end | [
"def update\n respond_to do |format|\n if @categoria.update(categoria_params)\n format.html { redirect_to @categoria, notice: 'Servico was successfully updated.' }\n format.json { render :show, status: :ok, location: @categoria }\n else\n format.html { render :edit }\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.