query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
counts tickets using ticket info array
def count_tickets tickets = self.tickets total_tickets = tickets.count return total_tickets end
[ "def tag_count( tagged_tickets )\n\t\ttag_count_array = []\n\t\tticket_array = tagged_tickets\n\t\tticket_array.each do | ticket |\n\t\t\t count_exists = tag_count_exists?( ticket[ 'tag' ], tag_count_array )\n\t\t\tif count_exists[ 'exists' ]\n\t\t\t\ttag_count_array[ count_exists[ 'matched_index' ] ][ 'count' ] +=...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
finds films a customer has tickets for
def find_films_for_each_customer() sql = "SELECT films.* FROM films INNER JOIN tickets ON tickets.film_id = films.id WHERE customer_id = $1" values = [@id] films = SqlRunner.run(sql, values) result = films.map {|film| Film.new(film)} return result end
[ "def films_for_customer()\n sql = \"SELECT films.* FROM films\n INNER JOIN tickets ON films.id = tickets.film_id\n WHERE customer_id = $1\"\n values = [@id]\n film_data = SqlRunner.run(sql, values)\n return Film.map_items(film_data)\n end", "def films()\n sql = \"SELECT films.* FROM films IN...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this finds the prices for films for a given customer and deducts the total from the customers funds
def remaining_funds() films = self.find_films_for_each_customer() film_fees = films.map{|film| film.price} combined_fees = film_fees.sum return @funds - combined_fees end
[ "def remaining_funds()\n films = self.films()\n film_prices = films.map{ |film| film.price.to_i}\n combined_prices = film_prices.sum\n @funds -= combined_prices\n update\n end", "def decrease_funds()\n film_price = films()\n ticket_price = film_price.sum{|film| film.price}\n return @funds...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /distbutors GET /distbutors.json
def index @distbutors = Distbutor.page(params[:page]) end
[ "def index\n @distritos = Distrito.all\n\n render json: @distritos\n end", "def index\n @dors = Dor.all\n end", "def index\n @doktors = Doktor.all\n end", "def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fill billing address on payment tab
def fill_billing_address(billing_address) add_credit_card_form.bl_street_addr_input.set billing_address[:street] add_credit_card_form.bl_city_input.set billing_address[:city] # display state option if page.has_css?('.stateSelect', wait: TimeOut::WAIT_SMALL_CONST) page.execute_script("$('#stateSel...
[ "def fill_billing_address(billing_address)\n credit_card_add_form.bl_street_addr_input.set billing_address[:street]\n credit_card_add_form.bl_city_input.set billing_address[:city]\n\n # display state option\n page.execute_script(\"$('#stateSelect').css('display','block')\")\n credit_card_add_form.bl_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add credit card on payment tab Return review tab
def add_credit_card(credit_card, billing_address = nil) add_credit_card_form.card_number_input.set credit_card[:card_number] add_credit_card_form.name_on_card_input.set credit_card[:card_name] # display expiration month option page.execute_script("$('#vin_PaymentMethod_creditCard_expirationDate_Month')...
[ "def add_credit_card(credit_card, billing_address = nil)\n credit_card_add_form.card_number_input.set credit_card[:card_number]\n credit_card_add_form.name_on_card_input.set credit_card[:card_name]\n\n # display expiration month option\n page.execute_script(\"$('#vin_PaymentMethod_creditCard_expirationD...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Order jobs by: their stage number their allow_failure status their original order
def apply jobs.sort_by.with_index { |job, ix| order(job, ix) } end
[ "def sort_by_job_status\n <<~SQL\n CASE status\n WHEN 'waiting_for_resource' THEN 0\n ELSE 1\n END ASC\n SQL\n end", "def order_jobs_by_dependings\n @jobs.each do |job|\n @ordered_jobs += reorder(job).reverse! if !@ordered_jobs.include?(job.name)\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wraps content words in individual spans.
def spanitize(content) content.split(" ").map { |s| "<span>#{s}</span>" }.join(" ") end
[ "def wrap_in_spans(**options)\n safe_join(options.fetch(:value, []).map { |v| content_tag(:span, html_escape(v)) })\n end", "def wrapText; end", "def wrap( content )\n content\n end", "def content_sentence_split_helper(contents, ele_name, counter)\n to_return = []\n contents = escape_links(c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
READ CSV DATA Method to get the data from a csv in hash map
def get_csv_data(csv_data) csv_file = nil #Get the path and name of the CSV file if csv_data.to_s.include? '.csv' csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}") elsif ( csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}.c...
[ "def parse_csv_for_data(csv, data_header:, alpha_num_header:)\n data_idx = csv.first.index(data_header)\n loc_idx = csv.first.index(alpha_num_header)\n data_map = []\n csv.drop(1).each do |row|\n alpha_loc = row[loc_idx]\n data = row[data_idx]\n rc_loc = convert_location_to_coordinates(al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
FILTER CSV DATA (HASH MAP FILTER) Allows you to filter a hash map from csv data
def get_data_by_filters(filters, csv) filters_a = filters.to_s.split(',') csv_tmp = Array.new csv_tmp = csv for i in 0..(filters_a.size - 1) filter = filters_a[i].to_s.downcase.strip filter_data = get_filter_data filter #The array is cleaned data_filtered = Array.new csv_tm...
[ "def prefilter_csv_data(raw_csv_data)\n # De-dup emails absolutely\n csv_data = raw_csv_data.uniq{|row| row[:email]}\n\n # Remove data with duplicate names scoped in company and address (parameterized)\n #csv_data.uniq{|row| \"#{row[:first_name]} #{row[:last_name]} #{row[:company]} #{row[:addres...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs a job and updates the +last_run_at+ field.
def run! PeriodicJob.log_error "Executing job id #{self.id}, #{self.to_s}..." begin self.last_run_at = Time.now self.next_run_at = nil self.save command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s) puts command eval(command) self.last_r...
[ "def run!\r\n TaskServerLogger.instance.info \"Executing job id #{self.id}, #{self.to_s}...\"\r\n begin\r\n eval(self.job)\r\n self.last_run_result = \"OK\"\r\n TaskServerLogger.instance.info \"Job completed successfully\"\r\n rescue Exception\r\n err_string = \"'#{self.job}' could not ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /world_instances POST /world_instances.json
def create world_name = params["name"] superclass_uri = params["type-parent"] container_uri = params["location-parent"] description = params["description"] if params.has_key?(:options) options = {protected: false, locked: false} options[:protected] = true if (params["options"].include?("...
[ "def create_instance(body)\n headers = default_headers\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n JSON.parse(post('/instances', urlencode(body), headers))['instances']\n end", "def create_in_world(client, world: required(\"world\"), options: {}, **data)\n\n self.new(parse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /world_instances/1 PATCH/PUT /world_instances/1.json
def update respond_to do |format| if @world_instance.update(world_instance_params) format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' } format.json { render :show, status: :ok, location: @world_instance } else format.html { render :edit ...
[ "def update_world\n # pattern = Pattern.find_by(id: params[:id])\n @world = World.find_by(id: params[:world_id]) if params[:world_id].present?\n @world = World.create if @world.blank?\n\n @world.update_pattern_cells(params[:id])\n @world.reload\n render json: world_points\n end", "def update\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /world_instances/1 DELETE /world_instances/1.json
def destroy @world_instance.destroy respond_to do |format| format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @world = World.find(params[:id])\n @world.destroy\n\n respond_to do |format|\n format.html { redirect_to worlds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @world.destroy\n respond_to do |format|\n format.html { redirect_to worlds_url }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Capacity is the desired number of samples a buffer will hold. This can be user dictated via config if a feature wants. This value will be forcibly capped by the max_capacity
def capacity raise NotImplementedError.new("TransactionSampleBufferBase subclasses must provide a capacity override") end
[ "def capacity\n raise NotImplementedError.new('TransactionSampleBuffer subclasses must provide a capacity override')\n end", "def max_capacity\n CAPACITY\n end", "def capacity\n @capacity ||= DEFAULT_CAPACITY\n end", "def input_capacity\n typical_input_capacity\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Our default truncation strategy is to keep max_capacity worth of the longest samples. Override this method for alternate behavior.
def truncate_samples @samples.sort!{|a,b| a.duration <=> b.duration} @samples.slice!(0..-(max_capacity + 1)) end
[ "def truncate_samples\n @samples.sort! { |a, b| a.duration <=> b.duration }\n @samples.slice!(0..-(max_capacity + 1))\n end", "def truncate_samples\n @samples = @samples.last(capacity)\n end", "def truncate(max)\n resize([max, self.length].min)\n end", "def red...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If a buffer needs to modify an added sample, override this method. Bounds checking, allowing samples and truncation belongs elsewhere.
def add_sample(sample) @samples << sample end
[ "def push_sample sample\n @buffer.push sample\n end", "def truncate_samples\n @samples = @samples.last(capacity)\n end", "def before_append!\n @bufs << new_buffer\n end", "def prepare_buffer(iIdxStartSample, iIdxEndSample, iIdxStartSamplePrefetch = iIdxStartSample, iIdxEndSamplePre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Take a DepositItemInput and make a UCI record out of it. Note that if you pass existing UCI data in, it will be retained if Elements doesn't override it. NOTE: UCI in this context means "UC Ingest" format, the internal metadata format for eScholarship.
def uciFromInput(input, ark) uci = Nokogiri::XML("<uci:record xmlns:uci='http://www.cdlib.org/ucingest'/>").root # Top-level attributes uci[:id] = ark.sub(%r{ark:/?13030/}, '') uci[:dateStamp] = DateTime.now.iso8601 uci[:peerReview] = input['isPeerReviewed'] ? "yes" : "no" uci[:state] = 'new' uci[:state...
[ "def uciFromInput(input)\n\n uci = Nokogiri::XML(\"<uci:record xmlns:uci='http://www.cdlib.org/ucingest'/>\").root\n\n # Top-level attributes\n ark = input[:id]\n uci[:id] = ark.sub(%r{ark:/?13030/}, '')\n uci[:dateStamp] = DateTime.now.iso8601\n uci[:peerReview] = input['isPeerReviewed'] ? \"yes\" : \"no\"\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> [3, 5, 7] REVERSE RANGE CHALLENGE Write a method reverse_range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max in reverse order. The min and max should be excluded from the array
def reverse_range(min, max) # Define method i = max - 1 # Because we are trying to reverse the order of array we have to start with the max value; minus one because it does not include min or max new_array = [] # Create an empty array to shovel values into while i > min # We have to start from the max va...
[ "def reverse_range(min, max)\n reverse_arr = []\n\n i = max -1\n while i > min\n reverse_arr << i\n i -= 1\n end\n return reverse_arr\nend", "def reverse_range(min, max)\n\trange = []\n \n\ti = max - 1\n\twhile i > min\n\t\trange << i\n\t\ti -= 1\n end\n \n\treturn range\nend", "def reverse(arr, r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is this a RHELcompatible OS with a minimum major version number of `version`
def el_min_version?(version) self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version) end
[ "def centos_package_major_release(version)\n m = /\\.(el|ael|centos|rhel)(\\d)/i.match(version)\n return 0 if m.nil?\n m[2].to_i\n end", "def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is this a RHELcompatible OS with a maximum major version number of `version`
def el_max_version?(version) self.rhel_family? && FB::Version.new(self['platform_version']) <= self._canonical_version(version) end
[ "def centos_package_major_release(version)\n m = /\\.(el|ael|centos|rhel)(\\d)/i.match(version)\n return 0 if m.nil?\n m[2].to_i\n end", "def el_min_version?(version)\n self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes one or more AWS account IDs as strings and return true if this node is in any of those accounts.
def in_aws_account?(*accts) return false if self.quiescent? return false unless self['ec2'] accts.flatten! accts.include?(self['ec2']['account_id']) end
[ "def users_include?(*user_ids)\n user_ids.map { |user_id| @users.include?(user_id) }.all?\n end", "def account_exists?(account_id)\n @accounts.member?(account_id)\n end", "def in?(*list)\n list.any? {|item| self === item}\n end", "def contains?(account)\n rpc(:wallet_contains, account...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is this device a SSD? If it's not rotational, then it's SSD expects a short device name, e.g. 'sda', not '/dev/sda', not '/dev/sda3'
def device_ssd?(device) unless node['block_device'][device] fail "fb_helpers: Device '#{device}' passed to node.device_ssd? " + "doesn't appear to be a block device!" end node['block_device'][device]['rotational'] == '0' end
[ "def mounted?(device_name_or_path)\n device_list = `cut -d' ' -f1 /etc/mtab`.split(\"\\n\")\n # did they pass in e.g. /dev/sda1 ?\n if File.blockdev?(device_name_or_path)\n device_list.include? device_name_or_path\n else\n candidate = File.join('/dev', device_name_or_pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
On Linux and Mac, as of Chef 13, FS and FS2 were identical and in Chef 14, FS2 is dropped. For FreeBSD and other platforms, they become identical in late 15 and FS2 is dropped in late 16 So we always try 2 and fail back to 1 (if 2 isn't around, then 1 is the new format) This will return modern filesystem data, where it...
def filesystem_data self['filesystem2'] || self['filesystem'] end
[ "def filesystem_type(host)\n case host['platform']\n when %r{aix}\n 'jfs2'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n 'ext3'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine a standard filesystem table type for #{host...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the versionrelease of an rpm installed, or nil if not present
def rpm_version(name) if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9? # returns epoch.version v = Chef::Provider::Package::Dnf::PythonHelper.instance. package_query(:whatinstalled, name).version unless v.nil? v.sp...
[ "def get_released_version(date)\n @minor_versions.each do |pv|\n if pv.release_date == date then\n return pv\n end\n end\n return nil\n end", "def installed_version\n sh = shell_out('rpm -q --info chefdk')\n return false if sh.exitstatus.nonzero?\n ver = sh.stdout.m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Safely dig through the node's attributes based on the specified `path`, with the option to provide a default value in the event the key does not exist.
def attr_lookup(path, delim: '/', default: nil) return default if path.nil? node_path = path.split(delim) # implicit-begin is a function of ruby2.5 and later, but we still # support 2.4, so.... until then node_path.inject(self) do |location, key| if key.respond_to?(:to_s) && locat...
[ "def nodeOrDefaultAttr(*keys)\n valOrDefault(node.dig(*keys), node.default.dig(*keys))\n end", "def find_attribute_value(tree, path, default)\n attribute = tree[path.shift]\n if attribute.is_a?(Hash)\n find_attribute_value(attribute, path, default)\n else\n attribute.nil? ? de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We can change interface configs if nw_changes_allowed? or we are operating on a DSR VIP
def interface_change_allowed?(interface) method = node['fb_helpers']['interface_change_allowed_method'] if method return method.call(node, interface) else return self.nw_changes_allowed? || ['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) || interface.match(Rege...
[ "def network_interface_configs\n get_network_interface_configs\n end", "def on_network_change(network)\n true\n end", "def update\n if user_entered_valid_ip( @switch_initial_config )\n @switch_initial_config.update(switch_initial_config_params)\n respond_to do |format|\n if @switch_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives total lesson time in hours
def lesson_length seconds = self.end_at - self.start_at seconds / 3600.0 end
[ "def totalHeures\n return totalMinutes / 60.0\n end", "def hours\n self.to_i * 3_600\n end", "def total_hours\n ('%.02f' % ((ends_at - starts_at) / 1.hour)).to_f\n end", "def hours\n _nudge[0]\n end", "def total_time\n minutes_to_human_readable_time(entries.internal.sum(:duration) + expec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The position of the task in the board list determines its priority This method sets the position of the task in the list (acts_as_list gem) According to the index passed by the ajax call.
def set_position(index) first_item_position = board.tasks.by_status(self.status)[index].position insert_at(first_item_position) end
[ "def order\n episode_position = params[:episode_position]\n tasks = params[\"task_list_episode#{episode_position}\"]\n logger.info(tasks.inspect)\n tasks.each_with_index do |id, position| \n Task.find(id).update_attribute(:position, position + 1) \n end \n render :nothing => true\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /list_items GET /list_items.xml
def index @list = List.find(params[:list_id]) @list_items = @list.list_items.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @list_items } end end
[ "def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end", "def list_items(params = nil, headers = nil)\n get(\"/api/v2/items\", params, headers)\n end", "def list(item_key=nil, params={})\n url...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /list_items/1 GET /list_items/1.xml
def show @list = List.find(params[:list_id]) @list_item = @list.list_items.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @list_item } end end
[ "def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end", "def show\n @item = Item.get!(params[:id])\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Each subarray will have strings which are anagrams of each other Time Complexity: O(n) if you pretend line 12 is a simple mathematically based hashing function, probably O (n n log n) as for each string you have to sort the string to get a key for the hash. Space Complexity: O(n) worst case is one string to one key, wh...
def grouped_anagrams(strings) string_hash = {} strings.each do |string| key = string.split("").sort.join # probably an O(n log n) operation, I couldn't find an integer based hashing function i liked string_hash[key] ||= [] # trying this thing out string_hash[key] << string end return string_has...
[ "def anagrams(str, arr)\nend", "def anagrams(array)\n hash = Hash.new { |hash,key| hash[key] = [] }\n array.each do |word|\n hash[word.chars.sort] << word\n end\n hash.values.select { |anas| anas.size > 1 }\nend", "def anagrams(string, array)\nend", "def grouped_anagrams(strings)\n hash_ana = {}\n ou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: I want to say this is O(1) since the number of elements in a 3x3 grid you have to check is alway...
def valid_sudoku(table) sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {}, [1, 0] => {}, [1, 1] => {}, [1, 2] => {}, [2, 0] => {}, [2, 1] => {}, [2, 2] => {}} sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {}, 4 => {}, 5 => {}, 6 => {}, ...
[ "def valid_sudoku(table)\n # assume that the input must always be 9x9 table\n subgrid_hash = {}\n \n 9.times do |i|\n rows_hash = {}\n columns_hash = {}\n \n 9.times do |j|\n row_value = table[i][j]\n column_value = table[j][i]\n \n if row_value != \".\"\n return false if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /sales/1 DELETE /sales/1.json
def destroy @sale = Sale.find(params[:id]) @sale.destroy respond_to do |format| format.html { redirect_to sales_url } format.json { head :no_content } end end
[ "def destroy\n @d_sale = DSale.find(params[:id])\n @d_sale.destroy\n\n respond_to do |format|\n format.html { redirect_to d_sales_url }\n format.json { head :ok }\n end\n end", "def destroy\n @daily_sale = DailySale.find(params[:id])\n @daily_sale.destroy\n\n respond_to do |format|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields all the permutations of self into block.
def permute(&block) case size when 0 then yield [] when 1 then yield self when 2 yield self yield self.reverse else 0.upto(size-1) do |i| a = dup c = a.slice!(i) a.permute do |p| yield p.dup.unshift(c) end end end end
[ "def each_permutation\n # This is pretty ugly..\n a, p, i = self.clone, (0..self.size).to_a, 0\n while i < self.size\n p[i] -= 1\n (i % 2) == 1 ? j = p[i] : j = 0\n a.swap! i, j\n yield a\n i = 1\n while p[i].zero?\n p[i] = i\n i += 1\n end\n end\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tagging_select_tos GET /tagging_select_tos.json
def index @tagging_select_tos = TaggingSelectTo.all if @tagging_select_tos.empty? TaggingSelectTo.create(name: 'Sajjad-Murtaza-Testing-Taggable') end end
[ "def create\n @tagging_select_to = TaggingSelectTo.new(tagging_select_to_params)\n\n respond_to do |format|\n if @tagging_select_to.save\n format.html { redirect_to tagging_select_tos_path }\n format.json { render :show, status: :created, location: @tagging_select_to }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tagging_select_tos POST /tagging_select_tos.json
def create @tagging_select_to = TaggingSelectTo.new(tagging_select_to_params) respond_to do |format| if @tagging_select_to.save format.html { redirect_to tagging_select_tos_path } format.json { render :show, status: :created, location: @tagging_select_to } else format.htm...
[ "def index\n @tagging_select_tos = TaggingSelectTo.all\n if @tagging_select_tos.empty?\n TaggingSelectTo.create(name: 'Sajjad-Murtaza-Testing-Taggable')\n end\n end", "def destroy\n @tagging_select_to.destroy\n respond_to do |format|\n format.html { redirect_to tagging_select_tos_url, no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /tagging_select_tos/1 PATCH/PUT /tagging_select_tos/1.json
def update respond_to do |format| if @tagging_select_to.update(tagging_select_to_params) format.html { redirect_to @tagging_select_to, notice: 'Tagging select to was successfully updated.' } format.json { render :show, status: :ok, location: @tagging_select_to } else format.html ...
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @tag.update(tag_params)\n render json: @tag\n end", "def create\n @tagging_select_to = TaggingSelectTo.new(tagging_select_to_params)\n\n respond_to do |format|\n if @tagging_selec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tagging_select_tos/1 DELETE /tagging_select_tos/1.json
def destroy @tagging_select_to.destroy respond_to do |format| format.html { redirect_to tagging_select_tos_url, notice: 'Tagging select to was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @tagging.destroy\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tagging = Tagging.fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def greatest_factor(num) i = num 1 while i > 0 return i if num % i == 0 i = 1 end i end
def greatest_factor(num) (2...num).reverse_each { |i| return i if num % i == 0} end
[ "def largest_prime_factor(max = 600851475143)\n i = 2\n while i < max do\n while max % i == 0 do\n max = max/i\n end\n i += 1\n end\n max\nend", "def largest_prime_factor\n number = 600851475143\n n = 2\n while n < number\n if number % n == 0\n factor = number / ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This overrides default save_entity (defined in RegisterMethods) and adds the inferred jurisdiction_code, unless it is overridden in entity_info
def save_entity(entity_info) return if entity_info.blank? default_options = {:jurisdiction_code => inferred_jurisdiction_code} super(default_options.merge(entity_info)) end
[ "def save_entity(entity_info)\n return if entity_info.blank?\n\n default_options = { jurisdiction_code: inferred_jurisdiction_code }\n super(default_options.merge(entity_info))\n end", "def save_entity(entity)\n result = service.put(entity.path, entity)\n entity[:updatedAt] = result[:updat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
EOL: this method was previously also checking: || include_eager_select?(options, joined_tables)
def references_eager_loaded_tables?(options) joined_tables = joined_tables(options) include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables) end
[ "def use_eager_loading_sql?(options)# :nodoc:\n include_associations = merge_includes(scope(:find, :include), options[:include])\n return ((include_associations.any?) &&\n (options[:force_eager_load].is_a?(TrueClass) ||\n references_eager_loaded_tables?(options)))\n end", "def has...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this is special kind of method that is used in layout template. it gets correct partial for the layout depending on context.
def get_content_for_layout() get_partial(@type) # if @type == "home" # get_partial('home') # elsif @type == "page" # get_partial('page') # elsif @type == "article" # get_partial('article') # elsif @type == "category" # get_partial('category') # end end
[ "def render_partial(context, options, &block); end", "def get_specific_partial(item_type, partial, object)\n if File.exists?(RAILS_ROOT+'/app/views/'+object.class.to_s.downcase.pluralize.underscore+\"/_#{partial}.html.erb\")\n render :partial => \"#{object.class.to_s.downcase.pluralize.underscore}/#{parti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
define a keyword to skip the sheet upload"
def keyword_to_skip(keyword_name) kw = Keyword.find_by_name(keyword_name) end
[ "def skip_actions; end", "def skip_for_zip\n ! %w(application/zip application/x-zip).include?(doc_content_type)\n end", "def skip!\n @skip ||= true\n end", "def unkeyword(flag)\n return add_params(UNKEYWORD, flag)\n end", "def unexpected_keyword(keyword)\n rais...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def bitwise_and(num1, num2) puts "num1 = " + num1.to_s(2) puts "num2 = " + num2.to_s(2) puts "base 10 & = " + (num1 & num2).to_s(10) puts "base 2 & = " + (num1 & num2).to_s(2) end
def bitwise_and(num1, num2) bnum1 = num1.to_s(2) bnum2 = num2.to_s(2) band = (num1 & num2).to_s(2) puts "num1 = " + ( ' ' * bnum2.length ) + num1.to_s(2) puts "num2 = " + ( ' ' * bnum1.length ) + num2.to_s(2) puts "b2& = " + ( ' ' * ([bnum1.length, bnum2.length].max ) + band) # puts "base 1...
[ "def bitwise_and(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == b[index]\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend", "def process_bitwise_and(exp)\n process(exp[1]) & process(exp[2])\n end", "def PowersofTwo2(num)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the base of a path The 'base' here means the portion of the basename before the extension.
def base() sub_ext('').basename.to_s end
[ "def base_path(uri)\n matched = uri.match(PATH_BASE_REGEX)\n (matched && matched[1]) || '/'\n end", "def get_base(file)\n if file\n if Bee::Util::url?(file)\n return File.dirname(file)\n else\n return File.expand_path(File.dirname(file))\n end\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Override ActiveRecord::Core::ClassMethodscached_find_by_statement `.find_by` not use caching
def cached_find_by_statement(key, &block) ActiveRecord::StatementCache.create(connection, &block) end
[ "def cached_find_by_statement(key, &block)\n ActiveRecord::StatementCache.create(connection, &block)\n end", "def find_with_model_cacher(*args)\nlogger.debug \"CachedModel.find #{args.to_json}\"\n args[0] = args.first.to_i if args.first =~ /\\A\\d+\\Z/\n # Only handle simple find requests. If t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_oi_category_selection Description: This method does the functional testing of the oi_category_selection method from the OI Instruction Controller class
def test_io_category_selection categories = ['Board Preparation', 'Placement', 'Routing', 'Fabrication Drawing', 'Nomenclature', 'Assembly Drawing', 'Other'] # Try accessing from an account that is not a PCB Designer and # verify th...
[ "def oi_category_selection\n\n @design = Design.find(params[:design_id])\n @oi_category_list = OiCategory.list\n\n end", "def uhook_select_fittest category, options = {}\n category\n end", "def test_feature_for_category\r\n\t\tfeatures = Feature.for_category(categories(:root...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_section_selection Description: This method does the functional testing of the section_selection method from the OI Instruction Controller class
def test_section_selection # Try accessing from an account that is not a PCB Designer and # verify that the user is redirected. get(:section_selection, { :id => @board_prep.id, :design_id => @mx234a.id }, pat_dfm_session) assert_redirected_to(:controller => 'tracker', :action => 'inde...
[ "def section\n section_test.section\n end", "def section_selection\n\n @category = OiCategory.find(params[:id])\n @design = Design.find(params[:design_id])\n\n if @category.name != \"Other\"\n @sections = @category.oi_category_sections\n @section_id = flash[:assignment] ? flash[:assignm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_process_assignments Description: This method does the functional testing of the
def test_process_assignments board_prep_sections = [oi_category_sections(:board_prep_1), oi_category_sections(:board_prep_2), oi_category_sections(:board_prep_3)] section_ids = board_prep_sections.collect { |s| s.id } team_member_list = [@s...
[ "def process_assignments(user)\n # A user can manage an Assignment if they have the\n # can_manage_assignments? permission in any of the CourseOfferings of\n # the Course that the assignment belongs to.\n #\n # TODO This may need improvement.\n can :manage, Assignment do |assignment|\n course...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_process_assignment_details Description: This method does the functional testing of the
def test_task_assignment board_prep_sections = [oi_category_sections(:board_prep_1), oi_category_sections(:board_prep_2), oi_category_sections(:board_prep_3)] section_ids = board_prep_sections.collect { |s| s.id } team_member_list = [@siva_...
[ "def test_process_assignments\n \n board_prep_sections = [oi_category_sections(:board_prep_1),\n oi_category_sections(:board_prep_2),\n oi_category_sections(:board_prep_3)]\n section_ids = board_prep_sections.collect { |s| s.id }\n team_member_li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_report_card_list Description: This method does the functional testing of the report card list view.
def test_report_card_list get(:report_card_list, { :id => @board_prep.id, :design_id => @mx234a.id }, scott_designer_session) assert_equal(@mx234a.id, assigns(:design).id) assert_equal(@board_prep.id, assigns(:category).id) assert_nil(assigns(:assignments_list)) end
[ "def test_lists\n\n # Try listing without being logged in - it should bounce to\n # the tracker index.\n post(:originator_list, {}, @empty_session)\n assert_redirected_to(:controller => 'tracker',\n\t\t :action => 'index')\n assert_equal(Pcbtr::PCBTR_BASE_URL + 'board_design_entry...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_create_assignment_report Description: This method does the functional testing of the create assignment report view.
def test_create_assignment_report first_report = oi_assignment_reports(:first) # Try accessing from an account that is not a PCB Designer and # verify that the user is redirected. get(:create_assignment_report, { :id => oi_assignment_reports(:first) }, lee_hweng_session) assert_redirected_...
[ "def create_assignment_report\n \n @assignment = OiAssignment.find(params[:id])\n @complexity_id = @assignment.complexity_id\n @report = OiAssignmentReport.new(:score => OiAssignmentReport::NOT_SCORED)\n @comments = @assignment.oi_assignment_comments\n @scoring_table = OiAssignmentRep...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_static_view Description: This method does the functional testing of the static_view view.
def test_static_view first_assignment = oi_assignments(:first) # Try accessing from an account that is not a PCB Designer and # verify that the user is redirected. get(:static_view, { :id => first_assignment }, siva_designer_session) assert_redirected_to(:controller => 'tracker', :action ...
[ "def test_static_page\r\n# it appears this style of interaction is deprecated, and doesn't work (without adding in more\r\n# non-obvious stuff...)\r\n#\t\t@request.path = '/contact-us'\r\n#\t\t@request.action = :contact_us\r\n#\t\tresponse = StaticPagesController.process_test(@request)\r\n\t\t@request.path = '/abou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_view_assignment_report Description: This method does the functional testing of the view assignment report view.
def test_view_assignment_report first_assignment = oi_assignments(:first) # Try accessing from an account that is not a PCB Designer and # verify that the user is redirected. get(:view_assignment_report, { :id => first_assignment }, siva_designer_session) assert_redirected_to(:controller =...
[ "def test_create_assignment_report\n \n first_report = oi_assignment_reports(:first)\n \n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n get(:create_assignment_report, { :id => oi_assignment_reports(:first) }, lee_hweng_session)\n assert...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
based on the reference spec in lib/rpmvercmp.c in rpm 4.9.0
def rpmvercmp(x, y) # easy! :) return 0 if x == y if x.nil? x = "" end if y.nil? y = "" end # not so easy :( # # takes 2 strings like # ...
[ "def compare_values(s1, s2)\n if s1.nil? && s2.nil?\n return 0\n elsif ( not s1.nil? ) && s2.nil?\n return 1\n elsif s1.nil? && (not s2.nil?)\n return -1\n end\n return rpmvercmp(s1, s2)\n end", "def compare_values(s1, s2)\n return 0 if s1.nil? && s2.nil?\n return 1 i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Rough RPM::Version rpm_version_cmp equivalent except much slower :) partial lets epoch and version segment equality be good enough to return equal, eg: 2:1.21 == 2:1.2 2:1.21 == 2:
def compare_versions(y, partial = false) x = self # compare epoch if (x.e.nil? == false && x.e > 0) && y.e.nil? return 1 elsif x.e.nil? && (y.e.nil? == false && y.e > 0) return -1 elsif x.e.nil? == false && y.e.nil? == false ...
[ "def compare_versions(y, partial=false)\n x = self\n\n # compare epoch\n if (x.e.nil? == false and x.e > 0) and y.e.nil?\n return 1\n elsif x.e.nil? and (y.e.nil? == false and y.e > 0)\n return -1\n elsif x.e.nil? == false and y.e.nil?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test if another RPMDependency satisfies our requirements
def satisfy?(y) unless y.is_a?(RPMDependency) raise ArgumentError, "Expecting an RPMDependency object" end x = self # Easy! if x.name != y.name return false end # Partial compare # ...
[ "def satisfy?(y)\n unless y.kind_of?(RPMDependency)\n raise ArgumentError, \"Expecting an RPMDependency object\"\n end\n\n x = self\n\n # Easy!\n if x.name != y.name\n return false\n end\n\n # Partial compare\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lookup package_name and return a descending array of package objects
def lookup(package_name) pkgs = @rpms[package_name] if pkgs pkgs.sort.reverse else nil end end
[ "def lookup(package_name)\n pkgs = @rpms[package_name]\n if pkgs\n return pkgs.sort.reverse\n else\n return nil\n end\n end", "def find_package_by_name(name)\n @packages[name]\n end", "def find_package_set(name)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lists the names of the store this user is entitled to read or write to.
def store_names names = @store_names.dup names << "users" unless names.include?("users") names end
[ "def find_all_storenames\n\n WiStore.find(:all).collect do |store|\n store.name\n end\n end", "def get_store_names\n\n sname = params[:store]\n sname ? sname.split(',') : nil\n end", "def workitems (store_name=nil)\n\n return load_user_workitems if store_name == 'users'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the permission for the given store.
def permission (store_name) return RWD_STORE_PERMISSION if @user.admin? return RWD_STORE_PERMISSION if store_name == 'users' @permissions[store_name] end
[ "def find_permissions\n\n return nil if @user.admin?\n\n groupnames = Group.find_groups(@user)\n\n StorePermission.find_all_by_groupname(groupnames).inject({}) do \n |result, permission|\n\n result[permission.storename] = permission\n result\n end\n end", "def manage?(s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the workitems for the given store.
def workitems (store_name=nil) return load_user_workitems if store_name == 'users' return (@workitems[store_name] || []) if store_name # then return all the workitems the user has access to wis = load_user_workitems @store_names.inject(wis) do |r, sname| r += (@workitems[sname] || []) ...
[ "def workitems\n @engine.storage_participant.map do |wi|\n ScriptoriaCore::Workitem.from_ruote_workitem(wi)\n end\n end", "def each (&block)\n\n return unless block\n\n wis = Workitem.find_by_store_name(@store_name)\n\n wis.each { |wi| block.call(wi) }\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the list of store[ names]s to which the user can delegate. If a workitem is passed, makes sure to remove the workitem current store name from the resulting list.
def delegation_targets (workitem=nil) names = @store_names.find_all { |n| permission(n).may_delegate? } names.delete(workitem.store_name) if workitem names end
[ "def workitems (store_name=nil)\n\n return load_user_workitems if store_name == 'users'\n return (@workitems[store_name] || []) if store_name\n\n # then return all the workitems the user has access to\n\n wis = load_user_workitems\n\n @store_names.inject(wis) do |r, sname|\n r += (@workitems[sna...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a search string, returns all the matching workitems (in the stores in which the user can read).
def search (query_string) OpenWFE::Extras::Workitem.search(query_string, store_names).find_all do |wi| @user.admin? or ( wi.store_name != 'users' || wi.participant_name == @user.name) end end
[ "def search_work(params)\n query = params.map { |key, value| [key, value].join(':') }.join(' AND ')\n result = call('work', query: query)\n extract_list result.work_list, :work\n end", "def search_for_store(query)\n\n @stores = Store.all\n\n # List to hold all store matches\n store_matches = []...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all the store names (according to the 'wi_stores' table)
def find_all_storenames WiStore.find(:all).collect do |store| store.name end end
[ "def get_store_names\n\n sname = params[:store]\n sname ? sname.split(',') : nil\n end", "def get_wms_stores workspace = nil\n ws = workspace.nil?? get_workspaces : [get_workspace(workspace)]\n cs = []\n ws.each{ |w| cs += w.wms_stores if w.wms_stores }\n cs\n end", "def get...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the mapping "storename" > Permission instance
def find_permissions return nil if @user.admin? groupnames = Group.find_groups(@user) StorePermission.find_all_by_groupname(groupnames).inject({}) do |result, permission| result[permission.storename] = permission result end end
[ "def permission (store_name)\n\n return RWD_STORE_PERMISSION if @user.admin?\n return RWD_STORE_PERMISSION if store_name == 'users'\n @permissions[store_name]\n end", "def get_permissions\n if @role.type_role==\"system\"\n\t\t\t@permissions = Permission.find(:all, :order => 'name ASC')\n\t else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Companion function to the !roles command used to generate the embeds for each group
def generate_embed(index) embed = Discordrb::Webhooks::Embed.new embed.color = 0xFFD700 # If index for a role group is given, generate embed for that group if index > 0 group = AssignableRoleGroup.all[index - 1] embed.author = { name: "Group: #{group.name}", icon_url...
[ "def role_to_embed\n raise \"Must be implemented by embed storage to generate a set of roles to embed\"\n end", "def groups\n roles\n end", "def list_roles\n #-find all characters that actor plays\n #-iterate over characters and compare to itself\n #-mutate each array 'character-show name'\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /score_evaluations GET /score_evaluations.json
def index @score_evaluations = ScoreEvaluation.all respond_to do |format| format.html # index.html.erb format.json { render :json => @score_evaluations } end end
[ "def index\n @evaluation_scores = EvaluationScore.all\n end", "def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def get_eval\n\t\t@stu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /score_evaluations/1 GET /score_evaluations/1.json
def show @score_evaluation = ScoreEvaluation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @score_evaluation } end end
[ "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /score_evaluations/new GET /score_evaluations/new.json
def new @score_evaluation = ScoreEvaluation.new respond_to do |format| format.html # new.html.erb format.json { render :json => @score_evaluation } end end
[ "def new\n @evaluation = Evaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation }\n end\n end", "def new\n @enrolled_score = EnrolledScore.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.jso...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /score_evaluations POST /score_evaluations.json
def create @score_evaluation = ScoreEvaluation.new(params[:score_evaluation]) respond_to do |format| if @score_evaluation.save format.html { redirect_to @score_evaluation, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @score_evaluation.class.model_name.h...
[ "def create\n @evaluation_score = EvaluationScore.new(evaluation_score_params)\n\n respond_to do |format|\n if @evaluation_score.save\n format.html { redirect_to @evaluation_score, notice: 'Evaluation score was successfully created.' }\n format.json { render :show, status: :created, locatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /score_evaluations/1 DELETE /score_evaluations/1.json
def destroy @score_evaluation = ScoreEvaluation.find(params[:id]) @score_evaluation.destroy respond_to do |format| format.html { redirect_to score_evaluations_url } format.json { head :no_content } format.js end end
[ "def destroy\n @evaluation_score.destroy\n respond_to do |format|\n format.html { redirect_to evaluation_scores_url, notice: 'Evaluation score was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_line_score.destroy\n respond_to do |format|\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /today_activities/1 GET /today_activities/1.xml
def show @today_activity = TodayActivity.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @today_activity } end end
[ "def recent_activities\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def recent_activities()\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def all_activities\n get('activities.json')\n end", "def recent_activities\n get(\"user/#{user_id}/activities/re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /today_activities/new GET /today_activities/new.xml
def new @today_activity = TodayActivity.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @today_activity } end end
[ "def new\n @activity = get_user.activities.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end", "def new\n @recent_activity = RecentActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /today_activities POST /today_activities.xml
def create @today_activity = TodayActivity.new(params[:today_activity]) respond_to do |format| if @today_activity.save flash[:notice] = 'TodayActivity was successfully created.' format.html { redirect_to(@today_activity) } format.xml { render :xml => @today_activity, :status => :...
[ "def create\n raise Request::NoRequiredFields unless params[:activities]\n Request.add( params[:org_id], current_user, \"activity\", \"add\", { :new_record => params[:activities][0..4] } )\n respond_success \"Спасибо, Ваш запрос отправлен\", requests_path\n rescue ActiveRecord::RecordInvalid, ActiveRecord...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /today_activities/1 PUT /today_activities/1.xml
def update @today_activity = TodayActivity.find(params[:id]) respond_to do |format| if @today_activity.update_attributes(params[:today_activity]) flash[:notice] = 'TodayActivity was successfully updated.' format.html { redirect_to(@today_activity) } format.xml { head :ok } ...
[ "def update\n @activity = Activity.find(params[:id])\n \n respond_to do |format|\n if @activity.update_attributes(params[:activity])\n format.html { redirect_to activities_path }\n format.xml { render :nothing => true }\n else\n format.html { render :action => \"edit\" }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /today_activities/1 DELETE /today_activities/1.xml
def destroy @today_activity = TodayActivity.find(params[:id]) @today_activity.destroy respond_to do |format| format.html { redirect_to(today_activities_url) } format.xml { head :ok } end end
[ "def destroy\n @evactivity = Evactivity.find(params[:id])\n @evactivity.destroy\n\n respond_to do |format|\n format.html { redirect_to(evactivities_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @activity = get_user.activities.find(params[:id])\n @activity.destroy\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
In the following 6 digit number: 283910 91 is the greatest sequence of 2 digits. Complete the solution so that it returns the largest five digit number found within the number given.. The number will be passed in as a string of only digits. It should return a five digit integer. The number passed may be as large as 100...
def solution(digits) digits.scan(/\d{5}/).max.to_i end
[ "def solution(digits)\n max_digits = 5 # How many digits\n digits_length = digits.to_s.length\n if digits_length < max_digits\n return digits\n end\n x=0\n y=x+max_digits # Position end of string to 5th digit\n largest_number = 0\n while y<= digits_length\n str_digits = subst...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Rock Paper Scissors Let's play! You have to return which player won! In case of a draw return Draw!. Examples: rps('scissors','paper') // Player 1 won! rps('scissors','rock') // Player 2 won! rps('paper','paper') // Draw! My code:
def rps(p1, p2) if p1 == "scissors" && p2 == "paper" return "Player 1 won!" elsif p1 == "scissors" && p2 == "rock" return "Player 2 won!" elsif p1 == "scissors" && p2 == "scissors" return "Draw!" end if p1 == "paper" && p2 == "paper" return "Draw!" elsif p1 == "paper" && p2 == "rock" re...
[ "def rps (player1, player2)\n return \"Draw!\" if player1 === player2\n win_player_1 = \"Player 1 won!\"\n win_player_2 = \"Player 2 won!\"\n draw = \"Draw!\"\n\n if player1 == \"paper\"\n return win_player_1 if player2 == \"rock\"\n return win_player_2 if player2 == \"scissors\"\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /auto1h_fold_changes/1 GET /auto1h_fold_changes/1.xml
def show @auto1h_fold_change = Auto1hFoldChange.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @auto1h_fold_change } end end
[ "def update\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change])\n format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') }\n format.xm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /auto1h_fold_changes/new GET /auto1h_fold_changes/new.xml
def new @auto1h_fold_change = Auto1hFoldChange.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @auto1h_fold_change } end end
[ "def new\n @fold_change = FoldChange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fold_change }\n end\n end", "def new\n @hetero1h_fold_change = Hetero1hFoldChange.new\n\n respond_to do |format|\n format.html # new.html.erb\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /auto1h_fold_changes POST /auto1h_fold_changes.xml
def create @auto1h_fold_change = Auto1hFoldChange.new(params[:auto1h_fold_change]) respond_to do |format| if @auto1h_fold_change.save format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully created.') } format.xml { render :xml => @auto1h_fold_chang...
[ "def update\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change])\n format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') }\n format.xm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /auto1h_fold_changes/1 PUT /auto1h_fold_changes/1.xml
def update @auto1h_fold_change = Auto1hFoldChange.find(params[:id]) respond_to do |format| if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change]) format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') } format.xml { head :...
[ "def update\n @hetero1h_fold_change = Hetero1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @hetero1h_fold_change.update_attributes(params[:hetero1h_fold_change])\n format.html { redirect_to(@hetero1h_fold_change, :notice => 'Hetero1h fold change was successfully updated.') }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /auto1h_fold_changes/1 DELETE /auto1h_fold_changes/1.xml
def destroy @auto1h_fold_change = Auto1hFoldChange.find(params[:id]) @auto1h_fold_change.destroy respond_to do |format| format.html { redirect_to(auto1h_fold_changes_url) } format.xml { head :ok } end end
[ "def destroy\n @auto24h_fold_change = Auto24hFoldChange.find(params[:id])\n @auto24h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto24h_fold_changes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @hetero1h_fold_change = Hetero1hFoldChange.f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
~ Validation ............................................................... ~ Constants ................................................................ ~ Hooks .................................................................... ~ Class methods ............................................................ ~ Instance m...
def clone(book, chapter) ch_mod = InstChapterModule.new ch_mod.inst_chapter_id = chapter.id ch_mod.inst_module_id = self.inst_module_id ch_mod.module_position = self.module_position ch_mod.save inst_sections.each do |section| inst_section = section.clone(book, ch_mod) end end
[ "def clone(inst_book)\n ch = InstChapter.new\n ch.inst_book_id = inst_book.id\n ch.name = self.name\n ch.short_display_name = self.short_display_name\n ch.position = self.position\n ch.save\n\n inst_chapter_modules.each do |chapter_module|\n inst_chapter_module = chapter_module.clone(inst_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets all the exercises in one module
def get_exercises_list exercises_list = [] inst_sections.each do |inst_section| exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact exercises_objs = InstExercise.where(id: exercises_ids) exercises_list.concat exercises_objs.collect(&:short_name) end...
[ "def get_bk_sec_exercises()\n InstBookSectionExercise.includes(:inst_exercise)\n .joins(:inst_section)\n .where(inst_sections: {inst_chapter_module_id: self.id})\n end", "def index\n @api_v1_exercises = Api::V1::Exercise.all\n end", "def get_all_exercises(query: nil, page: 1, exercises: [])\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get all of the inst_book_section_exercise instances associated with this module
def get_bk_sec_exercises() InstBookSectionExercise.includes(:inst_exercise) .joins(:inst_section) .where(inst_sections: {inst_chapter_module_id: self.id}) end
[ "def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact\n exercises_objs = InstExercise.where(id: exercises_ids)\n exercises_list.concat exercises_objs.collect(&:short_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get all exercise progresses for the exercises in this module for the specified user
def get_exercise_progresses(user_id) OdsaExerciseProgress.joins(inst_book_section_exercise: [:inst_section]) .where(inst_sections: {inst_chapter_module_id: self.id}, user_id: user_id) end
[ "def todays_exercises(user)\n todays_exercises = []\n @exercises.each do |exercise|\n if exercise.session_type == todays_session_type(user)\n todays_exercises << exercise\n end\n end\n todays_exercises.uniq\n end", "def list_exercises(transaction_id, user_id, opts =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /volunteer_jobs GET /volunteer_jobs.json
def index @volunteer_jobs = VolunteerJob.all respond_to do |format| format.html # index.html.erb format.json { render json: @volunteer_jobs } end end
[ "def show\n @volunteer_job = VolunteerJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer_job }\n end\n end", "def index\n \n @meeting_threads = @current_user.available_jobs\n \n \n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /volunteer_jobs/1 GET /volunteer_jobs/1.json
def show @volunteer_job = VolunteerJob.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @volunteer_job } end end
[ "def index\n @volunteer_jobs = VolunteerJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @volunteer_jobs }\n end\n end", "def new\n @volunteer_job = VolunteerJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /volunteer_jobs/new GET /volunteer_jobs/new.json
def new @volunteer_job = VolunteerJob.new respond_to do |format| format.html # new.html.erb format.json { render json: @volunteer_job } end end
[ "def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end", "def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /volunteer_jobs POST /volunteer_jobs.json
def create @volunteer_job = VolunteerJob.new(params[:volunteer_job]) respond_to do |format| if @volunteer_job.save format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully created.' } format.json { render json: @volunteer_job, status: :created, location: @voluntee...
[ "def new\n @volunteer_job = VolunteerJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer_job }\n end\n end", "def create\n @vacant_job = VacantJob.new(params[:vacant_job])\n\n respond_to do |format|\n if @vacant_job.save\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /volunteer_jobs/1 PUT /volunteer_jobs/1.json
def update @volunteer_job = VolunteerJob.find(params[:id]) respond_to do |format| if @volunteer_job.update_attributes(params[:volunteer_job]) format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully updated.' } format.json { head :ok } else format.ht...
[ "def update\n if @job_oportunity.update(job_oportunity_params)\n render :show, status: :ok, location: @job_oportunity\n else\n render json: @job_oportunity.errors, status: :unprocessable_entity\n end\n end", "def create\n @volunteer_job = VolunteerJob.new(params[:volunteer_job])\n\n resp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /volunteer_jobs/1 DELETE /volunteer_jobs/1.json
def destroy @volunteer_job = VolunteerJob.find(params[:id]) @volunteer_job.destroy respond_to do |format| format.html { redirect_to volunteer_jobs_url } format.json { head :ok } end end
[ "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to admin_jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @launched_job.destroy\n respond_to do |format|\n format.html { redirect_to launched_jobs_url }\n format.json { head ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Operation sperformed in FleetServiceRequest_FromDashboard script 1. User Login to application with valid credentials 2. User searches for a vehicle with unit and verifies the search results 3. Searches for a service location and verifies that the search results were displayed correctly 4. Creates service request for th...
def test_FleetRequest_FromSearchPage # Navigate to the volvo demo site @driver.get $env #1. Login to the application Login($uname, $pwd, "1.0") #2. Perform vehicle search with unit# and verify the search results VehicleSearchWithUnit_No("222", "2") #3. Perform service locat...
[ "def test_FleetRequest_FromDashboardPage\n\t # Navigate to the volvo demo site\n @driver.get $env\n \n #1. Login to the application \n Login($uname, $pwd, \"1.0\") \n \n\t #2. Click on vehicle# link \n\t if(\"No entries found\"!=(@driver.find_element(:css, RequestServicesTableSe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if a file belongs to a filtered list
def file_is_filtered?(path_cand) filename = File.basename(path_cand) ix = @filter_file.index(filename) if ix log "FILTER: #{path_cand}" return true else return false end end
[ "def is_a_list?(file)\n !!(file =~ /list$/)\n end", "def include?(file)\n @file_list.include?(file.basename)\n end", "def contain?(*files)\n files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s) } }\n end", "def filter_entries(file_entry_name, file_entry_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add the parameters in hash +new+ to already existing parameters. If +new+ contains a parameter with an already existing name, the old definition is clobbered.
def add_params(new) # We do not check for duplication on purpose: multiple calls # to add_params should be cumulative new.each { |p| @params[p.name] = p } end
[ "def set_new_parameters(new_atk, new_def, new_spi, new_agi)\n if @new_atk != new_atk or @new_def != new_def or\n @new_spi != new_spi or @new_agi != new_agi\n @new_atk = new_atk\n @new_def = new_def\n @new_spi = new_spi\n @new_agi = new_agi\n refresh\n end\n end", "def set_new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If the payment was successful, Cybersource will send us back a decision of 'ACCEPT'
def payment_success? @fields['decision'] == 'ACCEPT' end
[ "def guard_payment_successful\n true\n end", "def process!\n log_payment(\"Attempting to process payment: #{self}\")\n if valid?\n response = process_payment\n log_payment \"Processing - Received response: Success=#{response.success?} Auth=#{response.authorization} Params=<#{response.param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Raise an error if the payment failed or if the signature is invalid
def validate! Cybersource::Security.validate_signature!(@fields['signature'], signed_data) raise PaymentFailed unless payment_success? self end
[ "def test_bad_signature\n r = Adyen::Return.new('merchantReference=1234&skinCode=fVmBwBe3&shopperLocale=en_GB&paymentMethod=visa&authResult=AUTHORISED&pspReference=8612537486987238&merchantSig=6T6mc7NDB1c5I6So816B2hYMNRY%3D',\n :shared_secret => 'QCEAIHYyxiducsnczt6bdl7m5z4vao4f') # NOTE...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if a line of string contains specific hostname
def includes_hostname?(line, hostname) /\s#{Regexp.escape(hostname.fqdn)}(\s|$)/ =~ line end
[ "def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname)}(\\s|$)/ =~ line\n end", "def hosts_exists?(hostname)\n hosts = File.read PATHS[:hosts]\n hosts.include? \"\\t#{hostname}\\n\"\nend", "def validate_hostname(hostname)\n hostname_regex = /(hostname)$/\n if hostname_regex =~ h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }