#generates a n digit pin
5996
public static function generate_pin($length = 8)
    {
        $factory = new \RandomLib\Factory;
        $generator = $factory->getLowStrengthGenerator();
        #--with easy to speak letters
        #$alfabet = range('A', 'Z');
        #$consonants = array_diff($alfabet, array('Y', 'H', 'W', 'Q', 'C')) ;
        #$chars = implode('',$consonants);
        #--full
        #$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-#';
        #--only numbers
        $chars = '0123456789';
        $randomString = $generator->generateString($length, $chars);
        return $randomString;
    }
472000
def Pad(self, n):
        """"""
        for i in range_func(n):
            self.Place(0, N.Uint8Flags)
1116992
def _generate_number(self, prefix, length):
        
        number = prefix
        # Generate random char digits
        number += '#' * (length - len(prefix) - 1)
        number = self.numerify(number)
        reverse = number[::-1]
        # Calculate sum
        tot = 0
        pos = 0
        while pos < length - 1:
            tot += Provider.luhn_lookup[reverse[pos]]
            if pos != (length - 2):
                tot += int(reverse[pos + 1])
            pos += 2
        # Calculate check digit
        check_digit = (10 - (tot % 10)) % 10
        number += str(check_digit)
        return number
365080
function d2h(d, digits) {
  d = d.toString(16); 
  while (d.length < digits) {
		d = '0' + d;
	}
	  
  return d;
}
793637
public void append24(int bits) {
        long l;
        long[] a1;
        l = ((l = crc) >> 8L) ^ (a1 = CRC32_TABLE)[(int) ((l & 0xFF) ^ (long) (bits & 0xFF))];
        l = (l >> 8L) ^ a1[(int) ((l & 0xFF) ^ (long) ((bits & 0xff00) >> 8))];
        crc = (l >> 8L) ^ a1[(int) ((l & 0xFF) ^ (long) ((bits & 0xff0000) >> 16))];
    }
897451
def pins(id = nil, options = {}, &_block)
      id, options = nil, id if id.is_a?(Hash)
      if id
        pin = Origen.pin_bank.find(id, options)
        unless pin
          puts <<-END
You have tried to reference pin :#{id} within #{self.class} but it does not exist, this could be
because the pin has not been defined yet or it is an alias that is not available in the current context.

If you meant to define the pin then use the add_pin method instead.

          END
          fail 'Pin not found'
        end
        pin
      else
        if options[:power_pin]
          Origen.pin_bank.power_pins
        elsif options[:ground_pin]
          Origen.pin_bank.ground_pins
        elsif options[:virtual_pin]
          Origen.pin_bank.virtual_pins
        elsif options[:other_pin]
          Origen.pin_bank.other_pins
        else
          Origen.pin_bank.pins
        end
      end
    end
517027
function numToDigits(num) {
	var digits = num.toString().split('');
	for (var i = 0; i < digits.length; i++) {
		digits[i] = +digits[i];
	}
	digits.reverse();
	return digits;
}
17858
async function generateMachineKey () {
  let parts = await Promise.all([
    randomHex(8),
    randomHex(4),
    randomHex(4),
    randomHex(4),
    randomHex(12)
  ])
  return `${parts[0]}-${parts[1]}-${parts[2]}-${parts[3]}-${parts[4]}`
}
694557
function(digit) {
			var obj = this.createList(digit, {
				classes: {
					active: this.factory.classes.active,
					before: this.factory.classes.before,
					flip: this.factory.classes.flip
				}
			});

			this.appendDigitToClock(obj);
		}
921821
def pin_command(self):
        """"""
        parts = [
            'pip-compile',
            '--no-header',
            '--verbose',
            '--rebuild',
            '--no-index',
            '--output-file', self.outfile,
            self.infile,
        ]
        if OPTIONS['upgrade']:
            parts.insert(3, '--upgrade')
        if self.add_hashes:
            parts.insert(1, '--generate-hashes')
        return parts
905561
function writeFixed32 (num, buf, offset) {
  buf.writeUInt16BE(Math.floor(num) % (256 * 256), offset)
  buf.writeUInt16BE(Math.floor(num * 256 * 256) % (256 * 256), offset + 2)
}
731685
function getPinIdFromUrl(pinUrl) {
    var startIndex = pinUrl.indexOf('pin/') + 4;
    var endIndex = pinUrl.indexOf('/', startIndex);
    endIndex = endIndex === -1 ? pinUrl.length + 1 : endIndex;
    return pinUrl.slice(startIndex, endIndex);
}
482433
def parse_port_pin(name_str):
    """"""
    if len(name_str) < 3:
        raise ValueError("Expecting pin name to be at least 3 charcters.")
    if name_str[0] != 'P':
        raise ValueError("Expecting pin name to start with P")
    if name_str[1] < 'A' or name_str[1] > 'K':
        raise ValueError("Expecting pin port to be between A and K")
    port = ord(name_str[1]) - ord('A')
    pin_str = name_str[2:]
    if not pin_str.isdigit():
        raise ValueError("Expecting numeric pin number.")
    return (port, int(pin_str))
988904
def gen_n_random_num(n, MAX_NUM=MAX_INT, unique=True):
    
    fmt = "<%dI" % n
    t = struct.calcsize(fmt)
    D = [d % MAX_NUM for d in struct.unpack(fmt, os.urandom(t))]
    if unique:
        D = set(D)
        assert MAX_NUM > n, \
            "Cannot have {0} unique integers less than {1}".format(n, MAX_NUM)
        while len(D) < n:
            print("Number of collision: {}. Regenerating!".format(n - len(D)))
            fmt = "<%dI" % (n - len(D))
            t = struct.calcsize(fmt)
            extra = struct.unpack(fmt, os.urandom(t))
            D |= set(d % MAX_NUM for d in extra)
        D = list(D)
    return D
420427
def read(pin):
    '''
    '''
    f = _open[pin].value
    out = int(_read(f))
    log.debug("Read {0}: {1}".format(pin, out))
    return out
859271
def node_numerate(name, num, count)
      digits = count.to_s.length + 1
      pad = sprintf("%0#{digits}i", num)
      name.gsub(/\{\{n\}\}/, pad)
    end
1225668
def itn(n, digits=8, format=DEFAULT_FORMAT):
    
    # POSIX 1003.1-1988 requires numbers to be encoded as a string of
    # octal digits followed by a null-byte, this allows values up to
    # (8**(digits-1))-1. GNU tar allows storing numbers greater than
    # that if necessary. A leading 0o200 byte indicates this particular
    # encoding, the following digits-1 bytes are a big-endian
    # representation. This allows values up to (256**(digits-1))-1.
    if 0 <= n < 8 ** (digits - 1):
        s = ("%0*o" % (digits - 1, n)).encode("ascii") + NUL
    else:
        if format != GNU_FORMAT or n >= 256 ** (digits - 1):
            raise ValueError("overflow in number field")

        if n < 0:
            # XXX We mimic GNU tar's behaviour with negative numbers,
            # this could raise OverflowError.
            n = struct.unpack("L", struct.pack("l", n))[0]

        s = bytearray()
        for i in range(digits - 1):
            s.insert(0, n & 0o377)
            n >>= 8
        s.insert(0, 0o200)
    return s