Finds a machine where the UUID is prefixed by the given string.

 @return [Hash]
358812
def find_by_prefix(prefix)
      @machines.each do |uuid, data|
        return data.merge("id" => uuid) if uuid.start_with?(prefix)
      end

      nil
    end
46853
def core__get_string_inside_strings(string, marker1, marker2)
      string[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
    end
303973
def lchop(string, prefix):
    
    if string.startswith(prefix):
        return string[len(prefix):]
    return string
713493
def get_udim(cls, name):
        
        match = cls._get_regex_search(name, cls.REGEX_UDIM, match_index=-1)
        if match:
            match.update({'match_int': int(match['match'])})
            return match
        return None
828404
def tokenize string
      return nil if string.empty?
      return string if @string_cache.key?(string)
      return @symbol_cache[string] if @symbol_cache.key?(string)

      case string
      # Check for a String type, being careful not to get caught by hash keys, hex values, and
      # special floats (e.g., -.inf).
      when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
        if string.length > 5
          @string_cache[string] = true
          return string
        end

        case string
        when /^[^ytonf~]/i
          @string_cache[string] = true
          string
        when '~', /^null$/i
          nil
        when /^(yes|true|on)$/i
          true
        when /^(no|false|off)$/i
          false
        else
          @string_cache[string] = true
          string
        end
      when TIME
        begin
          parse_time string
        rescue ArgumentError
          string
        end
      when /^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/
        require 'date'
        begin
          class_loader.date.strptime(string, '%Y-%m-%d')
        rescue ArgumentError
          string
        end
      when /^\.inf$/i
        Float::INFINITY
      when /^-\.inf$/i
        -Float::INFINITY
      when /^\.nan$/i
        Float::NAN
      when /^:./
        if string =~ /^:(["'])(.*)\1/
          @symbol_cache[string] = class_loader.symbolize($2.sub(/^:/, ''))
        else
          @symbol_cache[string] = class_loader.symbolize(string.sub(/^:/, ''))
        end
      when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}$/
        i = 0
        string.split(':').each_with_index do |n,e|
          i += (n.to_i * 60 ** (e - 2).abs)
        end
        i
      when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}\.[0-9_]*$/
        i = 0
        string.split(':').each_with_index do |n,e|
          i += (n.to_f * 60 ** (e - 2).abs)
        end
        i
      when FLOAT
        if string =~ /\A[-+]?\.\Z/
          @string_cache[string] = true
          string
        else
          Float(string.gsub(/[,_]|\.([Ee]|$)/, '\1'))
        end
      else
        int = parse_int string.gsub(/[,_]/, '')
        return int if int

        @string_cache[string] = true
        string
      end
    end
982862
def unique_string(length=UUID_LENGTH):
    ''''''
    # We need a string at least as long as length
    string = str(uuid4()) * int(math.ceil(length / float(UUID_LENGTH)))
    return string[:length] if length else string
280891
def is_uuid(u):
    """"""
    if isinstance(u, str) and u.replace('-', '') == uuid.UUID(u).hex:
        return u
    return False
602055
def nil_uuid?
      return false if self.time_low != 0
      return false if self.time_mid != 0
      return false if self.time_hi_and_version != 0
      return false if self.clock_seq_hi_and_reserved != 0
      return false if self.clock_seq_low != 0
      self.nodes.each do |node|
        return false if node != 0
      end
      return true
    end
1202399
def uuid(self, **params):

        

        digest = str(uuidlib.uuid4()).replace('-', '')
        return self.humanize(digest, **params), digest
519271
def check_replace_string_pairs_for_project_name_sub(hash)
      unless @project_name.nil?
        hash.each do |key, value|
          if key == :project_name
            hash[key] = @project_name
          end
        end
      end
      hash
    end
1298201
function uuid() {
  return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
    (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
  )
}
846192
def find_uuid(es_url, index):
    

    uid_field = None

    # Get the first item to detect the data source and raw/enriched type
    res = requests.get('%s/%s/_search?size=1' % (es_url, index))
    first_item = res.json()['hits']['hits'][0]['_source']
    fields = first_item.keys()

    if 'uuid' in fields:
        uid_field = 'uuid'
    else:
        # Non perceval backend
        uuid_value = res.json()['hits']['hits'][0]['_id']
        logging.debug("Finding unique id for %s with value %s", index, uuid_value)
        for field in fields:
            if first_item[field] == uuid_value:
                logging.debug("Found unique id for %s: %s", index, field)
                uid_field = field
                break

    if not uid_field:
        logging.error("Can not find uid field for %s. Can not copy the index.", index)
        logging.error("Try to copy it directly with elasticdump or similar.")
        sys.exit(1)

    return uid_field
997160
def parse(string)
      return nil unless string.is_a?(String)

      uri = Addressable::URI.parse(string)

      scheme = uri.scheme
      return nil unless scheme

      self.secure = true if scheme.match(/ss\Z/m)

      host = uri.host
      host = '/' unless host && host != ''
      self.host = host
      self.port = uri.port.to_s if uri.port

      request_uri = uri.path
      request_uri = '/' unless request_uri && request_uri != ''
      request_uri += "?" + uri.query if uri.query
      self.resource_name = request_uri

      return self
    end
1306592
public String findSymbol(char[] buffer, int start, int len, int hash)
    {
        // Sanity check:
        if (len < 1) {
            return EMPTY_STRING;
        }

        hash &= mIndexMask;

        String sym = mSymbols[hash];

        // Optimal case; checking existing primary symbol for hash index:
        if (sym != null) {
            // Let's inline primary String equality checking:
            if (sym.length() == len) {
                int i = 0;
                do {
                    if (sym.charAt(i) != buffer[start+i]) {
                        break;
                    }
                } while (++i < len);
                // Optimal case; primary match found
                if (i == len) {
                    return sym;
                }
            }
            // How about collision bucket?
            Bucket b = mBuckets[hash >> 1];
            if (b != null) {
                sym = b.find(buffer, start, len);
                if (sym != null) {
                    return sym;
                }
            }
        }

        // Need to expand?
        if (mSize >= mSizeThreshold) {
            rehash();
            /* Need to recalc hash; rare occurence (index mask has been
             * recalculated as part of rehash)
             */
            hash = calcHash(buffer, start, len) & mIndexMask;
        } else if (!mDirty) {
            // Or perhaps we need to do copy-on-write?
            copyArrays();
            mDirty = true;
        }
        ++mSize;

        String newSymbol = new String(buffer, start, len);
        if (mInternStrings) {
            newSymbol = newSymbol.intern();
        }
        // Ok; do we need to add primary entry, or a bucket?
        if (mSymbols[hash] == null) {
            mSymbols[hash] = newSymbol;
        } else {
            int bix = hash >> 1;
            mBuckets[bix] = new Bucket(newSymbol, mBuckets[bix]);
        }

        return newSymbol;
    }
732606
def get_random_string():
    
    
    # set up a random string to associate with the run
    hash_string = "%8x" % random.getrandbits(32)
    hash_string = hash_string.strip()
    
    # done't allow the random strings to be equivalent to a number, since
    # the LSF cluster interprets those differently from letter-containing
    # strings
    while is_number(hash_string):
        hash_string = "%8x" % random.getrandbits(32)
        hash_string = hash_string.strip()
    
    return hash_string
1132952
private int findSid(SymbolToken symToken)
    {
        int sid = symToken.getSid();
        String text = symToken.getText();

        if (sid != UNKNOWN_SYMBOL_ID)   // sid is assigned
        {
            assert text == null ||
                   text.equals(mySymbolTable.findKnownSymbol(sid));
        }
        else                            // sid is not assigned
        {
            if (mySymbolTable.isSystemTable())
            {
                // Replace current symtab with a new local symbol table
                // using the default system symtab
                mySymbolTable = myIonSystem.newLocalSymbolTable();
            }

            // Intern the new symbol and get its assigned sid
            sid = mySymbolTable.intern(text).getSid();
        }

        return sid;
    }
877911
def print_hash(key, value)
      if value.length > @width
        print_long_string value, "#{key}:"
      else
        print "#{key}:", value.cyan
      end
    end