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

        var q = this.clone();

        var table  = q._T.__name__;
        var page   = q._page;
        var fields = q._fields;

        // Create the query from our stuff
        var query = {};
        _(q._where.concat(q._like)).each(function (q) {
            query[q.key] = q.value;
        });

        var doneLoading      = Q.defer();
        this._executePromise = doneLoading.promise;

        var left = q._take;

        // A single iteration of fetching via the API. Called repeatedly in
        // the case of large / unbounded TAKES
        var loop = function() {

            // always take 1000 unless we're almost done
            var take = left < 1000 ? left : 1000;

            // Hit the API and incremement the page
            q._fetch(table, take, page++, query, fields).then(function(res) {

                // publish progress
                doneLoading.notify(q._results.length);

                if (left !== undefined) left -= res.length;

                // Either resolve the the promise with the results if we're
                // done or call the loop again

                if (q._doneLoading || left <= 0)
                    doneLoading.resolve(q._getResults());
                else
                    process.nextTick(loop);

            }).catch(function(err) {
                doneLoading.reject(err);
            });
        };

        // do tha damn thing
        loop();
        return doneLoading.promise;
    }
946721
def _get_rule_port_ranges(rule):
        
        properties = rule['properties']
        if 'destinationPortRange' in properties:
            return [PortsRangeHelper._get_port_range(properties['destinationPortRange'])]
        else:
            return [PortsRangeHelper._get_port_range(r)
                    for r in properties['destinationPortRanges']]
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
905791
function() {
        var inRange = false;

        if (this.alwaysInRange) {
            inRange = true;
        } else {
            if (this.map) {
                var resolution = this.map.getResolution();
                inRange = ( (resolution >= this.minResolution) &&
                            (resolution <= this.maxResolution) );
            }
        }
        return inRange;
    }
840335
function range(begin, end) {
  var interval = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];

  var a = [];

  for (var i = begin; i < begin + end; i += interval) {
    a.push(i);
  }

  return a;
}
1013571
function () {
            var state = this.state,
                pages = state.pages,
                viewportHeight = state.viewportDimensions.clientHeight,
                viewportWidth = state.viewportDimensions.clientWidth;

            // no pages are visible, but this case breaks the logic below,
            // becasue page widths/heights will also be 0
            if (viewportWidth === 0 || viewportHeight === 0) {
                return {
                    min: -1,
                    max: -1
                };
            }

            var viewportY0 = state.scrollTop,
                viewportY1 = viewportY0 + viewportHeight,
                viewportX0 = state.scrollLeft,
                viewportX1 = viewportX0 + viewportWidth,
                lowY = util.bisectLeft(pages, viewportY0, 'y1'),
                highY = util.bisectRight(pages, viewportY1, 'y0') - 1,
                lowX = util.bisectLeft(pages, viewportX0, 'x1'),
                highX = util.bisectRight(pages, viewportX1, 'x0') - 1,
                low = Math.max(lowX, lowY),
                high = Math.min(highX, highY);

            return util.constrainRange(low, high, this.numPages - 1);
        }
481765
private int getPort(URI endpoint) {
        if (endpoint.getPort() != -1) {
            return endpoint.getPort();
        } else if ("https".equals(endpoint.getScheme())) {
            return 443;
        } else {
            return 80;
        }
    }
902247
function () {
    const chanInstance = this.mapper.getObject(this.modelElement.hub.path());
    const compInstance = this.mapper.getObject(this.modelElement.port.eContainer().path());

    if (chanInstance) {
      if (compInstance) {
        // if compInstance is found then it means that the port is on this node
        if (this.modelElement.port.getRefInParent() === 'provided') {
          // binding related port is an 'in' port type
          const input = compInstance.inputs[this.modelElement.port.path()];
          chanInstance.addInputPort(input);
          this.log.debug(input.path + ' <-> ' + chanInstance.path);
        } else {
          // binding related port is an 'out' port type
          const output = compInstance.outputs[this.modelElement.port.path()];
          output.addChannel(chanInstance);
          this.log.debug(output.path + ' <-> ' + chanInstance.path);
        }

        return Promise.resolve();

      } else {
        if (this.modelElement.port.getRefInParent() === 'provided') {
          // only add input port
          chanInstance.addInputPort(new Input(this.modelElement.port.eContainer(), this.modelElement.port, true));
          this.log.debug('create remote input: ' + this.modelElement.port.path());
          this.log.debug(this.modelElement.port.path() + ' <-> ' + chanInstance.path);
        }
        return Promise.resolve();
      }
    } else {
      return Promise.reject(new Error(this.toString() + ' error: unable to find channel ' + this.modelElement.hub.name + ' instance on platform.'));
    }
  }
1323920
function doAfterAllPromises (params) {

          // Desctructuring:
          var $ul = params.$ul;
          var $promises = params.$promises;
          var level = params.level;
          var event = params.event;
          var leftOriented = String(params.orientation).toLowerCase() === 'left';

          $q.all($promises).then(function () {
            var topCoordinate  = event.pageY;
            var menuHeight = angular.element($ul[0]).prop('offsetHeight');
            var winHeight = $window.pageYOffset + event.view.innerHeight;

            /// the 20 pixels in second condition are considering the browser status bar that sometimes overrides the element
            if (topCoordinate > menuHeight && winHeight - topCoordinate < menuHeight + 20) {
              topCoordinate = event.pageY - menuHeight;
              /// If the element is a nested menu, adds the height of the parent li to the topCoordinate to align with the parent
              if(level && level > 0) {
                topCoordinate += event.event.currentTarget.offsetHeight;
              }
            } else if(winHeight <= menuHeight) {
              // If it really can't fit, reset the height of the menu to one that will fit
              angular.element($ul[0]).css({ 'height': winHeight - 5, 'overflow-y': 'scroll' });
              // ...then set the topCoordinate height to 0 so the menu starts from the top
              topCoordinate = 0;
            } else if(winHeight - topCoordinate < menuHeight) {
              var reduceThresholdY = 5;
              if(topCoordinate < reduceThresholdY) {
                reduceThresholdY = topCoordinate;
              }
              topCoordinate = winHeight - menuHeight - reduceThresholdY;
            }

            var leftCoordinate = event.pageX;
            var menuWidth = angular.element($ul[0]).prop('offsetWidth');
            var winWidth = event.view.innerWidth + window.pageXOffset;
            var padding = 5;

            if (leftOriented) {
              if (winWidth - leftCoordinate > menuWidth && leftCoordinate < menuWidth + padding) {
                leftCoordinate = padding;
              } else if (leftCoordinate < menuWidth) {
                var reduceThresholdX = 5;
                if (winWidth - leftCoordinate < reduceThresholdX + padding) {
                  reduceThresholdX = winWidth - leftCoordinate + padding;
                }
                leftCoordinate = menuWidth + reduceThresholdX + padding;
              } else {
                leftCoordinate = leftCoordinate - menuWidth;
              }
            } else {
              if (leftCoordinate > menuWidth && winWidth - leftCoordinate - padding < menuWidth) {
                leftCoordinate = winWidth - menuWidth - padding;
              } else if(winWidth - leftCoordinate < menuWidth) {
                var reduceThresholdX = 5;
                if(leftCoordinate < reduceThresholdX + padding) {
                  reduceThresholdX = leftCoordinate + padding;
                }
                leftCoordinate = winWidth - menuWidth - reduceThresholdX - padding;
              }
            }

            $ul.css({
              display: 'block',
              position: 'absolute',
              left: leftCoordinate + 'px',
              top: topCoordinate + 'px'
            });
          });

        }
160454
function () {
                if (agent.isW3CRangeSupport) {
                    var w3cRange = document.createRange();
                    w3cRange.setStart(sc, so);
                    w3cRange.setEnd(ec, eo);

                    return w3cRange;
                } else {
                    var textRange = pointToTextRange({
                        node: sc,
                        offset: so
                    });

                    textRange.setEndPoint('EndToEnd', pointToTextRange({
                        node: ec,
                        offset: eo
                    }));

                    return textRange;
                }
            }
12246
function() {    
        var bounds = null; 
        
        var length = this.grid.length;
        if (length) {
            var bottomLeftTileBounds = this.grid[length - 1][0].bounds,
                width = this.grid[0].length * bottomLeftTileBounds.getWidth(),
                height = this.grid.length * bottomLeftTileBounds.getHeight();
            
            bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left, 
                                           bottomLeftTileBounds.bottom,
                                           bottomLeftTileBounds.left + width, 
                                           bottomLeftTileBounds.bottom + height);
        }   
        return bounds;
    }
465084
public static int findAvailableTcpPort(int minPortRange, int maxPortRange) {
        ArgumentUtils.check(() -> minPortRange > MIN_PORT_RANGE)
            .orElseFail("Port minimum value must be greater than " + MIN_PORT_RANGE);
        ArgumentUtils.check(() -> maxPortRange >= minPortRange)
            .orElseFail("Max port range must be greater than minimum port range");
        ArgumentUtils.check(() -> maxPortRange <= MAX_PORT_RANGE)
            .orElseFail("Port maximum value must be less than " + MAX_PORT_RANGE);

        int currentPort = nextPort(minPortRange, maxPortRange);
        while (!isTcpPortAvailable(currentPort)) {
            currentPort = nextPort(minPortRange, maxPortRange);
        }
        return currentPort;
    }
526037
public ChronoInterval<T> getRange() {

        Boundary<T> start = Boundary.infinitePast();
        Boundary<T> end = Boundary.infiniteFuture();

        T min = this.getMinimum();
        T max = this.getMaximum();

        if (min != null) {
            start = Boundary.ofClosed(min);
        }

        if (max != null) {
            if (this.isCalendrical()) {
                end = Boundary.ofClosed(max);
            } else {
                T max2 = this.getTimeLine().stepForward(max);
                if (max2 != null) {
                    end = Boundary.ofOpen(max2);
                } else {
                    end = Boundary.ofClosed(max);
                }
            }
        }

        return this.newInterval(start, end);

    }
695824
def _get_range(self, endpoint_name):
        

        url = self.build_url(self._endpoints.get(endpoint_name))
        response = self.session.get(url)
        if not response:
            return None
        data = response.json()
        return self.range_constructor(parent=self, **{self._cloud_data_key: data})
1167074
function isAvailable(port) {
    return new Promise((resolve, reject) => {
        const server = net.createServer();

        server.unref();
        server.on('error', reject);
        const options = {};
        options.port = port;
        server.listen(options, () => {
            const { port } = server.address();
            server.close(() => {
                resolve(port);
            });
        });
    });
}
546975
function _ensureMinimum() {
    // Nothing to do if draining.
    if (this._draining) {
        return Promise.resolve();
    }

    var diff = this._opts.min - this._count + this.availableLength;
    var promises = [];
    for (var i = 0; i < diff; ++i) {
        promises.push(this.acquire(function(client){ return Promise.resolve(); }));
    }

    return Promise.all(promises).then(function(){});
}