query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
POST /machine_total_owners POST /machine_total_owners.xml
def create @machine_total_owner = MachineTotalOwner.new(params[:machine_total_owner]) respond_to do |format| if @machine_total_owner.save format.html { redirect_to(@machine_total_owner, :notice => 'Machine total owner was successfully created.') } format.xml { render :xml => @machine_tot...
[ "def owners_count=(value)\n @owners_count = value\n end", "def new\n @machine_total_owner = MachineTotalOwner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_total_owner }\n end\n end", "def create\n @total_owne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /machine_total_owners/1 PUT /machine_total_owners/1.xml
def update @machine_total_owner = MachineTotalOwner.find(params[:id]) respond_to do |format| if @machine_total_owner.update_attributes(params[:machine_total_owner]) format.html { redirect_to(@machine_total_owner, :notice => 'Machine total owner was successfully updated.') } format.xml { ...
[ "def update\n @total_owner = TotalOwner.find(params[:id])\n\n respond_to do |format|\n if @total_owner.update_attributes(params[:total_owner])\n format.html { redirect_to(@total_owner, :notice => 'Total owner was successfully updated.') }\n format.xml { head :ok }\n else\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /machine_total_owners/1 DELETE /machine_total_owners/1.xml
def destroy @machine_total_owner = MachineTotalOwner.find(params[:id]) @machine_total_owner.destroy respond_to do |format| format.html { redirect_to(machine_total_owners_url) } format.xml { head :ok } end end
[ "def destroy\n @total_owner = TotalOwner.find(params[:id])\n @total_owner.destroy\n\n respond_to do |format|\n format.html { redirect_to(total_owners_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @machine_user_name = MachineUserName.find(params[:id])\n @machine_user_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform GET request, parsing response as JSON. Autofollows redirects until redirect_limit reached. Raises Net::HTTPExceptions if response code not 2xx.
def get(path, redirect_limit=5) parse_json do |parser| @http_client.get(path, redirect_limit) {|chunk| parser << chunk } end end
[ "def get(path, redirect_limit=5, &block)\n request = Net::HTTP::Get.new(path)\n @http.request(request) do |response|\n if response.is_a? Net::HTTPSuccess\n return response.read_body(&block)\n elsif response.is_a? Net::HTTPRedirection\n return follow_redirect(response, redirect_limit, &...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform POST request, parsing response as JSON. Optionally takes a form_data hash. Raises Net::HTTPExceptions if response code not 2xx.
def post(path, form_data=nil) parse_json do |parser| @http_client.post(path, form_data) {|chunk| parser << chunk } end end
[ "def post_form(*args)\r\n begin\r\n uri = URI.parse(args[0])\r\n res = Net::HTTP.start(uri.host,uri.port){|http|\r\n req = Net::HTTP::Post.new(uri.path,args[2])\r\n req.set_form_data args[1]\r\n http.request(req)\r\n }\r\n return JSON.parse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fibo_rec does the same as the fibo function, but recursively
def fibo_rec(n) return n <= 1 ? n : fibo(n - 1) + fibo(n - 2) end
[ "def fibs_rec(n)\n n == 0 || n == 1 ? n : fibs_rec(n-1) + fibs_rec(n-2)\n fibs(n)\nend", "def fibs_rec( n, fib = [0,1])\n\treturn 0 if n == 0\n\tif fib[n].nil?\n\t\tfib << fib[-2] + fib[-1]\n\t\tfibs_rec( n, fib )\n\telse\n\t\treturn fib[0..n-1]\n\tend\nend", "def fibo(n)\r\n check_pre(n.int?)\r\n n > 1 ?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Endpoint to save event updates
def save event = params # This assumes that all keys exists. Yay no error handling... toSave = Event.new(update_type: event[:event], start_time: event[:payload][:event][:start_time_pretty], end_time: event[:payload][:event][:end_time_pretty], location: event[:payload][:event][:location], ...
[ "def update\n #TODO params -> strong_params\n if @event.update(params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def save\n MoxiworksP...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writer method. We want to take this value, baby_name, and write into this variable, my_name. This method allows me to give a baby a name.
def name=(the_baby_name) @my_name = the_baby_name end
[ "def name=(the_baby_name) \n @my_name = the_baby_name\n end", "def update_boat_name=(name)\n @name = name\n puts @name\n end", "def set_name\n bio = forms('Biographical').find { |x|\n x.line[:whose] == 'mine'\n }\n names = bio.line[:first_name] + ' ' + bio.line[:last_name]\n with...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Flood paths are connections from one mapping to another along which the given flooder is activated. These paths are built for all flooders on startup, as they only need to be built once and should provide a performance increase in the queries. The flood paths are stored in a graph for the flooder the graph uri is build...
def build_flood_paths (flooder) flooderURI = flooder[:flooder] floodFrom = flooder[:floodFrom] || flooder[:path] || "<http://www.w3.org/2004/02/skos/core#broader>/^<http://www.w3.org/2004/02/skos/core#broader>" floodTo = flooder[:floodTo] || flooder[:path] || "<http://www.w3.org/2004/02/skos/core#broader>/^...
[ "def connect_flood_fill\n current_flood_fill = connect.flood_fill.clone\n connect.flood_fill = []\n\n current_flood_fill.each do |x, y|\n connect.main_region << [x, y]\n adjacent_points(x, y).each do |a_x, a_y|\n if connect_flood_fillable?(a_x, a_y)\n connect.flood_fill << [a_x, a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The root scope of the client locale, found on the locale file.
def locale_scope I18n::Scope.new(locale_translations) end
[ "def locale_root_path\n I18n.locale == I18n.default_locale ? '/' : \"/#{I18n.locale}\"\n end", "def current_locale\n Thread.current[:\"localite:locale\"] || base\n end", "def tm_scope\n language && language.tm_scope\n end", "def local_translation_scope\n [@controller.controller_path.split...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /hr/config/discipline_types GET /hr/config/discipline_types.json
def index @hr_config_discipline_types = Hr::Config::DisciplineType.all end
[ "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def show\n @discipline_type = DisciplineType.fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /hr/config/discipline_types POST /hr/config/discipline_types.json
def create @hr_config_discipline_type = Hr::Config::DisciplineType.new(hr_config_discipline_type_params) respond_to do |format| if @hr_config_discipline_type.save format.html { redirect_to @hr_config_discipline_type, notice: 'Discipline type was successfully created.' } format.json { rend...
[ "def index\n @hr_config_discipline_types = Hr::Config::DisciplineType.all\n end", "def create\n @discipline_type = DisciplineType.new(params[:discipline_type])\n\n respond_to do |format|\n if @discipline_type.save\n format.html { redirect_to @discipline_type, :notice => 'Tipo de disciplina c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /hr/config/discipline_types/1 PATCH/PUT /hr/config/discipline_types/1.json
def update respond_to do |format| if @hr_config_discipline_type.update(hr_config_discipline_type_params) format.html { redirect_to @hr_config_discipline_type, notice: 'Discipline type was successfully updated.' } format.json { render :show, status: :ok, location: @hr_config_discipline_type } ...
[ "def update\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n if @discipline_type.update_attributes(params[:discipline_type])\n format.html { redirect_to @discipline_type, :notice => 'Tipo de disciplina atualizado com sucesso.' }\n format.json { head :no_con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /hr/config/discipline_types/1 DELETE /hr/config/discipline_types/1.json
def destroy @hr_config_discipline_type.destroy respond_to do |format| format.html { redirect_to hr_config_discipline_types_url, notice: 'Discipline type was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @discipline_type = DisciplineType.find(params[:id])\n @discipline_type.destroy\n\n respond_to do |format|\n format.html { redirect_to discipline_types_url, :notice => 'Tipo de disciplina excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
There is a queue for the selfcheckout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out! input customers: an array of positive integers representing the queue. Each integer represents a customer, and its value is the amount of time they requi...
def queue_time(customers, n) if n >= customers.length && !customers.empty? customers.max elsif customers.empty? 0 else time_steps = [] current_queue = customers[0..(n - 1)] addition_to_queue = [] until current_queue.empty? customers.shift(n) time_steps << current_queue.min ...
[ "def queue_time(customers, n)\n return customers.inject(0, &:+) if n == 1\n time = 0\n cust_num = customers.size\n tills = Array.new(n > cust_num ? cust_num : n) \n tills = tills.map do |till|\n customers.shift\n end\n until tills.all?(&:zero?) && customers.empty?\n tills.map! do |till|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the current users is a moderator of a specified board
def current_user_is_moderator?(board) signed_in? && current_user.moderating?(board) end
[ "def moderating?(board)\n\t\tself.moderating.include?(board)\n\tend", "def board_admin?(user)\n if self.user_id == user.id\n true\n else\n false\n end\n end", "def moderator?(user)\n\t\tself.moderators.include?(user)\n\tend", "def moderator?\n \tif current_user.role == \"moderator\"\n \t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
scope/association that is used to test eligibility TODO: use vendors association to get eligible items
def eligible_items @eligible_items ||= ::InventoryItem.where(vendor: promotion.vendors) end
[ "def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item\", 20, :fixed, nil, nil)\n item.activate\n\n assert(user.can_buy?(item))\n\n user.work_on_behalf_of(org)\n assert(!user.on_behalf_of.can_buy?(item))\n end", "def ex...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds the static forwarding entries for this VLANs.
def add_static_forwarding(opts) opts = check_params(opts,[:forwarding_entries]) super(opts) end
[ "def static_route_vlan\n super\n end", "def add_static_ips\n # configure static IP (if specified in metadata)\n static_ip_numerals.each do |n_ip|\n add_static_ip(n_ip)\n end\n end", "def remove_static_forwarding(opts)\n opts = check_params(opts,[:forwarding_entries])\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the source checking states for this VLANs. If enabled and auto lasthop is disabled, check that the source of the first packet of a connection is correct (correct VLAN, router, node). This is equivalent to BSD's net.inet.sourcecheck sysctl variable.
def source_check_state super end
[ "def source_dest_check\n data[:source_dest_check]\n end", "def list_source_availabilities(id, opts = {})\n data, _status_code, _headers = list_source_availabilities_with_http_info(id, opts)\n data\n end", "def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes all dynamic forwarding entries from this VLANs.
def remove_all_dynamic_forwardings super end
[ "def clear_forwarded_ports\n args = []\n read_forwarded_ports(@uuid).each do |nic, name, _, _|\n args.concat([\"--natpf#{nic}\", \"delete\", name])\n end\n\n execute(\"modifyvm\", @uuid, *args) if !args.empty?\n end", "def remove_static_forwarding(opts)\n opts = chec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes all static forwarding entries from this VLANs.
def remove_all_static_forwardings super end
[ "def remove_static_forwarding(opts)\n opts = check_params(opts,[:forwarding_entries])\n super(opts)\n end", "def remove_all_dynamic_forwardings\n super\n end", "def clear_forwarded_ports\n args = []\n read_forwarded_ports(@uuid).each do |nic, name, _, _|\n args.concat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes the static forwarding entries from this VLANs.
def remove_static_forwarding(opts) opts = check_params(opts,[:forwarding_entries]) super(opts) end
[ "def remove_all_static_forwardings\n super\n end", "def remove_all_dynamic_forwardings\n super\n end", "def clear_forwarded_ports\n args = []\n read_forwarded_ports(@uuid).each do |nic, name, _, _|\n args.concat([\"--natpf#{nic}\", \"delete\", name])\n end\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the failsafe actions for this VLANs.
def set_failsafe_action(opts) opts = check_params(opts,[:actions]) super(opts) end
[ "def not_allowed_resource_actions=(value)\n @not_allowed_resource_actions = value\n end", "def allowed_resource_actions=(value)\n @allowed_resource_actions = value\n end", "def actions=(value)\n @actions = value\n end", "def resourc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the failsafe states for this VLANs.
def set_failsafe_state(opts) opts = check_params(opts,[:states]) super(opts) end
[ "def vulnerability_states=(value)\n @vulnerability_states = value\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlan_names])\n super(opts)\n end", "def set_across_virtu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the failsafe timeouts for this VLANs.
def set_failsafe_timeout(opts) opts = check_params(opts,[:timeouts]) super(opts) end
[ "def timeout=(value)\n @timeout = value.to_i\n @timeout = DEFAULT_TIMEOUT if (@timeout <= 0)\n end", "def timeouts_set=(_arg0); end", "def set_timeout timeout_s\n Lib.keyctl_set_timeout id, timeout_s\n self\n end", "def timeout=(value)\n @timeout = value\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the learning modes for this VLANs.
def set_learning_mode(opts) opts = check_params(opts,[:modes]) super(opts) end
[ "def setModes(modes)\n # set the modes\n (0...@list_size).each do |j|\n @mode[j] = modes[j]\n end\n end", "def set_learning_rate(rate = 0.01)\n @learning_rate = rate\n end", "def set_vlan(opts)\n opts = check_params(opts,[:vlans])\n super(opts)\n end", "def color_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the MAC masquerade addresses for this VLANs.
def set_mac_masquerade_address(opts) opts = check_params(opts,[:mac_masquerade_addresses]) super(opts) end
[ "def net_set_mac(mac_addr)\n execute(:set_network_mac, VmId: vm_id, Mac: mac_addr)\n end", "def set_mac_address(mac)\n end", "def setBlockedMACList(macList)\n macList.each { |m|\n @blockedMACList.add(m)\n }\n end", "def set_mac_address(opts = {})\n cmd = command_builder('...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the the source checking states for this VLANs. If enabled and auto lasthop is disabled, check that the source of the first packet of a connection is correct (correct VLAN, router, node). This is equivalent to BSD's net.inet.sourcecheck sysctl variable.
def set_source_check_state(opts) opts = check_params(opts,[:states]) super(opts) end
[ "def source_check_state\n super\n end", "def set_source_interface(name = 'Vxlan1', opts = {})\n commands = command_builder('vxlan source-interface', opts)\n configure_interface(name, commands)\n end", "def aws_instance_network_interface_first_source_dest_check_disable(opts)\n opts[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fingers/1 GET /fingers/1.xml
def show @finger = Finger.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @finger } end end
[ "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fingers/new GET /fingers/new.xml
def new @finger = Finger.new @finger.user = current_user respond_to do |format| format.html # new.html.erb format.xml { render :xml => @finger } end end
[ "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /fingers POST /fingers.xml
def create @finger = Finger.new(params[:finger]) @finger.user = current_user respond_to do |format| if @finger.save flash[:notice] = 'Finger was successfully created.' format.html { redirect_to(fingers_path) } format.xml { render :xml => @finger, :status => :created, :loc...
[ "def update\n @finger = Finger.find(params[:id])\n @finger.user = current_user\n respond_to do |format|\n if @finger.update_attributes(params[:finger])\n flash[:notice] = 'Finger was successfully updated.'\n format.html { redirect_to(fingers_path) }\n format.xml { head :ok }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /fingers/1 PUT /fingers/1.xml
def update @finger = Finger.find(params[:id]) @finger.user = current_user respond_to do |format| if @finger.update_attributes(params[:finger]) flash[:notice] = 'Finger was successfully updated.' format.html { redirect_to(fingers_path) } format.xml { head :ok } else ...
[ "def create\n @finger = Finger.new(params[:finger])\n @finger.user = current_user\n \n respond_to do |format|\n if @finger.save\n flash[:notice] = 'Finger was successfully created.'\n format.html { redirect_to(fingers_path) }\n format.xml { render :xml => @finger, :status => :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /fingers/1 DELETE /fingers/1.xml
def destroy @finger = Finger.find(params[:id]) @finger.destroy respond_to do |format| format.html { redirect_to(fingers_url) } format.xml { head :ok } end end
[ "def destroy\n @fattura = Fattura.find(params[:id])\n @fattura.destroy\n\n respond_to do |format|\n format.html { redirect_to(fatture_url) }\n format.xml { head :ok }\n end\n end", "def delete(name)\r\n id = name_to_id(name)\r\n self.class.delete(\"/cards/#{id}.xml\")\r\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Main entry point Requires a Time object and a parameter Hash, currently :format Returns an array of sound files with the requested output Example: sound_files_for_time(Time.now, format: "dMYaHm" format: h: 12h hour H: 24h hour m: minutes s: seconds d: day in number w: weekday name M: month name Y: year as "twenty twelv...
def sounds_for_time(time, args={}) format = args.delete(:format) || 'dMYaHm' result = [] format.each_char do |c| result += send("parse_#{FORMAT_TABLE[c]}".to_sym, time) end result end
[ "def run\n file = \"english.srt\"\n times = parse_times file\n build_ffmpeg times, file\nend", "def collectFileInformation(tracks, flavor, startTimes, real_start_time)\n startTimes.each do |file|\n pathToFile = File.join(file[\"filepath\"], file[\"filename\"])\n\n BigBlueButton.logger.info( \"Path...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the sounds for the single digits composing a number
def sounds_for_digits(num) result = [] num.to_s.each_char do |c| result << sound_path("#{c}.ul") end result end
[ "def get_drop(num)\n\t\t\t\tsounds = {\n\t\t\t\t\t3 => 'Pling',\n\t\t\t\t\t5 => 'Plang',\n\t\t\t\t\t7 => 'Plong'\n\t\t\t\t}\n\t\t\t\tsounds[num] || ''\n\t\t\tend", "def shahmukhi_numerals(number)\n number.to_s.chars.map { |digit| I18n.t(:digits, locale: :pa_PK)[digit.to_i] }.join\n end", "def sounds(part)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an "h" character from the main methods Returns the time in AM time.
def parse_hour_12h(time) sounds_for_number(time.strftime("%l")) end
[ "def handle_h\n handle_at\n handle_possible(SeparatorSpace)\n tag = @tokens[@index].get_tag(ScalarHour)\n @hour = tag.type\n @ambiguous = false if @hour.zero? or @hour > 12 or (tag.width >= 2 and @hour < 10 and @options[:hours24] != false)\n next_tag\n @precision = :hour\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an "H" character from the main methods Returns the time in 24 time.
def parse_hour_24h(time) sounds_for_number(time.strftime("%k")) end
[ "def parse_hour_12h(time)\n sounds_for_number(time.strftime(\"%l\"))\n end", "def handle_h\n handle_at\n handle_possible(SeparatorSpace)\n tag = @tokens[@index].get_tag(ScalarHour)\n @hour = tag.type\n @ambiguous = false if @hour.zero? or @hour > 12 or (tag.width >= 2 and @hour < ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an "M" character from the main methods Returns the month in an array.
def parse_month(time) [file_for_month(time.strftime("%-m"))] end
[ "def roman_month(date)\n date[1]\n end", "def month_array\r\n\t\t[[\"January\", \"1\"],[\"February\", \"2\"], \r\n\t\t[\"March\", \"3\"],[\"April\",4],\r\n\t\t[\"May\",5],[\"June\",6],\r\n\t\t[\"July\",7],[\"August\",8],\r\n\t\t[\"September\",9],[\"October\",10],\r\n\t\t[\"November\",11],[\"December\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a "d" character from the main methods Returns the numbers for the day.
def parse_day(time) sounds_for_number(time.strftime("%-d")) end
[ "def handle_dn\n @wday = Date::DAYS[@tokens[@index].get_tag(DayName).type]\n @index += 1\n @precision = :day\n end", "def _D\n _tmp = _letter(\"d\", \"D\")\n set_failed_rule :_D unless _tmp\n return _tmp\n end", "def ordinal_day(day = @day)\n day.to_s + case day.to_s\n when...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a "w" character from the main methods Returns the weekday sound.
def parse_weekday(time) [file_for_day(time.strftime("%w"))] end
[ "def weekday_letter\n return strftime(\"%a\")[0..0]\n end", "def parse_weather(line)\n if line =~ /\\.\\.\\..*[sS]unny/ then\n return \"\\u2600\"\n elsif line =~ /\\.\\.\\..*[cC]loudy/ then\n return \"\\u2601\"\n elsif line =~ /\\.\\.\\..*[rR]ain/ then\n return \"\\u2602\"\n elsif line =~ /\\.\\....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a "m" character from the main methods Returns the numbers for the minutes
def parse_minutes(time) minutes = time.strftime("%M").to_i minutes == 0 ? [sound_path("oclock.ul")] : sounds_for_number(minutes) end
[ "def get_minutes(time)\n time[/\\d{2}:(\\d{2})/, 1]\n end", "def minutes\n _nudge[1]\n end", "def handle_m\n @minute = @tokens[@index].get_tag(ScalarMinute).type\n next_tag\n @precision = :minute\n end", "def CountingMinutes(str)\n parts = str.scan(/\\A(\\d+):(\\d\\d)(..)-(\\d+)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a "s" character from the main methods Returns the numbers for the seconds
def parse_seconds(time) sounds_for_number(time.strftime("%S")) end
[ "def parse_time(str)\n seconds = 0\n str.scan(/\\d+ *[Dd]/).each { |m| seconds += (m.to_i * 24 * 60 * 60) }\n str.scan(/\\d+ *[Hh]/).each { |m| seconds += (m.to_i * 60 * 60) }\n str.scan(/\\d+ *[Mm]/).each { |m| seconds += (m.to_i * 60) }\n str.scan(/\\d+ *[Ss]/).each { |m| seconds += (m.to_i) }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a "p" character Returns AM or PM sound files
def parse_am_pm(time) time.strftime("%P") == "am" ? [sound_path("a-m.ul")] : [sound_path("p-m.ul")] end
[ "def _P\n\n _save = self.pos\n while true # choice\n _tmp = _letter(\"p\", \"P\")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\\\p\")\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_P unless _tmp\n return _tmp\n end", "def pb...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the path for a sound file based on configuration and platform
def sound_path(name) multi_path(File.join(Adhearsion.config.ahnsay.sounds_dir, name)) end
[ "def get_sound_source(type)\r\n sound = nil\r\n case type\r\n when :play_fitbell\r\n sound = File.join(get_resource_path, \"sound/fitebell.wav\")\r\n when :play_ba\r\n sound = File.join(get_resource_path, \"sound/ba.wav\")\r\n when :play_click4\r\n sound = File.join(get_res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
will always be a positive integer and return its additive persistence which is the number of times you must add the digits in num until you reach a single digit. For example: if num is 2718 then your program should return 2 because 2 + 7 + 1 + 8 = 18 and 1 + 8 = 9 and you stop at 9.
def AdditivePersistence(num) # code goes here sum = 0 count = 0 until num < 10 num1 = num.to_s sum = 0 for i in 0..num1.length-1 sum += num1[i].to_i end num = sum count += 1 end return count end
[ "def AdditivePersistence(num)\n addv_pers = 0\n until num < 10\n num = num.digits.sum\n addv_pers += 1\n end\n addv_pers\nend", "def AdditivePersistence(num)\n\n if num < 10:\n return 0\n end\n if num > 10:\n array = num.to_s.split('').map { |digit| digit.to_i }\n \ttotal = 0\n \tadd ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
filter the counts based on the user id set produces a new array of just the matched items if the user id filter is nil we match all the form of the input data is expected to be: [[user_id, cohort], ...] we sum up the count of matching user_ids into their cohort bucket
def sum_cohorts(users) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end users.each do |user| user_id = user[0] cohort = user[1] sums[cohort] = 0 if sums[cohort].nil? if match_user_id?(user_id) sums[...
[ "def cohorts_query_in(db, proc)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n if !@user_ids.nil?\n # build our user ids\n total_ids = @user_ids.length\n count = 0\n stmt = \"\"\n @user_ids.ea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This form of query expects you to provide summarized results When we run the query we expect to get back results of: [[cohort, count], ...] we then record the sums in the rollup result table
def cohorts_query(db, proc) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end sql = proc.call(date_first, date_last) results = db.execute(sql) results.each do |r| cohort = r[0] sum = r[1] sums[cohort] = 0 ...
[ "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run a cohorts_query derived from the current user_ids that have been added formed into a set that can be used in an IN clause. We actually break the set up into multiple parts in case we have a very large number of ids. We then sum the cohorts from the multiple calls, and report them the query must return results as [[...
def cohorts_query_in(db, proc) sums = [] # initialize the expected number of cohorts (1..current_cohort).each do |cohort| sums[cohort] = 0 end if !@user_ids.nil? # build our user ids total_ids = @user_ids.length count = 0 stmt = "" @user_ids.each do |user_id| ...
[ "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /black_fridays GET /black_fridays.json
def index @black_fridays = BlackFriday.paginate(:page => params[:page], :per_page => 10) end
[ "def index\n @fridays = Friday.all\n end", "def index\n\t\t@fridays = CareFriday.desc(:created_at)\n\tend", "def index\n @holidays = Holiday.all\n render json: @holidays\n end", "def flights\n club = GolfClub.find(params[:golf_club_id])\n if club.user_id != current_user.id then\n render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /black_fridays POST /black_fridays.json
def create @black_friday = BlackFriday.new(black_friday_params) respond_to do |format| if @black_friday.save format.html { redirect_to @black_friday, notice: 'Black friday was successfully created.' } format.json { render :show, status: :created, location: @black_friday } else ...
[ "def create\n @friday = Friday.new(friday_params)\n\n respond_to do |format|\n if @friday.save\n format.html { redirect_to @friday, notice: \"Friday was successfully created.\" }\n format.json { render :show, status: :created, location: @friday }\n else\n format.html { render :n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /black_fridays/1 PATCH/PUT /black_fridays/1.json
def update respond_to do |format| if @black_friday.update(black_friday_params) format.html { redirect_to @black_friday, notice: 'Black friday was successfully updated.' } format.json { render :show, status: :ok, location: @black_friday } else format.html { render :edit } ...
[ "def update\n respond_to do |format|\n if @friday.update(friday_params)\n format.html { redirect_to @friday, notice: \"Friday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friday }\n else\n format.html { render :edit, status: :unprocessable_ent...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /black_fridays/1 DELETE /black_fridays/1.json
def destroy @black_friday.destroy respond_to do |format| format.html { redirect_to black_fridays_url, notice: 'Black friday was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @holyday.destroy\n respond_to do |format|\n format.html { redirect_to holydays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hollyday = Hollyday.find(params[:id])\n @hollyday.destroy\n\n respond_to do |format|\n format.html { redirect_to ho...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
METHOD: update remaining guess count INPUT: N/A OUTPUT: integer of remaining guesses
def update_guess_count @guess_count > 0 ? @guess_count -= 1 : @guess_count end
[ "def increment_remaining_guess\n self.remaining_guesses += 1\n end", "def update_guess_count\n @guess_count += 1\n end", "def remaining_misses\n @guess_limit - incorrect_guesses.size\n end", "def decrement_remaining_guess\n self.remaining_guesses -= 1 \n end", "def wrong_guess_counter\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
METHOD: display word state INPUT: N/A OUTPUT: word state as string
def display_word_state @word_state.join(" ") end
[ "def print_state(word)\n \n spacing = Math.log10(word.length).to_i + 2 # there should be enough spaces so that the index fits under each letter of the word\n\n # print characters of word, with spaces\n print \"\\n\"\n word.each{|ch| print sprintf(\"%-#{spacing}.1s\", ch)}\n print \"\\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /corps GET /corps.json
def index @corps = Corp.all end
[ "def index\n @corals = Coral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corals }\n end\n end", "def index\n @ss_corals = SsCoral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ss_coral...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The message version is the 1B encoding of the `VERSION` above. It is encoded using Arraypack 'C' (8bit unsigned integer). The max value it can encode is 255 (`(2 8) 1`).
def msg_version; @msg_version ||= PackedHeader.new(1, 'C').encode(VERSION); end
[ "def pack_version(version)\n [version].pack(\"n\").force_encoding(Encoding::BINARY)\n end", "def message_version\n msg['_version']\n end", "def version\n bytes[0] >> 4\n end", "def binary_format_major_version; end", "def vvec( version_string )\n\t\t\treturn version_string.split('.').coll...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The message size is encoded using Arraypack 'N'. This encoding represents a 32bit (4 byte) unsigned integer. The max value that can be encoded in 4 bytes is 4,294,967,295 (`(2 32) 1`) or a size of ~4GB.
def msg_size; @msg_size ||= PackedHeader.new(4, 'N'); end
[ "def maximum_message_size\n\t\tsize = self.read( 'msgsize' )\n\t\treturn size ? size.split( ':' ).first.to_i : 0\n\tend", "def get_max_packed_length()\n (@prefixer.get_packed_length) + (@interpreter.get_packed_length(@length))\n end", "def max_message_size\n config[MAX_MESSAGE_BYTES]\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
THe message body is encoded using BSON.
def msg_body; @msg_body ||= BsonBody.new; end
[ "def client_empty_message\n BSON::Binary.new('')\n end", "def client_final_message\n BSON::Binary.new(\"#{without_proof},p=#{client_final}\")\n end", "def client_empty_message\n BSON::Binary.new('')\n end", "def client_final_message\n BSON::Binary.new(\"#{wit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin isaacs = TomcatUtility::TomcatDeploymentsCache.instance.get_isaac_deployments isaacs.first.tomcat.name isaacs.first.get_db_uuid isaacs.first.get_name isaacs.first.komets.first.get_name isaacs.first.komets.first.get_isaac_db_uuid will match with isaacs.first.get_db_uuid include TomcatUtility TomcatDeploymentsCach...
def get_indifferent_cached_deployments HashWithIndifferentAccess.new get_cached_deployments end
[ "def last_deployed_at(request, component_id)\n application_component = []\n application_environment = []\n request.apps.each do |app|\n application_component << ApplicationComponent.find_by_app_id_and_component_id(app.id, component_id)\n application_environment << ApplicationEnvironment.find_by_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
No edit , update or destroy on invite GET /invites/1/edit
def edit @invite = Invite.find(params[:id]) end
[ "def edit\n @invitation = Invitation.find(params[:id])\n @address = @invitation.address\n @address = Address.new(:kind => 'regular') if @address.nil? \n @email_addresses = @invitation.invited_non_members.collect { |nm| nm.email }\n @member_ids = @invitation.invited_members.collect{ |m| m.id.to_s }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /invites/1 PUT /invites/1.json
def update @invite = Invite.find(params[:id]) respond_to do |format| if @invite.update_attributes(params[:invite]) format.html { redirect_to @invite, notice: (t 'invite.update') } format.json { head :no_content } else format.html { render action: "edit" } format.json...
[ "def update\n invite = current_user.received_invites.find(params[:id])\n raise PermissionViolation unless current_user.updatable_by?(current_user)\n \n case params[:status].downcase\n when 'accepted' then invite.accept!\n when 'ignored' then invite.ignore!\n end\n \n respond_to do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a card, insert it on the bottom your deck
def add_card(card) @deck.add(card, :back) end
[ "def add_to_bottom(the_card)\n\t\t@cards.insert(0, the_card)\n\tend", "def add_bottom (card)\n @cards.unshift(card);\n end", "def add_card_to_bottom(card)\n unless self.id.nil? or (card.deck_id == self.id and card.card_order == 1)\n # Decrese the orders for the cards above in the old deck\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
You will need to play the entire game in this method using the WarAPI
def play_game # WarAPI.play_turn() end
[ "def play\n board_setup\n gameplay_setup\n end", "def play\n\t\tgame_loop\n\tend", "def start\n GAME.play\n render_all\n end", "def play\n #filled this in\n until game_over?\n do_battle\n end\n end", "def war\n declare_war\n # each player puts one card face d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
bomb in the 2D gridlike field in front of you. Write a function mineLocation/MineLocation that accepts a 2D array, and returns the location of the mine. The mine is represented as the integer 1 in the 2D array. Areas in the 2D array that are not the mine will be represented as 0s. The location returned should be an arr...
def mineLocation field coords = [] field.each_index do | i | field[i].each_index do | j | if field[i][j] == 1 coords << i coords << j end end end coords end
[ "def contains_mine?(row, col)\n if mine_locations.include?([row, col])\n true\n else\n false\n end\n end", "def mineLocation(field)\n row = 0\n column = 0\n field.each_with_index do |array, index|\n row = index if array.include?(1)\n end\n\n field[row].each_with_index do |num, index|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get PgVersion that is released at the given date. Return nil if not have.
def get_released_version(date) @minor_versions.each do |pv| if pv.release_date == date then return pv end end return nil end
[ "def version_for_date(date)\n # The release month ends at the 22nd, so for any date after that we want\n # the version for the month _after_ it; not the current month. Take this\n # schedule for example:\n #\n # | Month | Version |\n # |:---------|:--------|\n # |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Already release note file exists?
def exist?() return File.exist?(@r_note_filepath) end
[ "def checkReleaseNotes(iReleaseDir, iReleaseInfo)\n assert(File.exists?(\"#{iReleaseDir}/Documentation/ReleaseNote.html\"))\n assert(File.exists?(\"#{iReleaseDir}/Documentation/ReleaseNote.txt\"))\n end", "def exist?\n File.exist? @repo.changelog_path\n end", "def already_stored?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Save release note html file into ReleaseNoteDir
def save_release_note() puts "Saving the release note of " + @version + " ..." r_note = Nokogiri::HTML(open(@release_note_url)) File.open(@r_note_filepath, "w") do |f| f.puts(r_note) end end
[ "def write_html(html)\n File.open(\"assignment02-output.html\", \"w\") do |file|\n file.write html\n end\n end", "def generateReleaseNote_TXT\r\n rSuccess = true\r\n\r\n logOp('Generating release note in TXT format') do\r\n lStrWhatsNew = ''\r\n if (@ReleaseComment != nil)\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=============================================================================== Helper and utility functions for managing quests =============================================================================== Helper function for activating quests
def activateQuest(quest,color=colorQuest(nil),story=false) return if !$PokemonGlobal $PokemonGlobal.quests.activateQuest(quest,color,story) end
[ "def activate(name)\n $db.edit(:quests, @quest_id[name], {:status => :active})\n @gui.update\n end", "def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(diff...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function for marking quests as failed
def failQuest(quest,color=nil,story=false) return if !$PokemonGlobal $PokemonGlobal.quests.failQuest(quest,color,story) end
[ "def failed(name)\n $db.edit(:quests, @quest_id[name], {:status => :failed})\n @gui.update\n end", "def failed(why)\n @failed_reasons << why\n end", "def failed?(quest_id)\n return !@failed_quests.fetch(quest_id, nil).nil?\n end", "def mark_failure\n self.failure_occurred = true\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function for advancing quests to given stage
def advanceQuestToStage(quest,stageNum,color=nil,story=false) return if !$PokemonGlobal $PokemonGlobal.quests.advanceQuestToStage(quest,stageNum,color,story) end
[ "def next_stage\n\t\t\tif (stage == :river)\n\t\t\t\tself.current_player = nil\n\t\t\t\thand_finished\n\t\t\telse\n\t\t\t\tself.stage_num = self.stage_num + 1\n\t\t\t\tself.current_bet = 0\n\t\t\t\tself.players.each do |player|\n\t\t\t\t\tplayer.put_in_this_round = 0\n\t\t\t\t\tplayer.last_action = nil\n\t\t\t\t\tp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get symbolic names of failed quests Unused
def getFailedQuests failed = [] $PokemonGlobal.quests.failed_quests.each do |s| failed.push(s.id) end return failed end
[ "def unresolved\n list = Hash.new{ |h,k| h[k] = [] }\n @failures.each do |name, number|\n requirements(name, number).each do |rname, rnumber|\n list[[name,number]] << [rname, rnumber] if possibilities(rname, rnumber.to_s).empty?\n end\n end\n list\n end", "def failing...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get name of quest giver
def getQuestGiver(quest) return "#{QuestModule.const_get(quest)[:QuestGiver]}" end
[ "def name(quest_id = Class)\n return super() if quest_id == Class\n\n return nil.to_s unless id_valid?(quest_id)\n return text_get(45, quest_id)\n end", "def gym_name\n completed_problems.first.gym.name.to_s\n end", "def current_quest(player_name)\n return lookup(player_name).cu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get array of quest stages
def getQuestStages(quest) arr = [] for key in QuestModule.const_get(quest).keys arr.push(key) if key.to_s.include?("Stage") end return arr end
[ "def stages\n return @stages\n end", "def stages\n stage_spec_map.keys.map{|k| stage_named(k)}\n end", "def stages\n transform_to(:stage, get_request(\"stages\")['stages'])\n end", "def evolutions\n\t\tevolutions = []\n\t\tevolutions.push(self.stage1, self.stage2,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get overall quest description
def getQuestDescription(quest) return "#{QuestModule.const_get(quest)[:QuestDescription]}" end
[ "def descr(quest_id)\n return nil.to_s unless id_valid?(quest_id)\n return text_get(46, quest_id)\n end", "def description\n return text_get(7, @id || 0) # GameData::Skill.descr(@id)\n end", "def main_description\n other_text(1).try(:text)\n end", "def description\n\t # if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get maximum number of tasks for quest
def getMaxStagesForQuest(quest) quests = getQuestStages(quest) return quests.length end
[ "def max_tasks\n @max_tasks\n end", "def max_tasks\n @max_tasks\n end", "def completed_quest_number; completed_quests.size; end", "def get_task_count\n variables.has_key?(:task_count) ? variables[:task_count] : 14\n end", "def tasks_total_count\n tasks.length\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=============================================================================== Class that contains utility methods to return quest properties =============================================================================== Utility function to check whether the player current has any quests
def hasAnyQuests? if $PokemonGlobal.quests.active_quests.length >0 || $PokemonGlobal.quests.completed_quests.length >0 || $PokemonGlobal.quests.failed_quests.length >0 return true end return false end
[ "def has_quests?\r\n quest_count > 0\r\n end", "def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the ques...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Visits a static page
def visit_static_page visiting = STATIC_LOCATIONS[Kernel.rand(STATIC_LOCATIONS.size)] puts "Competitor #{@id} is visiting #{visiting}" @browser.location = @base_url + visiting raise "Visiting #{visiting} led to an error" unless @browser.is200 end
[ "def page_from_static_file(static_file); end", "def accessibility_statement\n # renders static page\n end", "def set_static_page\n @static_page = StaticPage.find_by(url: params[:name])\n render file: \"#{Rails.root}/public/404\", status: 404 unless @static_page\n end", "def landing_page\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
takes current_page and maximum to produce pagination array
def getPaginationArray(current_page, maximum, window = WINDOW, minimum = 1) return((minimum+window<current_page ? minimum.upto(window).collect : minimum.upto(current_page+window).collect) + (current_page-window > minimum+window ? [".."] : []) + (current_page>minimum+window ? (current_page-window > minimum+window ? ...
[ "def pagination(total,size) \n page_count = total.length/size + 1 # count total page\n paged_array = Array.new\n for i in 0..(page_count-1)\n paged_array.push(total[i*size..(i+1)*size-1])\n end\n paged_array\n end", "def pagination_range\n case JSONAPI.configuration.default_paginator...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Includes a partial. The path is relative to the Selenium tests root. The starting _ and the file extension don't have to be specified. include test/selenium/_partial. include_partial 'partial' include test/selenium/suite/_partial. include_partial 'suite/partial' include test/selenium/suite/_partial. and provide local a...
def include_partial path, local_assigns = {} partial = @view.render :partial => path, :locals => local_assigns @output << partial end
[ "def include(partial, context)\n template = Template.new(sprintf('_%s.tmpl', partial))\n template.render(context)\n end", "def include_partial\n #append_file \"app/views/pages/show.html.haml\", \"\\n\\n= render :partial => 'shared/disqus'\"\n append_file \"app/views/#{view_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a selection to the set of selected options in a multiselect element using an option locator. See the select command for more information about option locators.
def add_selection locator, option_locator command 'addSelection', locator, option_locator end
[ "def add_selection(locator,optionLocator)\n do_command(\"addSelection\", [locator,optionLocator,])\n end", "def set_selected(sel)\n @column.numItems.times do |i|\n if sel.include?(i)\n @column.selectItem(i)\n else\n @column.deselectItem(i)\n end\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Waits for a popup window to appear and load up. The +timeout+ is specified in milliseconds.
def wait_for_popup window_id, timeout command 'waitForPopUp', window_id||'null', timeout end
[ "def wait_for_pop_up(windowID,timeout)\n do_command(\"waitForPopUp\", [windowID,timeout,])\n end", "def wait_for_popup(window_id, timeout_in_seconds=nil)\n remote_control_command \"waitForPopUp\",\n [window_id, actual_timeout_in_milliseconds(timeout_in_seconds) ,]\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simulates the user pressing the alt key and hold it down until do_alt_up() is called or a new page is loaded.
def alt_key_down command 'altKeyDown' end
[ "def alt_key_up()\n do_command(\"altKeyUp\", [])\n end", "def alt_key_down()\n do_command(\"altKeyDown\", [])\n end", "def alt_key_up\r\n command 'altKeyUp'\r\n end", "def alt_button_pressed?\n return Gosu.button_down?(Gosu::KB_LEFT_ALT) || Gosu.button_down?(Go...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simulates the user releasing the alt key.
def alt_key_up command 'altKeyUp' end
[ "def alt_key_up()\n do_command(\"altKeyUp\", [])\n end", "def alt_key_down()\n do_command(\"altKeyDown\", [])\n end", "def alt_key_down\r\n command 'altKeyDown'\r\n end", "def key_released( event )\n @keys -= [event.key]\n end", "def alt_button_pressed?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simulates the user releasing the control key.
def control_key_up command 'controlKeyUp' end
[ "def control_key_up()\n do_command(\"controlKeyUp\", [])\n end", "def control_key_down()\n do_command(\"controlKeyDown\", [])\n end", "def key_released( event )\n @keys -= [event.key]\n end", "def release(key)\n assert_modifier key\n\n @bridge.sendKeysToAc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a named cookie with specified path.
def delete_cookie name, path command 'deleteCookie', name, path end
[ "def delete_cookie(name); end", "def delete(name)\n @control.delete_cookie(name)\n end", "def delete_cookie(name)\n @bridge.delete_cookie name\n end", "def delete_cookie(cookie)\n run_command :delete, :cookie, {\n :cookie => cookie\n }, cookie\n end", "def del...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
def meta_key_down command 'metaKeyDown' end
[ "def meta_key_down()\n do_command(\"metaKeyDown\", [])\n end", "def process_pageup\r\n Sound.play_cursor\r\n Input.update\r\n deactivate\r\n call_handler(:pageup)\r\n end", "def process_pageup\n Sound.play_cursor\n Input.update\n deactivate\n call_handler(:pageup)\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Opens a popup window (if a window with that ID isn't already open). After opening the window, you'll need to select it using the select_window command. This command can also be a useful workaround for bug SEL339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or bef...
def open_window url, window_id command 'openWindow', url, window_id end
[ "def open_window(url,windowID)\n do_command(\"openWindow\", [url,windowID,])\n end", "def window_open\n execute(\"window-open\")\n end", "def open_window_with_click(win_name)\n wait_start\n click\n wait_for_window_shown(win_name)\n end", "def open_window_with_double_cli...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Selects a frame within the current window. (You may invoke this command multiple times to select nested frames.) To select the parent frame, use "relative=parent" as a locator; to select the top frame, use "relative=top". You may also use a DOM expression to identify the frame you want directly, like this: dom=frames["...
def select_frame locator command 'selectFrame', locator end
[ "def select_frame(locator)\n do_command(\"selectFrame\", [locator,])\n end", "def inside_iframe(frame)\n # massive hack but the only way to reliably wait\n # for the frame\n sleep 2\n browser.select_frame(frame)\n yield\n browser.select_frame(\"relative=parent\")\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Moves the text cursor to the specified position in the given input element or textarea. This method will fail if the specified element isn't an input element or textarea.
def set_cursor_position locator, position command 'setCursorPosition', locator, position end
[ "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def set_cursor_position(locator,position)\n do_command(\"setCursorPosition\", [locator,position,])\n end", "def move_to(locator, offset = {})\n x = offset.fetch(:x, 0)\n y = offset.fetch(:y, 0)\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10). Setting this value to 0 means that we'll send a "mousemove" event to every single pixel in between the start location and the end location; that can be very slow, and may cause some browsers to force the JavaScript to ti...
def set_mouse_speed pixels command 'setMouseSpeed', pixels end
[ "def set_mouse_speed(pixels)\n do_command(\"setMouseSpeed\", [pixels,])\n end", "def on_mouse_move(new_point)\n end", "def drag(startx,starty,endx,endy,steps = 10, duration=500) \n\t\treturn if !checkConn\n\t\tsend_command(\"DRAG #{startx}, #{starty}, #{endx}, #{endy}, #{steps}, #{duration}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
def shift_key_down command 'shiftKeyDown' end
[ "def shift_key_up()\n do_command(\"shiftKeyUp\", [])\n end", "def shift_key_down()\n do_command(\"shiftKeyDown\", [])\n end", "def shift_key_up\r\n command 'shiftKeyUp'\r\n end", "def hit_shift_tab\n @driver.action.key_down(:shift).send_keys(:tab).key_up(:shift).perf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Release the shift key.
def shift_key_up command 'shiftKeyUp' end
[ "def shift_key_up()\n do_command(\"shiftKeyUp\", [])\n end", "def shift_key_down()\n do_command(\"shiftKeyDown\", [])\n end", "def shift_key_down\r\n command 'shiftKeyDown'\r\n end", "def release(key)\n assert_modifier key\n\n @bridge.sendKeysToActiveEleme...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This command is a synonym for store_expression.
def store expression, variable_name command 'store', expression, variable_name end
[ "def expression=(value)\n @expression = value\n end", "def expression_eval(expr)\n\t\t@ee.expand_expr(expr)\n\tend", "def add_expression(entity_id, value, expression)\n return @client.post(\"/entities/#{entity_id}/values/#{value}/e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes a message to the status bar and adds a note to the browserside log. +context+ is the message sent to the browser. +log_level_threshold+ can be +nil+, :debug, :info, :warn or :error.
def set_context context, log_level_threshold = nil if log_level_threshold command 'setContext', context, log_level_threshold.to_s else command 'setContext', context end end
[ "def reportContext( message )\n threading = NSThread.mainThread? ? \"on MAIN thread\" : \"on background thread\"\n if current == main\n NSLog \"MAIN context #{threading} :#{message}\"\n elsif current == root\n NSLog \"ROOT context #{threading} :#{message}\"\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Waits for a new page to load. You can use this command instead of the +and_wait+ suffixes, +click_and_wait+, +select_and_wait+, +type_and_wait+ etc. (which are only available in the JS API). Selenium constantly keeps track of new pages loading, and sets a +newPageLoaded+ flag when it first notices a page load. Running ...
def wait_for_page_to_load timeout command 'waitForPageToLoad', timeout end
[ "def wait_for_page_to_load(timeout=@timeout)\n do_command(\"waitForPageToLoad\", [timeout,])\n end", "def wait_for_page(timeout_in_seconds=nil)\n remote_control_command \"waitForPageToLoad\",\n [actual_timeout_in_milliseconds(timeout_in_seconds),]\n end", "def wait_for_p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check connection to Selenium RC
def check_connection one_wait = 5 max_wait = 15 request = Net::HTTP::Get.new('/selenium-server/') wait = 0; while (wait < max_wait) begin response = Net::HTTP.start(@host, @port) {|http| http.request(request) } break if ...
[ "def check_connection\n one_wait = 5\n max_wait = 15\n request = Net::HTTP::Get.new('/selenium-server/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@CONFIG['selenium_host'], @CONFIG['selenium_port']) {|http|\n http.reque...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
wait for page to load and verify text
def wait_for_page_and_verify_text(text) @selenium.wait_for_page_to_load(120000) check_page_and_verify_text(text) end
[ "def check_page_and_verify_text(text)\n check_page(@selenium.get_body_text())\n verify_text(text)\n end", "def check_page_and_verify_text(text)\n #check_page(@selenium.find_element(:id, \"body\").text)\n verify_text(text)\n end", "def wait_page_load(criteria,value,expected_element_text,s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check the page for any abnormalities and verify text
def check_page_and_verify_text(text) #check_page(@selenium.find_element(:id, "body").text) verify_text(text) end
[ "def check_page_and_verify_text(text)\n check_page(@selenium.get_body_text())\n verify_text(text)\n end", "def blury_verify_text(text)\n page = get_body_text\n check_page(page)\n p(\"-- searching for text using pattern matching, text: {#{text}}\")\n if !/#{text}/.match(page)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the roles associated with this user
def roles client.user_roles(id) end
[ "def user_roles user\n cache.user_roles user\n end", "def roles\r\n @roles ||= user_roles.map(&:name)\r\n end", "def roles_for user\n roles.where(user: user)\n end", "def roles\n return @roles\n end", "def roles\n users.map { |item| item['roles'] }....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
end initialize randomly determine if this room will have an enemy
def assign_enemy @has_enemy = rand(1..2)==1 ? true : false #need an enemy value for the room. end
[ "def enemy_spawned\n @enemy_chance > rand(100)\n end", "def resetEnemyCounter\n\t\t@enemyCounter = 0 + rand(2)\n\tend", "def generateEnemyOnMap(position_x = rand(map_width), position_y = rand(map_height))\n enemy_list.push(Enemy.new(position_x, position_y))\n end", "def random_target_enemy_hp0\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }