Computes the ephemeral port range for a Windows system.
@return {!webdriver.promise.Promise.<{min: number, max: number}>} A promise
that will resolve with the ephemeral port range on the current system.
516391
function findWindowsPortRange() {
  var deferredRange = promise.defer();
  // First, check if we're running on XP.  If this initial command fails,
  // we just fallback on the default IANA range.
  return execute('cmd.exe /c ver').then(function(stdout) {
    if (/Windows XP/.test(stdout)) {
      // TODO: Try to read these values from the registry.
      return {min: 1025, max: 5000};
    } else {
      return execute('netsh int ipv4 show dynamicport tcp').
          then(function(stdout) {
            /* > netsh int ipv4 show dynamicport tcp
              Protocol tcp Dynamic Port Range
              ---------------------------------
              Start Port : 49152
              Number of Ports : 16384
             */
            var range = stdout.split(/\n/).filter(function(line) {
              return /.*:\s*\d+/.test(line);
            }).map(function(line) {
              return Number(line.split(/:\s*/)[1]);
            });

            return {
              min: range[0],
              max: range[0] + range[1]
            };
          });
    }
  });
}
1066842
function PromisePool(opts) {
    this._opts = {
        // Configuration options
        name:               opts.name || 'pool',
        idleTimeoutMillis:  opts.idleTimeoutMillis || 30000,
        reapInterval:       opts.reapIntervalMillis || 1000,
        drainCheckInterval: opts.drainCheckIntervalMillis || 100,
        refreshIdle:        ('refreshIdle' in opts) ? opts.refreshIdle : true,
        returnToHead:       opts.returnToHead || false,
        max:                parseInt(opts.max, 10),
        min:                parseInt(opts.min, 10),

        // Client management methods.
        create:     opts.create,
        destroy:    opts.destroy,
        validate:   opts.validate || function(){ return true; },
        onRelease:  opts.onRelease
    };

    this._availableObjects = [];
    this._waitingClients = new PriorityQueue(opts.priorityRange || 1);
    this._count = 0;
    this._removeIdleScheduled = false;
    this._removeIdleTimer = null;
    this._draining = false;

    // Prepare a logger function.
    if (opts.log instanceof Function) {
        this._log = opts.log;
    }
    else if (opts.log) {
        this._log = _logger.bind(this);
    }
    else {
        this._log = function(){};
    }

    // Clean up some of the inputs.
    this._validate = opts.validate || function(){ return true; };
    this._opts.max = Math.max(isNaN(this._opts.max) ? 1 : this._opts.max, 1);
    this._opts.min = Math.min(isNaN(this._opts.min) ? 0 : this._opts.min, this._opts.max-1);

    // Finally, ensure a minimum number of connections right out of the gate.
    _ensureMinimum.call(this);
}
921277
function(min, max) {
    return function limitVisibleY(params) {

      // Do nothing for a null viewport.
      if (params.width <= 0 || params.height <= 0) {
        return params;
      }

      // Calculate the X to Y conversion factor.
      var viewportAspectRatio = params.width / params.height;
      var factor = viewportAspectRatio / params.mediaAspectRatio;

      // Calculate the zoom value that makes the specified range fully visible.
      var maxZoom = (max - min) * factor;

      // Clamp zoom to the maximum value.
      if (params.zoom > maxZoom) {
        params.zoom = maxZoom;
      }

      // Bound Y such that the image is visible up to the range edges.
      var minY = min + 0.5 * params.zoom / factor;
      var maxY = max - 0.5 * params.zoom / factor;
      params.y = clamp(params.y, minY, maxY);

      return params;
    };
  }
1036089
private int getTargetPort() {
        int port = getVirtualPort();
        if (NOTSET == port) {
            port = (isIncoming()) ? getServiceContext().getLocalPort() : getServiceContext().getRemotePort();
        }
        return port;
    }
103421
function getrange(key, start, end, req) {
  var val = this.getKey(key, req);
  if(!val) return '';
  start = parseInt(start);
  end = parseInt(end);
  if(start < 0) start = val.length + start;
  if(end < 0) end = val.length + end;
  // TODO: buffer compat
  return (val + '').substr(start, end + 1);
}
953832
public long getRangeFrom() {
		final long limit = (liveUpdated ? database.getStorage().getClusterDataRange(current.clusterId)[1] : firstClusterPosition) - 1;
		if (rangeFrom > -1)
			return Math.max(rangeFrom, limit);
		return limit;
	}
198555
def good_port_ranges(ports=None, min_range_len=20, border=3):
    
    min_range_len += border*2
    if ports is None:
        ports = available_ports()
    ranges = utils.to_ranges(list(ports))
    lenghts = sorted([(r[1]-r[0], r) for r in ranges], reverse=True)
    long_ranges = [l[1] for l in lenghts if l[0] >= min_range_len]
    without_borders = [(low+border, high-border) for low, high in long_ranges]
    return without_borders
