query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
The tuition calculated indicator is always S09 and TCALC
def tuition_calculated? type_code == '+S09' && reason_code == 'TCALC' end
[ "def tupe\n if @tupe_flag == 'Y'\n @tupe =\n if @supplier_name\n @subtotal3 * @rate_card.data['Variances'][@supplier_name]['TUPE Risk Premium (DA %)'].to_f\n else\n @subtotal3 * @framework_rates['M148']\n end\n else\n 0\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /admin/weeks/1 PATCH/PUT /admin/weeks/1.json
def update respond_to do |format| if @admin_week.update(admin_week_params) format.html { redirect_to @admin_week, success: 'Week was successfully updated.' } format.json { render :show, status: :ok, location: @admin_week } else format.html { render :edit } format.json { r...
[ "def update\n respond_to do |format|\n if @week.update(week_params)\n format.json { render :show, status: :ok, location: @week }\n else\n format.json { render json: @week.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @week.update(week_params)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /admin/weeks/1 DELETE /admin/weeks/1.json
def destroy @admin_week.destroy respond_to do |format| format.html { redirect_to admin_weeks_url, success: 'Week was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @week.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @wb_week.destroy\n respond_to do |format|\n format.html { redirect_to wb_weeks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @when_w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new factory with all the subclasses of base added to it as matchers.
def factory raise RuntimeError unless defined? @subclasses MessageFactory.new @subclasses.map(&:matcher) end
[ "def extended(base)\n base.matchers.concat(matchers)\n end", "def child_factories; end", "def matchers\n Argument::Matcher.subclasses.map { |subclass| subclass.new(@arguments) }\n end", "def new_class(name, inherits_of, context) #method\n @classes[name] = ObjectClass.new(name, inherits_of, cont...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a value and mask that can be used to match the first byte of a message. == Usage The following example illustrates how the value and mask are intended to be used. value, mask = status_value_and_mask 0x42 & mask == value => true if STATUS == 0x40 value, mask = status_value_and_mask 3 0x42 & mask == value => fals...
def status_value_and_mask(channel = nil) if channel validate_channel channel [(self::STATUS & self::STATUS_MASK) + (channel & CHANNEL_MASK), self::STATUS_MASK + CHANNEL_MASK] else [self::STATUS, self::STATUS_MASK] end ...
[ "def parse_mask(mask)\n and_mask = mask.gsub(\"X\", \"1\").to_i(2)\n or_mask = mask.gsub(\"X\", \"0\").to_i(2)\n\n [and_mask, or_mask]\nend", "def mask\n # + - - - - - - - - - - - - - - - +-------------------------------+\n # | |Masking-key, if MASK set to 1 |\n # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The klass matcher is the most generic `Matcher` for the message class and is cached to avoid duplication. By default the default `Matcher` uses the value and mask returned by `status_value_and_mask` to match messages. Subclasses that need different behaviour can pass a block to be forwarded directly to the matcher (see...
def klass_matcher(&block) return @klass_matcher if defined?(@klass_matcher) unless block_given? val, mask = status_value_and_mask block = proc { |d| (d[0] & mask) == val } end @klass_matcher = Matcher.new(self, &block) end
[ "def klass_matcher\n super do |d|\n (d[0] & STATUS_MASK) == STATUS && d[1] >= 120\n end\n end", "def klass_matcher\n super do |d|\n (d[0] & STATUS_MASK) == STATUS && d[1] < 120\n end\n end", "def _match_class(klass)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Constructs a Valkyrie::Persistence::CustomQueryContainer using this query service
def custom_queries @custom_queries ||= ::Valkyrie::Persistence::CustomQueryContainer.new(query_service: self) end
[ "def custom_queries\n @custom_queries ||= ::Valkyrie::Persistence::CustomQueryContainer.new(query_service: self)\n end", "def build_query want\n Query.new want\n end", "def initialize(query)\n @queryable = query.all\n end", "def base_query\n DataServicesApi::QueryGenerator.new\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse out _str_ and return two Time objects. It will return nil if one of the times are corrupt (like 13th month) or missing. It will also look at context if no end time is given so: 2008 becomes 20080101 00:00:00 20081231 23:59:59 200801 becomes 20080101 00:00:00 20080131 23:59:59 20080101 becomes 20080101 00:00:00 20...
def parse(str) match_data = str.match(DATE_REGEXP) # Oh my god, I hate this shit. Basically it prepares dates for # Time.parse consuming because it's so stupid and ignorant it wants # to make me puke :( from = extract_time_string_from_match_data(match_data) to = extract_time_string_...
[ "def parse_time str\n return nil unless str\n day = get_f_with_units( str, /(\\s)?d(ay(s)?)?/i ) || 0\n hr = get_f_with_units( str, /(\\s)?h((ou)?r(s)?)?/i ) || 0\n min = get_f_with_units( str, /(\\s)?m(in(ute)?(s)?)?/i ) || 0\n sec = get_f_with_units( str, /(\\s)?s(ec(s)?)?/i ) || 0\n \n return...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extract context from match data. For example if user enters just 2008 it will return :year. Return value meanings: :year: end range should be years end :month: end range should be months end :nothing: nothing should be done with end range
def extract_context_from_match_data(m, offset=0) year, month, day, hour, minute, second = \ extract_pieces_from_match_data(m, offset) if year and month and day and hour and minute and second :nothing elsif year and month and day and hour and minute :minute elsif year and...
[ "def description\n case range\n when :year\n \"in #{starting.year}\" # in 2008\n when :month\n \"in #{starting.strftime(\"%B %Y\")}\" # in November 2008\n when :day\n \"on #{starting.strftime(\"%B %d, %Y\")}\" # on November 18, 2008\n else\n \"between #{starting.strftime(\"%B %d %...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Derive from this waypoint's location, its opposite location and its left & right locations. These will be determined to make 'rotation' easier. Example: For a location east 10, north 1 oppositie location is: west 10, south 1 right location is: east 1, south 10 left location is: west 1, north 10.
def location_changed! east = location.east_units west = location.west_units north = location.north_units south = location.south_units # NOTE: expectation is 1 of the paired directions will be zero. calculate_location_opposite east: east, west: west, north: north, south: south calculate_loc...
[ "def calculate_location_right east:, west:, north:, south:\n self.location_right = {}\n if east.zero? && north.zero?\n location_right[:west] = south\n location_right[:north] = west\n elsif east.zero? && south.zero?\n location_right[:east] = north\n location_right[:north] = west\n els...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Example: For a location east 10, north 1 oppositie location is: west 10, south 1
def calculate_location_opposite east:, west:, north:, south: self.location_opposite = {} if east.zero? location_opposite[:east] = west else location_opposite[:west] = east end if north.zero? location_opposite[:north] = south else location_opposite[:south] = north end...
[ "def location_changed!\n east = location.east_units\n west = location.west_units\n\n north = location.north_units\n south = location.south_units\n\n # NOTE: expectation is 1 of the paired directions will be zero.\n calculate_location_opposite east: east, west: west, north: north, south: south\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Example: For a location east 10, north 1 right location is: east 1, south 10
def calculate_location_right east:, west:, north:, south: self.location_right = {} if east.zero? && north.zero? location_right[:west] = south location_right[:north] = west elsif east.zero? && south.zero? location_right[:east] = north location_right[:north] = west elsif west.zero?...
[ "def calculate_location_left\n self.location_left = {}\n if location_right.key? :east\n location_left[:west] = location_right[:east]\n else\n location_left[:east] = location_right[:west]\n end\n\n if location_right.key? :north\n location_left[:south] = location_right[:north]\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Example: For a location east 10, north 1 left location is: west 1, north 10. NOTE: location left is opposite from location right
def calculate_location_left self.location_left = {} if location_right.key? :east location_left[:west] = location_right[:east] else location_left[:east] = location_right[:west] end if location_right.key? :north location_left[:south] = location_right[:north] else location_...
[ "def location_changed!\n east = location.east_units\n west = location.west_units\n\n north = location.north_units\n south = location.south_units\n\n # NOTE: expectation is 1 of the paired directions will be zero.\n calculate_location_opposite east: east, west: west, north: north, south: south\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /bankets POST /bankets.json
def create @banket = Banket.new(banket_params) respond_to do |format| if @banket.save format.html { redirect_to @banket, notice: 'Banket was successfully created.' } format.json { render :show, status: :created, location: @banket } else format.html { render :new } fo...
[ "def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.succe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /bankets/1 PATCH/PUT /bankets/1.json
def update respond_to do |format| if @banket.update(banket_params) format.html { redirect_to @banket, notice: 'Banket was successfully updated.' } format.json { render :show, status: :ok, location: @banket } else format.html { render :edit } format.json { render json: @ba...
[ "def update\n respond_to do |format|\n if @api_v1_budget.update(api_v1_budget_params)\n format.html { redirect_to @api_v1_budget, notice: 'Budget was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_budget }\n else\n format.html { render :edit }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /bankets/1 DELETE /bankets/1.json
def destroy @banket.destroy respond_to do |format| format.html { redirect_to bankets_url, notice: 'Banket was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @bank = Bank.find(params[:id])\n @bank.destroy\n\n respond_to do |format|\n format.html { redirect_to banks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sole_bank = SoleBank.find(params[:id])\n @sole_bank.destroy\n\n respond_to do |format|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
COUNTER TO IGNORE THE 'puts stringsHash[:start_date]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
def getStartDate(eventName) counter = 0 start_date_check = "" @startDate = "" while start_date_check != 'y' || start_date_check != "exit" if counter == 0 puts @@stringsHash[:start_date] end counter += 1 start_date = gets.str...
[ "def start_time_idx() return (self.start_date.strftime(\"%Y%m%d%H%M\") rescue nil); end", "def process_keywords_date(keywords_init)\n keywords_init.map do |query, data|\n {\n :date => query,\n :query => data.uniq!{|s| s[:query]}.count\n }\n end\n end", "def time_file (doc2, estim...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
COUNTER TO IGNORE THE 'puts stringsHash[:total_days]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
def getTotalDays(eventName) counter = 0 total_days_check = "" @totalDays = "" while total_days_check != 'y' || total_days_check != "exit" if counter == 0 puts @@stringsHash[:total_days] end counter += 1 total_days = gets.str...
[ "def no_of_requests_by_day(requests_per_day_hash)\n requests_per_day_hash.each { |date, item_list|\n # Invalid dates comes as nil. Skip those items\n next if date == nil\n puts \"#{date} -> #{item_list.count}\"\n }\n end", "def validate_time_total(hash, date)\n if hash.values.map(&:to_i)....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
COUNTER TO IGNORE THE 'puts stringsHash[:band_num]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
def getBandNum(eventName) counter = 0 band_num_check = "" @bandNum = "" while band_num_check != 'y' || band_num_check != "exit" if counter == 0 puts @@stringsHash[:band_num] end counter += 1 band_num = gets.strip ...
[ "def getBandNum()\n counter = 0\n band_num_check = \"\"\n @bandNum = \"\"\n while band_num_check != 'y' || band_num_check != \"exit\"\n if counter == 0\n puts @@stringsHash[:band_nums]\n end\n counter += 1\n band_num = gets.strip...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
true if pattern matches request path and http method matches request method
def matches?(req) pattern.match(req.path) && req.request_method.downcase == http_method.to_s end
[ "def matches?(req)\n pattern.match(req.path) &&\n method(req).downcase.to_sym == http_method\n end", "def matches?(req)\n path_match = !!(@pattern =~ req.path)\n method_match = @http_method.to_s == req.request_method.downcase\n path_match && method_match\n end", "def matches?(req)\n matc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses model's publisher's country_codes to determine how to validate zip
def validates_zip_code_according_to_publisher(*config) validates_each(:zip_code, *config) do |model, attr, zip| if zip.present? valid = false if model.publisher model.publisher.country_codes.each do |country_code| regex = postal_code_regex(country_code) ...
[ "def validates_zip_code(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n regex = postal_code_regex(model.country_code)\n if regex.present?\n unless regex =~ zip\n model.errors.add(attr, I18n.t(\"activerecord.errors.mes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If there's no country code at all, pretend us If there is a country code, the regex might still be nil....
def postal_code_regex(country_code) return us_regex if country_code.nil? Country.postal_code_regex(country_code) end
[ "def valid_country_name\n return unless valid?\n\n Phonelib.phone_ext_data[Phonelib::Core::EXT_COUNTRY_NAMES][valid_country]\n end", "def get_valid_country country\n country.strip!\n country.downcase!\n\n return nil if country.blank?\n\n countries = [\"Egypt\", \"Lebanon\", \"Jordan\", \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uses the model''s country code to determine how to validate zip
def validates_zip_code(*config) validates_each(:zip_code, *config) do |model, attr, zip| if zip.present? regex = postal_code_regex(model.country_code) if regex.present? unless regex =~ zip model.errors.add(attr, I18n.t("activerecord.errors.messages.invali...
[ "def validates_zip_code_according_to_publisher(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n valid = false\n if model.publisher\n model.publisher.country_codes.each do |country_code|\n regex = postal_code_regex(coun...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
remove episodes that are found in plex
def thetvdb_missing_plex_found(show,season,episode) plex_has = false # remove shows that we have if $plex.episodes.has_key? show if $plex.episodes[show].has_key?(season.to_i) if $plex.episodes[show][season.to_i].has_key?(episode.to_i) plex_has = true end end end p...
[ "def cleanUpRogueNps\n\n removeNps = []\n @npModels.each do |acceptableNp|\n idx = 0\n \n @npModels.each do |otherNp|\n if otherNp.included == false && otherNp.id != acceptableNp.id && otherNp.startIdx == acceptableNp.startIdx && otherNp.endIdx <= acceptableNp.endIdx\n removeNps...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete the character from the line positioned at the given index.
def delete_character(index = nil) Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete .from(line, index, size)) end
[ "def delete(index)\n @buffer.del_line(abs_line(index))\n end", "def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end", "def delete_character\n return self if document_start?\n\n if first_char? && y > 0\n delete_line\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Insert the character on the line positioned at the given index.
def insert_character(character, index = nil) return self unless character Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert .into(collection, character, index, size)) end
[ "def insert_character(character, index = nil)\n return self unless character\n\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert\n .into(line, character, index, size))\n end", "def insert_character(character, y, x)\n lines[y] = line(y).insert_character(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a string containing digits from 29 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
def letter_combinations(digits) map = "- - abc def ghi jkl mno pqrs tuv wxyz".split charsets = digits.chars.map { |d| map[d.to_i].chars } digits == "" ? [] : [''].product(*charsets).map(&:join) end
[ "def letter_combinations(digits)\n return [] if digits.empty?\n\n keymap = {\n \"1\" => \"\",\n \"2\" => \"abc\",\n \"3\" => \"def\",\n \"4\" => \"ghi\",\n \"5\" => \"jkl\",\n \"6\" => \"mno\",\n \"7\" => \"pqrs\",\n \"8\" => \"tuv\",\n \"9\" => \"wxyz\",\n \"0\" => \" \"\n }\n\n c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given an array nums and a value val, remove all instances of that value inplace and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array inplace with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond the new le...
def remove_element(nums, val) nums.each_with_index do |num, i| if num == val nums[i] = nil end end nums.compact! nums.length end
[ "def remove_val(nums,val)\n return 0 if nums.length == 0 \n nums.each_with_index do |el,idx|\n if el == val\n nums[idx] = nil\n end\n end \n nums.compact!\n nums.length\nend", "def remove_element(nums, val)\n return 0 if nums.empty? || (nums.size == 1 && nums[0] == val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
When Car.new is called, this method is run Therefore, for this class, you must pass in 2 variables (make and model) when creating a new instance of it
def initialize(make, model) @make = make @model = model end
[ "def createModel(model, trim, km, year, type, driveTrain, trans, id, status, fuel, features)\n @carModel = CarModel.new(model, trim, km, year, type, driveTrain, trans, id, status, fuel, features)\n self.model = model\n self.trim = trim\n self.km = km\n self.year = year\n self.type = type\n self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
puppet version to use (env var)
def puppet_version "PUPPET_VERSION=2.7.19" end
[ "def puppet_version\n \"3.5.1\"\nend", "def puppet_version\n @catalog_obj.respond_to?(:puppet_version) ? @catalog_obj.puppet_version : @options[:puppet_version]\n end", "def get_puppet_version\n version = nil\n installed = self.is_in_path?('puppet')\n\n if installed\n raw = self.run('pu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO: Don't mark loans as realised if they have futher recoveries.
def realise_loans! loan_ids = realised_recoveries.map {|recovery| recovery.loan.id }.uniq Loan.find(loan_ids).each do |loan| loan.realised_money_date = Date.today loan.modified_by = creator loan.update_state!(Loan::Realised, LoanEvent::RealiseMoney, creator) end end
[ "def unreturn_referenced_loan\n loan.update_attributes(returned: false)\n end", "def before_recover\n end", "def after_recover\n end", "def recovery?()\n #This is a stub, used for indexing\n end", "def handle_completly_uncontested!\n\n # sole party get thre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a before hook that applies the received validator class to input. will abort request with validation error if invalid
def validate_input(validator_klass, options = {}) unless validator_klass.include?(ActiveModel::Validations) raise ArgumentError, "validator class should be an ActiveModel::Validator" end before lambda { |_rack_env, env| validator = validator_klass.new(env[:input]) validator.valid? || twir...
[ "def before_validation(*args, &block); end", "def _before_validation\n end", "def validated_before(method)\n __method = :\"#{method}_without_validations\"\n alias_method __method, method\n\n define_method method do |*params|\n begin\n if valid? then send __method else raise errors end\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
used when constructing service to apply handler's configured service hooks
def configure_hooks(hook_type, service) unless VALID_HOOKS.include?(hook_type) raise ArgumentError, "unknown twirp hook type received: #{hook_type}" end existing_hooks = instance_variable_get("@#{hook_type}_hooks") return if existing_hooks.nil? existing_hooks.values.each do |hook| serv...
[ "def setup_processor\n @loadedhandlers = []\n self.set_service_hook do |obj, *args|\n protect_service(obj, *args)\n end\n end", "def register_hooks; end", "def get_service_hook\n @service_hook\n end", "def around_hooks; end", "def service_init (service_name, application_context)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a wrapped lambda for received hook config and registers it to hooks. method can be a Proc or name of instance or class method on the handler. options :if and :unless are respected here.
def define_hook(hooks, method, options) hook_name = options[:name] || method if hook_name.is_a?(Proc) raise ArgumentError, "name option required when using proc for method" end hooks[hook_name] = lambda do |*args| env = args.find { |arg| arg.is_a?(Hash) && arg.key?(:input) } return if...
[ "def hook(*args, &block)\n\t\t\thooks = args.last.is_a?(::Hash) ? args.pop : {}\n\n\t\t\targs.each do |method|\n\t\t\t\toriginal_method = self.instance_method(method)\n\n\t\t\t\tself.send(:define_method, method) do |*a|\n\t\t\t\t\treturn original_method.bind(self).call(*a) if \n\t\t\t\t\t\tcase\n\t\t\t\t\t\twhen ho...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add a single item to a set of item_ids to the matrix
def add_single(set_id, item_id, other_item_ids) raise "implemented in subclass" end
[ "def add_item_to_array(array, item_set)\n item_id = item_set.id\n\n unless array[item_id]\n array[item_id] = [item_set]\n else\n array[item_id] << item_set\n end\n end", "def add_items(new_items)\n self.items << new_items\n # new_items.each { |i| i.customer_id = self.id }\n # self....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calculate all similarities to other items in the matrix for item1
def similarities_for(item1) # return => [ ["item23", 0.6], ["item42", 0.23], (...) ] raise "implemented in subclass" end
[ "def similarity_by_euclidean_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n \n result = 0.0\n return result if common_users.size < 1\n \n common_users.each do |u|\n result += (u.rating_for(item1.id) - u.rating_for(item2.id))*...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
embed video, calculates embed iframe by urls from various simple formats, but not accept iframe code
def parse_video # standard unless /\A\s*(?<width>\d+)x(?<height>\d+)\s+(?<url>.+)\z/ =~ content env.warn 'can not parse \video content, should be "#{WIDTH}x#{HEIGHT} #{URL}"' return end case url when /youtu\.?be/ # NOTE merging them into one regexp fails (because l...
[ "def embedded_video s\n %(<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/#{video_id s}?rel=0\" frameborder=\"0\" allowfullscreen></iframe>)\n end", "def embed_url\n video_url = params[:video_url]\n video = VideoInfo.get(video_url)\n if(video)\n embed_url = video.embed_u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Define a single reference into _pool_ from _data_ beginning at _start_
def initialize(pool, data, start, name=nil) super(name) @tag = data.u1(start) @enclosing_pool = pool @first_index = data.u2(start+1) end
[ "def pool \n @pool\n end", "def redis_pool=(_arg0); end", "def preconnect(_concurrent = false)\n @pool.fill!\n end", "def initialize(pool)\n @pool = pool\n end", "def pool(node)\n MUTEX.synchronize do\n pools[node.address.resolved] ||= create_pool(node)\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a reference _ref_ from the +enclosing_pool+
def get(ref) @enclosing_pool[ref].to_s end
[ "def pool\n parent || pool\n end", "def weak_ref_value(o)\n if o && o.weakref_alive?\n o\n end\n end", "def pool \n @pool\n end", "def get_pool_manager(owner); end", "def read_pool\n @primary_pool\n end", "def owner_to_pool_manager; end", "def getConnectio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all relationships that are manytoone for this model. Used to find the relationships that require properties in any Repository. Example: class Plur include DataMapper::Resource def self.default_repository_name :plur_db end repository(:plupp_db) do has 1, :plupp end end This resource has a manytoone to the Plupp ...
def many_to_one_relationships relationships unless @relationships # needs to be initialized! @relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end end
[ "def relationships\n model.relationships(repository.name)\n end", "def relationships\n @relationships ||= Relationship.from_associations(self, associations)\n end", "def relationships\n links = Link.all_from_active_record(self)\n @relationships ||= Relationship.all_from_links(l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /food_products POST /food_products.json
def create @food_product = FoodProduct.new(food_product_params) respond_to do |format| if @food_product.save format.html { redirect_to @food_product, notice: 'Food product was successfully created.' } format.json { render :show, status: :created, location: @food_product } else ...
[ "def create\n @food_product = FoodProduct.new(food_product_params)\n\n respond_to do |format|\n if @food_product.save\n format.html { redirect_to @food_product, notice: \"Food product was successfully created.\" }\n format.json { render :show, status: :created, location: @food_product }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /food_products/1 DELETE /food_products/1.json
def destroy @food_product.destroy respond_to do |format| format.html { redirect_to food_products_url, notice: 'Food product was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @productos_json.destroy\n respond_to do |format|\n format.html { redirect_to productos_jsons_url }\n format.json { head :no_content }\n end\n end", "def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end", "def destroy\n @food = Food.find(params[:id])...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /components or /components.json
def create @component = Component.new(component_params) respond_to do |format| if @component.save format.html { redirect_to @component, notice: "Component was successfully created." } format.json { render :show, status: :created, location: @component } else format.html { ren...
[ "def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end", "def create\n @component = Component.new(compo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /components/1 or /components/1.json
def update respond_to do |format| if @component.update_attributes(component_params) format.html { redirect_to @component, notice: "Component was successfully updated." } format.json { render :show, status: :ok, location: @component } else format.html { render :edit, status: :unpr...
[ "def update\n @component = service.components.find_by!(slug: params[:id])\n\n if @component.update(component_params)\n head :no_content\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end", "def update\n @component = Admin::Component.find(params[:id])\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Placeholder for ack received. You must override hsdq_request in your HsdqXxx class
def hsdq_ack(message, context); placeholder; end
[ "def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end", "def receive_ack\n case @state\n when :proceeding\n log_system_debug \"ACK received during proceeding state, ignoring it\" if $oversip_debu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Placeholder for callback received. You must override hsdq_request in your HsdqXxx class
def hsdq_callback(message, context); placeholder; end
[ "def register_request_callback; end", "def callback; end", "def tmp_dh_callback(*) end", "def on_request &b\n @request_proc = b\n self\n end", "def on_request\n manager._run_callbacks(:on_request, self)\n end", "def send_channel_request(request_name, *data, &callback); end", "def re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Placeholder for feedback received. You must override hsdq_request in your HsdqXxx class
def hsdq_feedback(message, context); placeholder; end
[ "def hsdq_callback(message, context); placeholder; end", "def hsdq_ack(message, context); placeholder; end", "def hsdq_error(message, context); placeholder; end", "def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end", "def feedback\n end", "def ask\n @poll_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Placeholder for error received. You must override hsdq_request in your HsdqXxx class
def hsdq_error(message, context); placeholder; end
[ "def _452(request)\n raise RubyRabbitmqJanus::Errors::Janus::Responses::MissingRequest, request\n end", "def error\n @error_response\n end", "def connection_error(error, req, text = T.unsafe(nil)); end", "def on_empty_request\n ResponseLite.new(:error=>\"empty request\")\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If there is no context this method is used instead of pull_burst
def pull_burst_only(burst_p) [burst_p.call, nil] end
[ "def drill_with_depth args={}, &blck\n\t\targs[:start_depth] ||= (args.has_key?(:no_self_call) ? -1 : 0)\n\t\tblck.call self, args[:start_depth] unless args.has_key? :no_self_call\n\t\t@children.each do |child|\n\t\t\tchild.drill_with_depth(\n\t\t\t\t\t{:start_depth\t=> args[:start_depth] + 1},\n\t\t\t\t\t&blck\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Call whitelisted? to verify the the topic and task are legit.
def check_whitelist(spark, options) begin whitelisted?(spark, options) ? true : (raise ArgumentError.new("Illegal argument in topic or task")) rescue => e reject_spark spark, e false end end
[ "def can_be_blacklisted?\n !self.blacklisted?\n end", "def check_exists\n name = test_topic_name\n p \"... checking for topic #{name}\"\n exists = topic_exists?(name)\n p \"#{name} is a topic\" if exists\n p \"#{name} is not a topic\" unless exists\n rescue GRPC::BadStatus => e\n p \"Could ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
updating the locationerror and itemerror after deleting records from the upload screen
def update_errormaintenance case self.upload_filename when 'Location.csv' location_error = Locationerror.destroy_all(uploadfile_id: self.id) when 'Item.csv' item_error = Itemerror.destroy_all(uploadfile_id: self.id) end end
[ "def delete_errors\n @c.get_data(:delete_errors)\n end", "def update_errors\n @c.get_data(:update_errors)\n end", "def update_location_error(params)\n location_error(:edit_location, params)\n end", "def deletion_results\n # User selected cancel\n if params[:commit].eql?('Cancel')\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def logger= Wrap SizedQueuepush with a timer metric.
def push(*args) @metric_queue_write.time do super(*args) end end
[ "def queue_time_ms; end", "def log_queue(value)\n STDOUT.puts(\"[hirefire:router] queue=#{get_queue(value)}ms\")\n end", "def push_time_updates\n @log.debug(\"Pushing timelogs.\")\n @ob.static(:Timelog, :push_time_updates, {:oata => self})\n end", "def send_metric(metric)\n key = sprintf '%s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Return level of nesting for this Scope. Note that this is recursive calling Parentnesting. =end
def nesting @parent ? @parent.nesting + 1 : 1 end
[ "def nesting_depth\n @nesting_depth ||= nesting.split(/::/).length\n end", "def depth\n level = 0\n scopelist=[]\n if (doe_scope == \"hvac\")\n scopelist = @hvacLevel\n else\n scopelist = @envelopeLevel\n end\n scopelist.each_index do |index|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Return list of symbols defined in this scope. If recurse is true, all child scopes are included as well. =end
def symbols(names_only=false, recurse=false) symtab = recurse ? @children.map { |c| c.symbols(names_only, true) }.flatten : [] names_only ? @symtab.keys.concat(symtab) : @symtab.values.concat(symtab) end
[ "def symbols\n @symbol_set.symbols\n end", "def symbols() @symbols end", "def namespaces(recurse=false)\n symbols(false, recurse).map { |s| s.namespace }.sort.uniq\n end", "def each_namespaced_symbol\n self.nested_symbols.inject([]) do |name, symbol|\n name << symbol\n yield name....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Return a list of all namespaces defined in this scope. If recurse is true, all child scopes are included as well. =end
def namespaces(recurse=false) symbols(false, recurse).map { |s| s.namespace }.sort.uniq end
[ "def namespaces\n root ? root.collect_namespaces : {}\n end", "def namespace_scopes()\n #This is a stub, used for indexing\n end", "def namespaces ns = \"root\", cn = \"__Namespace\"\n result = []\n each_instance( ns, cn ) do |inst|\n name = \"#{ns}/#{inst.Name}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Return number of symbols defined in this scope. =end
def num_symbols @symtab.keys.count end
[ "def variable_count\n variables.keys.length\n end", "def size\n entries = 0\n\n @symbol_table.each_pair do |k,v|\n entries += v.length\n end\n\n return entries\n end", "def used_namespace_symbols\r\n\t\t\treturn @from_code_namespace_symbol_usage_count.keys\r\n\t\tend", "def num_sym_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Define a symbol for function 'name' at location 'value' in scope. =end
def define_func(name, value, namespace=nil) define(CodeSymbol.new name, value, namespace) end
[ "def symfun name\n Symbolic.check_name name\n fs = SymbolicFunction.new(name)\n meta_def name do\n fs\n end\n fs\n end", "def use_function(name)\n call \"_#{name}\"\n end", "def named_function(name, *args)\n ::Arel::Nodes::NamedFunction.new(name.to_s, args)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Resolve name to a Symbol object. This recurses to Parentresolve if necessary. =end
def resolve(name) #FIXME: how to handle namespace @symtab[name] || (parent ? parent.resolve(name) : nil) end
[ "def resolve!(name)\n raise UnresolvedSymbol if not resolve(name) \n end", "def resolve_name(name)\n resolve_name_with_call_id(@node_name, @ns, name, @remappings)\n end", "def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin rdoc Resolve name to a Symbol object, raising an UnresolvedSymbol error if the symbol is not defined. This recurses to Parentresolve if necessary. =end
def resolve!(name) raise UnresolvedSymbol if not resolve(name) end
[ "def resolve(name)\n #FIXME: how to handle namespace\n @symtab[name] || (parent ? parent.resolve(name) : nil)\n end", "def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Using the Ruby language, have the function SymmetricTree(strArr) take the array of strings stored in strArr, which will represent a binary tree, and determine if the tree is symmetric (a mirror image of itself). The array will be implemented similar to how a binary heap is implemented, except the tree may not be comple...
def symmetric_tree(arr) rows = Hash.new([]) n = 0 until arr.empty? (2**n).times { rows[n] += [arr.shift] } n += 1 end rows.values.each do |row| return false unless row == row.reverse end true end
[ "def is_symmetric root\n queue = []\n queue << root if root\n\n while !queue.empty?\n level_size = queue.size\n level_str = \"\"\n\n while !level_size.zero?\n current_node = queue.shift\n level_str << current_node.val.to_s\n\n if current_node.left\n queue << current_node.left\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /diningts GET /diningts.json
def index @diningts = Diningt.all end
[ "def index\n @dusts = Dust.all\n render json: @dusts\n end", "def index\n @dances = current_user.dances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dances }\n end\n end", "def show\n @dining_table = DiningTable.find(params[:id])\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /diningts POST /diningts.json
def create @diningt = Diningt.new(diningt_params) respond_to do |format| if @diningt.save format.html { redirect_to @diningt, notice: 'Diningt was successfully created.' } format.json { render :show, status: :created, location: @diningt } else format.html { render :new } ...
[ "def create\n @dino = Dino.new(dino_params)\n\n if @dino.save\n render json: @dino, status: :created, location: @dino\n else\n render json: @dino.errors, status: :unprocessable_entity\n end\n end", "def create\n @dining_table = DiningTable.new(params[:dining_table])\n\n respond_to do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
choose the correct book layout
def books_layout if params[:action] == 'show' 'reading' elsif params[:action] == 'edit' || params[:action] == 'new' 'writing' else 'application' end end
[ "def layout_for(document); end", "def prepare_document\n case @document.layout\n when '' \n end\n end", "def book_pages\n\t\t@book = {\n\t\t\t\t\"sketch\" =>\n\t\t\t\t\"\t\t\t\t------------------------------------------\n\t\t\t\t| |\n\t\t\t\t| ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The ShareThis widget defines a bunch of attributes you can customize. Facebook seems to ignore them (it uses title and description meta tags instead). MySpace, however, only works if you set these attributes.
def sharethis_options(post) content_tag :script, :type=>"text/javascript" do <<-eos SHARETHIS.addEntry({ title:'#{escape_javascript(post.title)}', content:'#{escape_javascript(truncate_words(post.post, 75, '...' ))}' }, {button:true}); eos end end
[ "def meta_share(title = nil, description = nil, image = nil)\n title = title || @item[:meta_title] || @config[:site][:meta_title]\n description = description || @item[:meta_description] || @config[:site][:meta_description]\n image = image || @item[:meta_image] || @config[:site][:meta_image]\n\n \"<meta ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
builds up a template header with given informatations
def buildup_template_header(basename, hash) header = [] type = hash[:type] || :script header << filename_for(basename, type) header << "" description = hash[:description] || "no description" header << teardown_to_oneline(description) header << "" date = hash[:date] || Tim...
[ "def output_template_header( template )\n\t\theader_info = \"%s (%0.2fK, %s)\" %\n\t\t\t[ template.source_file, template.source.bytesize/1024.0, template.source.encoding ]\n\t\theader_line = \"-- %s\" % [ header_info ]\n\t\tself.prompt.say( self.prompt.color(header_line, :bold, :white) )\n\tend", "def generate_he...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate initial map that only consist of wall
def generate_initial_map for _ in 0...@height temp = [] for _ in 0...@width temp.push(@WALL) end @map.push(temp) end end
[ "def generate_walls (map)\n @walls = Array.new\n\n #Build top and bottom walls\n col = 0\n while in_x_bounds(col)\n wall1 = Wall.new(col, 0)\n wall2 = Wall.new(col, $MAP_HEIGHT - 1)\n\n map[0][col] = wall1\n map[$MAP_HEIGHT - 1][col] = wall2\n\n @walls << wall1\n @walls << ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clear unnecessary wall tht only have < 2 surrounding wall
def clear_small_wall for row_i in 1...@height - 1 for column_i in 1...@width - 1 total_wall = count_adjacent_wall(row_i, column_i) if @map[row_i][column_i] == @WALL if total_wall < 2 @map[row_i][column_i] = @FLOOR ...
[ "def remove_extra_walls\n a_count_number = $cells.length/2/5\n while a_count_number > 0 do\n cell_index = rand(0..$cells.length/2)\n remove_walls($cells[cell_index], $cells[cell_index+1])\n a_count_number -= 1\n end\n end", "def remove_wall(x, y, choice)\n case choice\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Put user on given coordinate
def put_user(coord) x_position = coord[0] y_position = coord[1] if !((0 < x_position && x_position < @width - 1) && (0 < y_position && y_position < @height - 1)) raise RangeError.new("User coordinate out of map size bound") end for row in [-1, 0, 1] for co...
[ "def update_coordinates\n if !current_user.nil?\n geo_result = Geocoder.search(current_user.address + ', ' + current_user.city)\n if !geo_result.empty?\n mfactory = RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(:geo_type => 'point')\n current_user.update(coordinates: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joining the cave rooms
def join_rooms all_caves = populate_caves for cave in all_caves.keys() join_points(all_caves[cave][0]) end end
[ "def join_room(id)\n @rooms.join id\n end", "def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end", "def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n role = @room.user_ro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find the nearest path to user from the given coordinate It will return the shortest path to the user
def shortest_path_to_user(start_coord) queue = Queue.new queue << [start_coord] seen = Set.new([start_coord]) while queue begin path = queue.pop(non_block = true) rescue ThreadError return nil end x, y = path...
[ "def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find the nearest driver from given coordinate It will return a hash about the nearest driver coordinate, driver object, and the shortest route to the driver
def nearest_driver(coord_from) queue = Queue.new queue << [coord_from] seen = Set.new([coord_from]) while queue begin path = queue.pop(non_block = true) rescue ThreadError return nil end x, y = path[-1] ...
[ "def getNearestDriver\r\n\t\tnearestDriver = nil\r\n\t\tnearestDistance = 99999\r\n\t\tu = @user.coordinate\r\n\t\t@drivers.each do |d|\r\n\t\t\tdRadius = (u.x - d.coordinate.x).abs + (u.y - d.coordinate.y).abs\r\n\t\t\tif dRadius < nearestDistance\r\n\t\t\t\tnearestDistance = dRadius\r\n\t\t\t\tnearestDriver = d \...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Put an object randomly on map floor
def put_random(object) while true random_row = rand(1...@height - 1) random_column = rand(1...@width - 1) if @map[random_row][random_column] == @FLOOR @map[random_row][random_column] = object return [random_column, random_row] end ...
[ "def place_oject_randomly(object)\n while is_wall?(object.location)\n object.location_x = 1 + rand(width - 1)\n\n object.location_y = 1 + rand(height - 1)\n end\n\n objects << object\n end", "def create_random_world\n randomize_terrain\n randomize_entities\n end", "def newfloor\n # w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete driver from the map
def delete_driver(driver_coord) @drivers.delete_if do |driver| driver["coord"] == driver_coord end x, y = driver_coord @map[y][x] = @FLOOR end
[ "def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end", "def destroy\n driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def delete(name)\n @driver.deletePool([name])\n end", "def de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Omniauth callback handler when using force_authentication
def auth_callback current_user omniauth_origin = session[:omniauth_origin] session.delete(:omniauth_origin) redirect_to omniauth_origin || '/' end
[ "def omniauth(provider, *args); end", "def after_custom_authentication; end", "def default_oauth_callback(&on_fail)\n auth = request.env['omniauth.auth']\n\n @user = User.send(\"find_for_#{auth.provider.to_s}_oauth\", auth, current_user)\n unless @user.persisted?\n # save oauth data if user creati...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Extract omniauth credentials from the request environment
def omniauth_credentials if omniauth_hash = request.env['omniauth.auth'] { provider: omniauth_hash['provider'], uid: omniauth_hash['uid'], email: omniauth_hash['info']['email'], name: omniauth_hash['info']['name'], } else nil end end
[ "def auth_hash\n request.env['omniauth.auth']\n end", "def omniauth_data\n request.env[\"omniauth.auth\"]\n end", "def auth_info\n request.env[\"omniauth.auth\"]\n end", "def credentials\n auth_hash['credentials']\n end", "def credentials\n auth_hash['credentials']\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load Erector library if not already loaded.
def require_engine return if defined? ::Erector require_library 'erector' end
[ "def require_engine\n return if defined? ::Radius\n require_library 'radius'\n end", "def require_engine\n return if defined? ::Creole\n require_library 'creole'\n end", "def set_up_libraries\n R.eval <<-EOR\n EOR\n end", "def load_library\n raise NotImplementedError, \"l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return user answer for a multichoice question as a label (a, b, c, etc.)
def answerLabel(question) if question.input.is_a? org.concord.otrunk.ui.OTChoice return choiceLabel(question.input, currentChoice(question.input)) else return questionAnswer(question) end end
[ "def answerLabel(question) \n if question.input.is_a? org.concord.otrunk.ui.OTChoice\n \treturn choiceLabel(question.input, question.input.currentChoice)\n else\n \treturn questionAnswer(question)\n end\nend", "def answerLabel(question) \n if question.input.is_a? org.concord.otrunk.ui.OTChoice\n retu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Go through the IMAP server and checks for new neurons to be added
def checkbrainmailbox #Check if token is present logger.info params["token"] if APP_CONFIG['token_action'].to_s == params["token"] #Start the actual work imap = Net::IMAP.new(APP_CONFIG['imap_host'], APP_CONFIG['imap_port'] , APP_CONFIG['imap_ssl'], nil, false) imap.authenticate('LOGIN', A...
[ "def check_for_new_connections(notify)\r\n netstat_output = `netstat -na`\r\n for connection_entry in netstat_output do\r\n if connection_entry.include?(\"ESTABLISHED\")\r\n connection = Connection.new(connection_entry)\r\n\r\n if connection.local_port != nil && @ports.include? (connec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /corpora/1 GET /corpora/1.json
def show @corpus = Corpus.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @corpus } end end
[ "def index\n @corpora = Corpus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corpora }\n end\n end", "def index\n @corpora = Corpus.all\n end", "def index\n @corporations = Corporation.all\n\n respond_to do |format|\n format.html #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /corpora/new GET /corpora/new.json
def new @corpus = Corpus.new respond_to do |format| format.html # new.html.erb format.json { render json: @corpus } end end
[ "def new\n @corporation = Corporation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corporation }\n end\n end", "def new\n @corporation = Corporation.new\n @page_header = \"Добавление новой Корпорации\"\n\n respond_to do |format|\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /corpora/1 DELETE /corpora/1.json
def destroy @corpus = Corpus.find(params[:id]) @corpus.destroy respond_to do |format| format.html { redirect_to corpora_url } format.json { head :ok } end end
[ "def destroy\n @corp.destroy\n respond_to do |format|\n format.html { redirect_to corps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @corpus = Corpus.find(params[:id])\n @corpus.destroy\n\n respond_to do |format|\n format.html { redirect_to corpora_url }\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
param row is the row of the center block param col is the column of the center block return the Block array that represents the rotated Tetromino
def getRotatedBlocks(row, col) return [ Block.new(row, col), Block.new(row + 1, col), Block.new(row, col + 1), Block.new(row - 1, col + 1) ] end
[ "def getRotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row - 1, col),\n Block.new(row + 1, col),\n Block.new(row + 2, col)\n ]\n end", "def getUnrotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row + 1, col),\n Block.new(row ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
param row is the row of the center block param col is the column of the center block return the Block array that represents the unrotated Tetromino
def getUnrotatedBlocks(row, col) return [ Block.new(row, col), Block.new(row + 1, col), Block.new(row + 1, col + 1), Block.new(row, col - 1) ] end
[ "def getUnrotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row, col - 1),\n Block.new(row, col + 1),\n Block.new(row, col + 2)\n ]\n end", "def getRotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row - 1, col),\n Block.new(row ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called to remove the +fd+ from the poller and delete any callbacks
def deregister(fd:) delete_from_selector(fd: fd) delete_callbacks(fd: fd) end
[ "def pop_writable(fd)\n @write_polls.pop(Integer(fd))\n end", "def remove_handler\n @handler = nil\n @running = false\n change_info\n send_message_all \"Service terminating...\"\n end", "def deregister_readable pollable\n deregister pollable, ZMQ::POLLIN\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /inputs GET /inputs.json
def index @inputs = Input.all respond_to do |format| format.html # index.html.erb format.json { render json: @inputs } end end
[ "def inputs\n @inputs ||= JSON.parse(inputs_json || \"null\")\n end", "def index\n @inputs = Input.all\n end", "def show\n @input = Input.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @input }\n end\n end", "def GET(inputs)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /inputs/new GET /inputs/new.json
def new @input = Input.new respond_to do |format| format.html # new.html.erb format.json { render json: @input } end end
[ "def new\n @input_output = InputOutput.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @input_output }\n end\n end", "def new\n @input = Input.new params[:input]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { ren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /inputs/1 DELETE /inputs/1.json
def destroy @input = Input.find(params[:id]) @input.destroy respond_to do |format| format.html { redirect_to inputs_url } format.json { head :ok } end end
[ "def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.html { redirect_to inputs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @input.destroy\n respond_to do |format|\n format.html { redirect_to inputs_url }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /magazines GET /magazines.json
def index @magazines = Magazine.all end
[ "def show\n @magazines_serie = MagazinesSerie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magazines_serie }\n end\n end", "def show\n @magagine = Magagine.find(params[:id])\n\n respond_to do |format|\n format.html # show.h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of numbers needed to calculate the factorial for a given number
def numbers_to_calculate_factorial(number) factorials = [number] number.times do if number > 1 # <-- ensures 0 is not pushed into the factorials array factorials << number - 1 number -= 1 end end factorials end
[ "def factorions()\n # Initialize an array of factorials with index n giving the nth factorial.\n fac = (0..9).map { |i| if i.zero? then 1 else (1..i).reduce(:*) end }\n\n # This is the lowest upper bound that can be found analytically.\n upper_bound = 1499999\n\n factorions = []\n\n 1.upto(upper_bound).each ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUBLIC METHODS Returns number of link_tracking assocations Only used for reporting purposes
def tracking_total_count link_tracking.count end
[ "def link_count\n raw_links.size\n end", "def link_count\n raw_links.size + @onebox_urls.size\n end", "def reference_count\n reference_ids.count\n end", "def number_of_internal_links_to_page(link)\n @ilps[link]\n end", "def total_link_count\n @sitemaps_link_count\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates comma seperated list of subjects.
def subject_list list = [] subjects.each { |subject| list << subject.name } list.to_sentence end
[ "def format_final_subject(subjects)\n if subjects.size == 1\n subjects[0]\n elsif subjects.size == 2\n subjects[0] + ' and ' + subjects[1]\n else\n last_subject = subjects.pop()\n subjects.join(', ') + ' and ' + last_subject\n end\n end", "def subjects\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates comma seperated list of resources.
def resource_list list = [] resources.each { |rss| list << rss.name } list.to_sentence end
[ "def generate_resources_list\n resources = chefsorted_objects(:resource)\n generate_full_list(resources, 'Resource', 'resources')\nend", "def list\n puts local_resources.map { |name, resource| name }.join(\" \")\n end", "def manipulate_resource_list(resources)\n resources + apps_list\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls the association for vendor unless nil, and returns the vendors name.
def vendor_name vendor&.name end
[ "def vendor_name\n vendor.name if vendor\n end", "def vendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end", "def getVendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end", "def vendor\n FarMar::Vendor.find(@vendor_id)\n end", "def vendor\n @vendor |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see if the campus only designation is set
def campus_only? access == 'Campus Only Access (No Proxy)' end
[ "def design_data_filled_in?\n !self.description.blank? && \n !self.platform.blank? && \n !self.product_type.blank? && \n !self.project.blank? &&\n !self.design_directory.blank? &&\n !self.incoming_directory.blank?\n end", "def designer_only?\n self.check_type == 'designer_only'\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash to use in the lib_guides CSV. LibGuides requries the use of these fields vendor name url enable_proxy description more_info enable_new enable_trial types keywords target slug best_bets subjects desc_pos lib_note enable_popular enable_hidden internal_note owner resource_icons thumbnail content_id
def csv_hash { vendor: self.vendor_name, name: self.name, url: self.url, enable_proxy: self.access == 2 ? 1 : 0, description: self.description, more_info: '', enable_new: self.new_database.to_i, enable_trial: self.trial_database.to_i, types: self.resources.pluck...
[ "def preference_items_hash\n @preference_items_hash ||= {\n # Mission page table headers and visibilities\n # [1, \"Mission\", \"Column\", \"title\", \"Mission\", true],\n # [2, \"Mission\", \"Column\", \"tag\", \"Tag\", true],\n # [3, \"Mission\", \"Column\", \"exp\", \"Max E...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash to use in the link_tracking CSV. name tracking_count
def link_tracking_csv_hash { name: self.name, count: self.tracking_count } end
[ "def link_tracking_all_csv_hash\n {\n name: self.name,\n count: self.tracking_total_count\n }\n end", "def tracking_total_count\n link_tracking.count\n end", "def to_hash\n @counts.clone\n end", "def create_count_hash( tag, ticket_id)\n\t\tcount_hash = {}\n\t\tcount_hash[ 'tag' ] = ta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash to use in the link_tracking CSV. name tracking_count
def link_tracking_all_csv_hash { name: self.name, count: self.tracking_total_count } end
[ "def link_tracking_csv_hash\n {\n name: self.name,\n count: self.tracking_count\n }\n end", "def tracking_total_count\n link_tracking.count\n end", "def to_hash\n @counts.clone\n end", "def create_count_hash( tag, ticket_id)\n\t\tcount_hash = {}\n\t\tcount_hash[ 'tag' ] = tag\n\t\tcou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Minting a UUID creates a uuid for the record to use as a stable URL.
def mint_uuid self.url_uuid ||= Time.now.to_i end
[ "def assign_uuid\n self.id = UUIDTools::UUID.timestamp_create().to_s\n end", "def olduuid uuid\n\trf = uuid\n\trf.insert(8, \"-\")\n\trf.insert(13, \"-\")\n\trf.insert(18, \"-\")\n\trf.insert(23, \"-\")\n\treturn rf\nend", "def add_uuid\n self.uuid ||= UUIDTools::UUID.timestamp_create().to_s\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sanitize the Description field
def sanitize_description self.description = Sanitize.fragment(self.description, Sanitize::Config::BASIC) end
[ "def sanitized_description\n @sanitized_description ||= (self.description || '').gsub(/(?<!cdn\\.)(?<!cdn-prd-)maestrano(?!\\.com)/i,MnoEnterprise.app_name)\n end", "def raw_description\n if self.description\n Helper.strip_html(self.description).gsub(/\\s+/, \" \").strip\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /address_ranges GET /address_ranges.xml
def index @address_ranges = AddressRange.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @address_ranges } end end
[ "def show\n @address_range = AddressRange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @address_range }\n end\n end", "def addresses\n query(:address)\n end", "def addresses\n @client.request('getaddressesbyaccount...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }