function top (opts) {
328689
function top () { // NOTE: Replacing line above
  // if (!opts) opts = {}

  // const tick = opts.interval || 1000
  // const started = Date.now()
  // const interval = setInterval(perSecond, tick)
  // const win = [{ time: process.hrtime(), cpu: process.cpuUsage(), delay: 0 }, null, null, null]
  const win = [{ time: process.hrtime(), cpu: process.cpuUsage() }, null, null, null] // NOTE: Replacing line above
  // const loopSampler = eld()

  let sec = 1

  // interval.unref()

  return {
    // pid: process.pid,
    // command: process.argv.join(' '),
    // started,
    // time () {
    //   return Date.now() - started
    // },
    // delay () {
    //   const btm = oldest()
    //   const timeDelta = process.hrtime(win[btm].time)
    //   const ms = timeDelta[0] * 1e3 + Math.floor(timeDelta[1] / 1e6)
    //   return Math.floor((loopSampler.delay - win[btm].delay) / (ms / tick))
    // },
    cpu () {
      const btm = oldest()
      const cpuDelta = process.cpuUsage(win[btm].cpu)
      const timeDelta = process.hrtime(win[btm].time)
      const us = timeDelta[0] * 1e6 + timeDelta[1] / 1e3
      perSecond() // NOTE: Added to skip timer and update at each check
      return {
        time: us,
        percent: (cpuDelta.system + cpuDelta.user) / us,
        system: cpuDelta.system,
        user: cpuDelta.user
      }
    }
    // memory () {
    //   const mem = process.memoryUsage()
    //   const total = os.totalmem()
    //   return {
    //     percent: mem.rss / total,
    //     rss: mem.rss,
    //     total,
    //     heapPercent: mem.heapUsed / mem.heapTotal,
    //     heapUsed: mem.heapUsed,
    //     heapTotal: mem.heapTotal,
    //     external: mem.external
    //   }
    // },
    // loadavg () {
    //   return os.loadavg()
    // },
    // destroy () {
    //   clearInterval(interval)
    // },
    // toString () {
    //   const mem = this.memory()
    //   return `cpu: ${pct(this.cpu().percent)} | rss: ${p(mem.rss)} (${pct(mem.percent)}) | heap: ${p(mem.heapUsed)} / ${p(mem.heapTotal)} (${pct(mem.heapPercent)}) | ext: ${p(mem.external)} | delay: ${this.delay()} ms | ${time(this.time())} | loadavg: ${os.loadavg().map(fixed2).join(', ')}`
    // }
  }

  function oldest () {
    let btm = (sec - 4) & 3
    while (!win[btm]) btm = (btm + 1) & 3
    return btm
  }

  function perSecond () {
    const ptr = sec++ & 3
    // win[ptr] = { time: process.hrtime(), cpu: process.cpuUsage(), delay: loopSampler.delay }
    win[ptr] = { time: process.hrtime(), cpu: process.cpuUsage() } // NOTE: Replacing line above
  }
}
685257
function top(date, fmt) {
            fmt = fmt || '%Y-%M-%dT%H:%m:%sZ';

            function pad(value) {
                return (value.toString().length < 2) ? '0' + value : value;
            };

            return fmt.replace(/%([a-zA-Z])/g, function (_, fmtCode) {
                switch (fmtCode) {
                    case 'Y':
                        return date.getUTCFullYear();
                    case 'M':
                        return pad(date.getUTCMonth() + 1);
                    case 'd':
                        return pad(date.getUTCDate());
                    case 'H':
                        return pad(date.getUTCHours());
                    case 'm':
                        return pad(date.getUTCMinutes());
                    case 's':
                        return pad(date.getUTCSeconds());
                    default:
                        throw new Error('Unsupported format code: ' + fmtCode);
                }
            });
        }
526184
def top(n, width=WIDTH, style=STYLE):
    """"""
    return hrule(n, width, linestyle=STYLES[style].top)
1203731
function (t) {
        var o_p = this.offsetParent(),
            o = o_p.offset(),
            p = t.offset();

        p.top -= o.top;
        p.left -= o.left;

        return p;
      }
399881
def topWindow():
    
    import_qt(globals())
    
    window = QtGui.QApplication.instance().activeWindow()
    if not window:
        return None
    
    parent = window.parent()
    
    while parent:
        window = parent
        parent = window.parent()
        
    return window
475017
function scrollTop() {
    var assign;

    var args = [], len = arguments.length;
    while ( len-- ) args[ len ] = arguments[ len ];
    var top = args[0];
    var duration = args[1];
    var easing = args[2];
    var callback = args[3];
    if (args.length === 3 && typeof easing === 'function') {
      (assign = args, top = assign[0], duration = assign[1], callback = assign[2], easing = assign[3]);
    }
    var dom = this;
    if (typeof top === 'undefined') {
      if (dom.length > 0) { return dom[0].scrollTop; }
      return null;
    }
    return dom.scrollTo(undefined, top, duration, easing, callback);
  }
1190717
public void top(String arg) throws IOException {
        String top;
        if (arg.equals("1"))
            top = top1;
        else
            top = top2;
        this.println("+OK " + top.length() + " octets");
        this.writer.write(top);
        this.println(".");
    }
677321
def get_tops(self):
        '''
        
        '''
        tops = DefaultOrderedDict(list)
        include = DefaultOrderedDict(list)
        done = DefaultOrderedDict(list)
        found = 0  # did we find any contents in the top files?
        # Gather initial top files
        merging_strategy = self.opts['top_file_merging_strategy']
        if merging_strategy == 'same' and not self.opts['saltenv']:
            if not self.opts['default_top']:
                raise SaltRenderError(
                    'top_file_merging_strategy set to \'same\', but no '
                    'default_top configuration option was set'
                )

        if self.opts['saltenv']:
            contents = self.client.cache_file(
                self.opts['state_top'],
                self.opts['saltenv']
            )
            if contents:
                found = 1
                tops[self.opts['saltenv']] = [
                    compile_template(
                        contents,
                        self.state.rend,
                        self.state.opts['renderer'],
                        self.state.opts['renderer_blacklist'],
                        self.state.opts['renderer_whitelist'],
                        saltenv=self.opts['saltenv']
                    )
                ]
            else:
                tops[self.opts['saltenv']] = [{}]

        else:
            found = 0
            state_top_saltenv = self.opts.get('state_top_saltenv', False)
            if state_top_saltenv \
                    and not isinstance(state_top_saltenv, six.string_types):
                state_top_saltenv = six.text_type(state_top_saltenv)

            for saltenv in [state_top_saltenv] if state_top_saltenv \
                    else self._get_envs():
                contents = self.client.cache_file(
                    self.opts['state_top'],
                    saltenv
                )
                if contents:
                    found = found + 1
                    tops[saltenv].append(
                        compile_template(
                            contents,
                            self.state.rend,
                            self.state.opts['renderer'],
                            self.state.opts['renderer_blacklist'],
                            self.state.opts['renderer_whitelist'],
                            saltenv=saltenv
                        )
                    )
                else:
                    tops[saltenv].append({})
                    log.debug('No contents loaded for saltenv \'%s\'', saltenv)

            if found > 1 and merging_strategy == 'merge' and not self.opts.get('env_order', None):
                log.warning(
                    'top_file_merging_strategy is set to \'%s\' and '
                    'multiple top files were found. Merging order is not '
                    'deterministic, it may be desirable to either set '
                    'top_file_merging_strategy to \'same\' or use the '
                    '\'env_order\' configuration parameter to specify the '
                    'merging order.', merging_strategy
                )

        if found == 0:
            log.debug(
                'No contents found in top file. If this is not expected, '
                'verify that the \'file_roots\' specified in \'etc/master\' '
                'are accessible. The \'file_roots\' configuration is: %s',
                repr(self.state.opts['file_roots'])
            )

        # Search initial top files for includes
        for saltenv, ctops in six.iteritems(tops):
            for ctop in ctops:
                if 'include' not in ctop:
                    continue
                for sls in ctop['include']:
                    include[saltenv].append(sls)
                ctop.pop('include')
        # Go through the includes and pull out the extra tops and add them
        while include:
            pops = []
            for saltenv, states in six.iteritems(include):
                pops.append(saltenv)
                if not states:
                    continue
                for sls_match in states:
                    for sls in fnmatch.filter(self.avail[saltenv], sls_match):
                        if sls in done[saltenv]:
                            continue
                        tops[saltenv].append(
                            compile_template(
                                self.client.get_state(
                                    sls,
                                    saltenv
                                ).get('dest', False),
                                self.state.rend,
                                self.state.opts['renderer'],
                                self.state.opts['renderer_blacklist'],
                                self.state.opts['renderer_whitelist'],
                                saltenv
                            )
                        )
                        done[saltenv].append(sls)
            for saltenv in pops:
                if saltenv in include:
                    include.pop(saltenv)
        return tops
899280
function onShow(scope, element, opts) {

      watchAsyncLoad();
      sanitizeAndConfigure(scope, opts);

      opts.hideBackdrop = showBackdrop(scope, element, opts);

      return showDropDown(scope, element, opts)
        .then(function(response) {
          element.attr('aria-hidden', 'false');
          opts.alreadyOpen = true;
          opts.cleanupInteraction = activateInteraction();
          opts.cleanupResizing = activateResizing();
          autoFocus(opts.focusedNode);

          return response;
        }, opts.hideBackdrop);

      // ************************************
      // Closure Functions
      // ************************************

      /**
       *  Attach the select DOM element(s) and animate to the correct positions
       *  and scalings...
       */
      function showDropDown(scope, element, opts) {
        if (opts.parent !== element.parent()) {
          element.parent().attr('aria-owns', element.attr('id'));
        }
        element.parent().find('md-select-value').attr('aria-hidden', 'true');

        opts.parent.append(element);

        return $q(function(resolve, reject) {

          try {

            $animateCss(element, {removeClass: 'md-leave', duration: 0})
              .start()
              .then(positionAndFocusMenu)
              .then(resolve);

          } catch (e) {
            reject(e);
          }

        });
      }

      /**
       * Initialize container and dropDown menu positions/scale, then animate
       * to show.
       */
      function positionAndFocusMenu() {
        return $q(function(resolve) {
          if (opts.isRemoved) return $q.reject(false);

          var info = calculateMenuPositions(scope, element, opts);

          info.container.element.css(animator.toCss(info.container.styles));
          info.dropDown.element.css(animator.toCss(info.dropDown.styles));

          $$rAF(function() {
            element.addClass('md-active');
            info.dropDown.element.css(animator.toCss({transform: ''}));
            autoFocus(opts.focusedNode);

            resolve();
          });

        });
      }

      /**
       * Show modal backdrop element...
       */
      function showBackdrop(scope, element, options) {

        // If we are not within a dialog...
        if (options.disableParentScroll && !$mdUtil.getClosest(options.target, 'MD-DIALOG')) {
          // !! DO this before creating the backdrop; since disableScrollAround()
          //    configures the scroll offset; which is used by mdBackDrop postLink()
          options.restoreScroll = $mdUtil.disableScrollAround(options.element, options.parent);
        } else {
          options.disableParentScroll = false;
        }

        if (options.hasBackdrop) {
          // Override duration to immediately show invisible backdrop
          options.backdrop = $mdUtil.createBackdrop(scope, "md-select-backdrop md-click-catcher");
          $animate.enter(options.backdrop, $document[0].body, null, {duration: 0});
        }

        /**
         * Hide modal backdrop element...
         */
        return function hideBackdrop() {
          if (options.backdrop) options.backdrop.remove();
          if (options.disableParentScroll) options.restoreScroll();

          delete options.restoreScroll;
        };
      }

      /**
       *
       */
      function autoFocus(focusedNode) {
        if (focusedNode && !focusedNode.hasAttribute('disabled')) {
          focusedNode.focus();
        }
      }

      /**
       * Check for valid opts and set some sane defaults
       */
      function sanitizeAndConfigure(scope, options) {
        var selectEl = element.find('md-select-menu');

        if (!options.target) {
          throw new Error($mdUtil.supplant(ERROR_TARGET_EXPECTED, [options.target]));
        }

        angular.extend(options, {
          isRemoved: false,
          target: angular.element(options.target), // make sure it's not a naked DOM node
          parent: angular.element(options.parent),
          selectEl: selectEl,
          contentEl: element.find('md-content'),
          optionNodes: selectEl[0].getElementsByTagName('md-option')
        });
      }

      /**
       * Configure various resize listeners for screen changes
       */
      function activateResizing() {
        var debouncedOnResize = (function(scope, target, options) {

          return function() {
            if (options.isRemoved) return;

            var updates = calculateMenuPositions(scope, target, options);
            var container = updates.container;
            var dropDown = updates.dropDown;

            container.element.css(animator.toCss(container.styles));
            dropDown.element.css(animator.toCss(dropDown.styles));
          };

        })(scope, element, opts);

        var window = angular.element($window);
        window.on('resize', debouncedOnResize);
        window.on('orientationchange', debouncedOnResize);

        // Publish deactivation closure...
        return function deactivateResizing() {

          // Disable resizing handlers
          window.off('resize', debouncedOnResize);
          window.off('orientationchange', debouncedOnResize);
        };
      }

      /**
       *  If asynchronously loading, watch and update internal
       *  '$$loadingAsyncDone' flag
       */
      function watchAsyncLoad() {
        if (opts.loadingAsync && !opts.isRemoved) {
          scope.$$loadingAsyncDone = false;

          $q.when(opts.loadingAsync)
            .then(function() {
              scope.$$loadingAsyncDone = true;
              delete opts.loadingAsync;
            }).then(function() {
              $$rAF(positionAndFocusMenu);
            });
        }
      }

      /**
       *
       */
      function activateInteraction() {
        if (opts.isRemoved) return;

        var dropDown = opts.selectEl;
        var selectCtrl = dropDown.controller('mdSelectMenu') || {};

        element.addClass('md-clickable');

        // Close on backdrop click
        opts.backdrop && opts.backdrop.on('click', onBackdropClick);

        // Escape to close
        // Cycling of options, and closing on enter
        dropDown.on('keydown', onMenuKeyDown);
        dropDown.on('click', checkCloseMenu);

        return function cleanupInteraction() {
          opts.backdrop && opts.backdrop.off('click', onBackdropClick);
          dropDown.off('keydown', onMenuKeyDown);
          dropDown.off('click', checkCloseMenu);

          element.removeClass('md-clickable');
          opts.isRemoved = true;
        };

        // ************************************
        // Closure Functions
        // ************************************

        function onBackdropClick(e) {
          e.preventDefault();
          e.stopPropagation();
          opts.restoreFocus = false;
          $mdUtil.nextTick($mdSelect.hide, true);
        }

        function onMenuKeyDown(ev) {
          ev.preventDefault();
          ev.stopPropagation();

          switch (ev.keyCode) {
            case keyCodes.UP_ARROW:
              return focusPrevOption();
            case keyCodes.DOWN_ARROW:
              return focusNextOption();
            case keyCodes.SPACE:
            case keyCodes.ENTER:
              var option = $mdUtil.getClosest(ev.target, 'md-option');
              if (option) {
                dropDown.triggerHandler({
                  type: 'click',
                  target: option
                });
                ev.preventDefault();
              }
              checkCloseMenu(ev);
              break;
            case keyCodes.TAB:
            case keyCodes.ESCAPE:
              ev.stopPropagation();
              ev.preventDefault();
              opts.restoreFocus = true;
              $mdUtil.nextTick($mdSelect.hide, true);
              break;
            default:
              if (shouldHandleKey(ev, $mdConstant)) {
                var optNode = dropDown.controller('mdSelectMenu').optNodeForKeyboardSearch(ev);
                opts.focusedNode = optNode || opts.focusedNode;
                optNode && optNode.focus();
              }
          }
        }

        function focusOption(direction) {
          var optionsArray = $mdUtil.nodesToArray(opts.optionNodes);
          var index = optionsArray.indexOf(opts.focusedNode);

          var newOption;

          do {
            if (index === -1) {
              // We lost the previously focused element, reset to first option
              index = 0;
            } else if (direction === 'next' && index < optionsArray.length - 1) {
              index++;
            } else if (direction === 'prev' && index > 0) {
              index--;
            }
            newOption = optionsArray[index];
            if (newOption.hasAttribute('disabled')) newOption = undefined;
          } while (!newOption && index < optionsArray.length - 1 && index > 0);

          newOption && newOption.focus();
          opts.focusedNode = newOption;
        }

        function focusNextOption() {
          focusOption('next');
        }

        function focusPrevOption() {
          focusOption('prev');
        }

        function checkCloseMenu(ev) {
          if (ev && (ev.type == 'click') && (ev.currentTarget != dropDown[0])) return;
          if (mouseOnScrollbar()) return;

          var option = $mdUtil.getClosest(ev.target, 'md-option');
          if (option && option.hasAttribute && !option.hasAttribute('disabled')) {
            ev.preventDefault();
            ev.stopPropagation();
            if (!selectCtrl.isMultiple) {
              opts.restoreFocus = true;

              $mdUtil.nextTick(function () {
                $mdSelect.hide(selectCtrl.ngModel.$viewValue);
              }, true);
            }
          }
          /**
           * check if the mouseup event was on a scrollbar
           */
          function mouseOnScrollbar() {
            var clickOnScrollbar = false;
            if (ev && (ev.currentTarget.children.length > 0)) {
              var child = ev.currentTarget.children[0];
              var hasScrollbar = child.scrollHeight > child.clientHeight;
              if (hasScrollbar && child.children.length > 0) {
                var relPosX = ev.pageX - ev.currentTarget.getBoundingClientRect().left;
                if (relPosX > child.querySelector('md-option').offsetWidth)
                  clickOnScrollbar = true;
              }
            }
            return clickOnScrollbar;
          }
        }
      }

    }
33902
function positionFromTop(container, el){
    
    var containerTop = container.position().top
      , windowTop = $window.scrollTop()
    if(containerTop > windowTop) return el.css('top', 0)
      
    var pos = windowTop - containerTop
    
    return el.css('top', pos)
    
    
  }
974337
def top(**kwargs):
    '''
    
    '''
    if 'id' not in kwargs['opts']:
        return {}
    cmd = '{0} {1}'.format(
            __opts__['master_tops']['ext_nodes'],
            kwargs['opts']['id']
            )
    ndata = salt.utils.yaml.safe_load(
        subprocess.Popen(
            cmd,
            shell=True,
            stdout=subprocess.PIPE).communicate()[0]
    )
    if not ndata:
        log.info('master_tops ext_nodes call did not return any data')
    ret = {}
    if 'environment' in ndata:
        env = ndata['environment']
    else:
        env = 'base'

    if 'classes' in ndata:
        if isinstance(ndata['classes'], dict):
            ret[env] = list(ndata['classes'])
        elif isinstance(ndata['classes'], list):
            ret[env] = ndata['classes']
        else:
            return ret
    else:
        log.info('master_tops ext_nodes call did not have a dictionary with a "classes" key.')

    return ret
410969
function(opt){
        // merge with default options
        Object.keys(_options).forEach(function(key){
            _options[key] = opt[key] || _options[key];
        });
    }
76140
function(r) {
			geo.origin.size.height = r.height,
				geo.origin.windowOffset.left = r.left,
				geo.origin.windowOffset.top = r.top,
				geo.origin.size.width = r.width
		}
1014776
def tops(opts):
    '''
    
    '''
    if 'master_tops' not in opts:
        return {}
    whitelist = list(opts['master_tops'].keys())
    ret = LazyLoader(
        _module_dirs(opts, 'tops', 'top'),
        opts,
        tag='top',
        whitelist=whitelist,
    )
    return FilterDictWrapper(ret, '.top')
935430
function(opts) {
  var that = this;

  this._children = {};
  var label = $.div( 'label' );
  var button = $.div( 'button', 'thm-bgP', [new Icon({content: 'tri-down', size: '24px'})] );
  var body = $.tag( 'div', 'body' );
  var datalist = $.div( 'datalist' );
  this._button = button;
  var table = $.div('table', 'thm-ele2', 'thm-bg3', [body, button]);
  var elem = $.elem( this, 'div', 'wdg-combo',
                     [label, table, datalist] );
  var touchable = new Touchable( elem );

  body.addEventListener('focus', function() {
    $.removeClass( table, 'thm-ele2' );
    $.addClass( table, 'thm-ele4' );
  });
  body.addEventListener('blur', function() {
    $.addClass( table, 'thm-ele2' );
    $.removeClass( table, 'thm-ele4' );
  });
  DB.propRemoveClass(this, 'enabled', 'disabled');
  DB.propBoolean(this, 'focus')(function(v) {
    if (v) body.focus();
    else body.blur();
  });
  DB.propString(this, 'label')(function(v) {
    if (v === null || (typeof v === 'string' && v.trim() == '')) {
      $.addClass(elem, 'no-label');
    } else {
      $.removeClass(elem, 'no-label');
      $.textOrHtml(label, v);
      if (v.substr(0, 6) == '<html>') {
        $.att(label, {title: ''});
      } else {
        $.att(label, {title: v});
      }
    }
  });
  DB.prop(this, 'content')(function(v) {
    var obj;
    if( typeof v === 'string' ) {
      v = v.split(",").map(function(itm) {
        return itm.trim();
      });
      obj = {};
      v.forEach( function( itm ){
        obj[itm] = itm;
      });
      v = obj;
    }
    if (Array.isArray( v )) {
      // Convert array into map.
      // Each item must have the `$key` property.
      // If not, the element is ignored.
      obj = {};
      v.forEach(function (itm, idx) {
        if( typeof itm.$key === 'undefined' ) return;
        obj[itm.$key] = itm;
      });
      v = obj;
    }
    that._children = v;
    DB.fire( that, 'value' );
  });
  DB.propString(this, 'value')(function(v) {
    var selectedItem = that._children[v];
    if( typeof selectedItem === 'undefined' ) {
      for( v in that._children ) break;
      selectedItem = that._children[v];
    }
    $.clear( body );
    if (!selectedItem) return;
    $.add( body, selectedItem );
  });
  DB.propAddClass(this, 'wide');
  DB.propRemoveClass(this, 'visible', 'hide');

  opts = DB.extend({
    value: '',
    content: [],
    label: null,
    enabled: true,
    wide: false,
    visible: true
  }, opts, this);

  touchable.tap.add( that.fire.bind( that ) );
}
1313040
def _setup_toplevel_hook(self, color):
        """"""
        def __toplevel__(*args, **kwargs):
            kwargs.setdefault("background", color)
            self.__init__toplevel(*args, **kwargs)

        tk.Toplevel.__init__ = __toplevel__
543882
def merge_tops(self, tops):
        '''
        
        '''
        merging_strategy = self.opts['top_file_merging_strategy']
        try:
            merge_attr = '_merge_tops_{0}'.format(merging_strategy)
            merge_func = getattr(self, merge_attr)
            if not hasattr(merge_func, '__call__'):
                msg = '\'{0}\' is not callable'.format(merge_attr)
                log.error(msg)
                raise TypeError(msg)
        except (AttributeError, TypeError):
            log.warning(
                'Invalid top_file_merging_strategy \'%s\', falling back to '
                '\'merge\'', merging_strategy
            )
            merge_func = self._merge_tops_merge
        return merge_func(tops)