1187272
int refreshAndGetMax() {
		int max = 0;

		for (InputChannel channel : inputGate.getInputChannels().values()) {
			if (channel instanceof RemoteInputChannel) {
				RemoteInputChannel rc = (RemoteInputChannel) channel;

				int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
				max = Math.max(max, size);
			}
		}

		return max;
	}
517403
function getPort(req) {
		if (req.connection && req.connection.localPort) {
			return req.connection.localPort.toString();
		}
		const host = req.headers && req.headers.host;
		let protocolSrc = 80;
		if (host && ((host.match(/:/g) || []).length) === 1) {
			const possiblePort = host.split(':')[1];
			protocolSrc = isNaN(possiblePort) ? protocolSrc : possiblePort;
		}
		return protocolSrc;
	}
656113
public Bbox getBounds() {
		if (isEmpty()) {
			return null;
		}
		double minX = Double.MAX_VALUE;
		double minY = Double.MAX_VALUE;
		double maxX = -Double.MAX_VALUE;
		double maxY = -Double.MAX_VALUE;

		for (Point point : points) {
			if (point.getX() < minX) {
				minX = point.getX();
			}
			if (point.getY() < minY) {
				minY = point.getY();
			}
			if (point.getX() > maxX) {
				maxX = point.getX();
			}
			if (point.getY() > maxY) {
				maxY = point.getY();
			}
		}

		return new Bbox(minX, minY, maxX - minX, maxY - minY);
	}
1160020
public com.google.api.Distribution.Range getRange() {
    return range_ == null ? com.google.api.Distribution.Range.getDefaultInstance() : range_;
  }
1012034
public static synchronized PortRange getTcpInstance() {
        if (tcpPortRange == null) {
            tcpPortRange = new PortRange();
            tcpPortRange.init(CoGProperties.getDefault().getTcpPortRange());
        }
        return tcpPortRange;
    }
1019927
int getPort() {
        LOGGER.entering();
        int val = -1;

        InstanceType type = getType();
        if (commands.contains(PORT_ARG)) {
            val = Integer.parseInt(commands.get(commands.indexOf(PORT_ARG) + 1));
            LOGGER.exiting(val);
            return val;
        }

        try {
            if (type.equals(InstanceType.SELENIUM_NODE) || type.equals(InstanceType.SELENIUM_HUB)) {
                val = getSeleniumConfigAsJsonObject().get("port").getAsInt();
            }
        } catch (JsonParseException | NullPointerException e) {
            // ignore
        }

        // last ditch effort
        val = (val != -1) ? val : 4444;
        LOGGER.exiting(val);
        return val;
    }
20338
def _get_port_range(range_str):
        
        if range_str == '*':
            return PortsRangeHelper.PortsRange(start=0, end=65535)

        s = range_str.split('-')
        if len(s) == 2:
            return PortsRangeHelper.PortsRange(start=int(s[0]), end=int(s[1]))

        return PortsRangeHelper.PortsRange(start=int(s[0]), end=int(s[0]))
357691
private boolean toBoundedPrevious() throws FetchException {
        if (!toPrevious()) {
            return false;
        }

        if (mStartBound != null) {
            byte[] currentKey = getCurrentKey();
            if (currentKey == null) {
                return false;
            }
            int result = compareKeysPartially(currentKey, mStartBound);
            if (result <= 0) {
                if (result < 0 || !mInclusiveStart) {
                    // Too far now, reset to first.
                    toBoundedFirst();
                    return false;
                }
            }
        }

        return prefixMatches();
    }
969593
private boolean toBoundedLast() throws FetchException {
        if (mEndBound == null) {
            if (!toLast()) {
                return false;
            }
        } else {
            if (!toLast(mEndBound.clone())) {
                return false;
            }
            if (!mInclusiveEnd) {
                byte[] currentKey = getCurrentKey();
                if (currentKey == null) {
                    return false;
                }
                if (compareKeysPartially(mEndBound, currentKey) == 0) {
                    if (!toPreviousKey()) {
                        return false;
                    }
                }
            }
        }

        if (mStartBound != null) {
            byte[] currentKey = getCurrentKey();
            if (currentKey == null) {
                return false;
            }
            int result = compareKeysPartially(currentKey, mStartBound);
            if (result <= 0) {
                if (result < 0 || !mInclusiveStart) {
                    return false;
                }
            }
        }

        return prefixMatches();
    }
1360520
def get_port_range(port_def):
    '''
    
    '''
    if isinstance(port_def, six.integer_types):
        # Single integer, start/end of range is the same
        return port_def, port_def
    try:
        comps = [int(x) for x in split(port_def, '-')]
        if len(comps) == 1:
            range_start = range_end = comps[0]
        else:
            range_start, range_end = comps
        if range_start > range_end:
            raise ValueError('start > end')
    except (TypeError, ValueError) as exc:
        if exc.__str__() == 'start > end':
            msg = (
                'Start of port range ({0}) cannot be greater than end of '
                'port range ({1})'.format(range_start, range_end)
            )
        else:
            msg = '\'{0}\' is non-numeric or an invalid port range'.format(
                port_def
            )
        raise ValueError(msg)
    else:
        return range_start, range_end