Try to create a free nick, first by cycling through all
 available alternatives and then by appending underscores.

 @param [String] base The base nick to start trying from
 @api private
 @return [String]
 @since 2.0.0
345410
def generate_next_nick!(base = nil)
      nicks = @config.nicks || []

      if base
        # if `base` is not in our list of nicks to try, assume that it's
        # custom and just append an underscore
        if !nicks.include?(base)
          new_nick =  base + "_"
        else
          # if we have a base, try the next nick or append an
          # underscore if no more nicks are left
          new_index = nicks.index(base) + 1
          if nicks[new_index]
            new_nick = nicks[new_index]
          else
            new_nick = base + "_"
          end
        end
      else
        # if we have no base, try the first possible nick
        new_nick = @config.nicks ? @config.nicks.first : @config.nick
      end

      @config.nick = new_nick
    end
748092
def make_url(*args, **kwargs):
    """"""
    base = "/".join(args)
    if kwargs:
        return "%s?%s" % (base, urlencode(kwargs))
    else:
        return base
729836
def basic_options
      Hash[BASIC_OPTION_KEYS.map { |k| [k, send(k)] }].reject {|_,v| v.nil?}
    end
1020249
function(base){
  if(typeof base === 'undefined'){
    throw new Error("Too few arguments in RollingHash constructor");
  }else if(typeof base !== 'number'){
    throw new TypeError("Invalid argument; expected a number in RollingHash constructor");
  }
  
  // The base of the number system
  this.BASE = base;

  // The internal hash value of the window
  this.state = 0;

  // A block of expensive code we will cache in order to optimize runtime
  this.CACHE = 1;

  // The amount of digits a number can hold given the base
  // TODO: unused.. figure out why I thought I needed this
  this.BUFFER_SIZE = Math.log(base) * Math.LOG10E + 1 | 0;

  // The modular inverse of the base
  this.INVERSE_BASE = modInverse(this.BASE, PRIME_BASE) % PRIME_BASE;

  // An offset to add when calculating a modular product, to make sure it can not go negative
  this.OFFSET_IF_NEGATIVE = PRIME_BASE * this.BASE;
}
637348
def _normalize_args(action = nil, options = {})
        options = super(action, options)
        case action
        when NilClass
        when Hash
          options = action
        when String, Symbol
          action = action.to_s
          key = action.include?(?/) ? :template : :action
          options[key] = action
        else
          if action.respond_to?(:permitted?) && action.permitted?
            options = action
          else
            options[:partial] = action
          end
        end

        options
      end
1330415
def generate name, file
      require 'erb'
      template = File.read(File.join(File.dirname(__FILE__), "class_template.erb"))
      erb = ERB.new(template)
      code = erb.result(binding)
      Dir.mkdir(@basedir) unless File.directory?(@basedir)
      File.open(file, "w+") do |f|
        f.puts code
      end
    end
1153017
def better_result(base_result, result = nil)
      base_result ||= {}
      return base_result unless result

      return result unless base_result.values.find { |e| e[:possible].any? }

      return result if result.values.find { |e| e[:valid].any? }

      base_result
    end
308688
def free=(new_val)
      return nil if new_val == @free
      raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
      @free = new_val
      @need_to_update = true
    end
1141069
def create(options = {})
      request(:put) do |req|
        req.body = {
          actions: [
            add: options.merge(:alias => @name)
          ]
        }
      end
    end
32908
def try_function(name, params, returns, options={}, &def_block)
      begin
        function name, params, returns, options, &def_block
      rescue Win::Errors::NotFoundError
        "This platform does not support function #{name}"
      end
    end
1220331
def merge_base(*args)
      opts = args.last.is_a?(Hash) ? args.pop : {}

      arg_opts = opts.map { |k, v| "--#{k}" if v }.compact + args

      command('merge-base', arg_opts)
    end
878617
def html_safe_options(hash)
      hash.inject({}) do |result, (key, value)|
        result[key] = case value
          when String
            ERB::Util.h(value)
          else
            value
          end

        result
      end
    end
362630
def create(attributes_hash)
      #the tap method allows preconfigured methods and values to
      #be associated with the instance during instantiation while also automatically returning
      #the object after its creation is concluded.
      self.new.tap do |card|
        attributes_hash.each do |key, value|
          #sending the new instance the key name as a setter with the value
          card.send("#{key}=", value)
          #string interpolation is used as the method doesn't know the key name yet
          #but an = sign is implemented into the string in order to asssociate it as a setter
        end
        #saves the new instance into the database
        card.save
      end
    end
1056874
def generate!(name = default_fauxture_name, attributes = {})
      name, attributes = default_fauxture_name, name if name.is_a? Hash
      Sweatshop.create!(self, name, attributes)
    end
1219565
def FnSub(string, substitutions = nil)
      raise ArgumentError, 'The first argument passed to Fn::Sub must be a string' unless string.is_a? String

      if substitutions
        raise ArgumentError, 'The second argument passed to Fn::Sub must be a Hash' unless substitutions.is_a? Hash

        Fn.new('Sub', [string, substitutions])
      else
        Fn.new('Sub', string)
      end
    end
1144213
def base_url(klass, space_id='', resource_id=None, environment_id=None, **kwargs):
        

        url = "spaces/{0}".format(
            space_id)

        if environment_id is not None:
            url = url = "{0}/environments/{1}".format(url, environment_id)

        url = "{0}/{1}".format(
            url,
            base_path_for(klass.__name__)
        )

        if resource_id:
            url = "{0}/{1}".format(url, resource_id)

        return url
475936
def as_nick(self, name):
        
        orig = self.get_nickname()
        self.nick(name)
        try:
            yield orig
        finally:
            self.nick(orig)