The col size of the current terminal as returned by tput

@staticvar bool|int $cols the cached value for the number of columns
@param bool $cache Whether to cache the response
@return int
507734
public static function cols( $cache = true ) {
		static $cols = false;
		if( !$cols || !$cache ) {
			$cols = intval(`tput cols`);
		}

		return $cols ? : 80;
	}

	/**
	 * The row size of the current terminal as returned by tput
	 *
	 * @staticvar bool|int $rows the cached value for the number of columns
	 * @param bool $cache Whether to cache the response
	 * @return int
	 */
	public static function rows( $cache = true ) {
		static $rows = false;
		if( !$rows || !$cache ) {
			$rows = intval(`tput lines`);
		}

		return $rows ? : 24;
	}
1080698
public function size($loc = 'output') {
		if ($loc === 'output' && !$this->output_css) {
			$this->formatted();
		}

		if ($loc === 'input') {
			return (strlen($this->input_css) / 1000);
		} else {
			return (strlen($this->output_css_plain) / 1000);
		}
	}
731930
def column_widths(self, size, focus=False):
        
        maxcol = size[0]
        self._cache_maxcol = maxcol
        widths = [width for i, (w, (t, width, b)) in enumerate(self.contents)]
        self._cache_column_widths = widths

        return widths
25450
protected function getRealpathCacheSize()
    {
        $size = ini_get('realpath_cache_size');
        $size = trim($size);
        $unit = strtolower(substr($size, -1, 1));
        switch ($unit) {
            case 'g':
                return $size * 1024 * 1024 * 1024;
            case 'm':
                return $size * 1024 * 1024;
            case 'k':
                return $size * 1024;
            default:
                return (int) $size;
        }
    }
1207241
public static void widthTable(XWPFTable table, float widthCM, int cols) {
        int width = (int)(widthCM/2.54*1440);
        CTTblPr tblPr = table.getCTTbl().getTblPr();
        if (null == tblPr) {
            tblPr = table.getCTTbl().addNewTblPr();
        }
        CTTblWidth tblW = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW();
        tblW.setType(0 == width ? STTblWidth.AUTO : STTblWidth.DXA);
        tblW.setW(BigInteger.valueOf(width));

        if (0 != width) {
            CTTblGrid tblGrid = table.getCTTbl().getTblGrid();
            if (null == tblGrid) {
                tblGrid = table.getCTTbl().addNewTblGrid();
            }

            for (int j = 0; j < cols; j++) {
                CTTblGridCol addNewGridCol = tblGrid.addNewGridCol();
                addNewGridCol.setW(BigInteger.valueOf(width / cols));
            }
        }
    }
664906
public function send($cache = true)
    {
        $returnCssFile = $this->_absoluteCssPath;
        $returnCss = '';

        // Try to process this CSS file
        try {

            // If the cache directory doesn't exist or is not writable: Error
            if ((!@is_dir($this->_absoluteCacheCssDir) && !@mkdir($this->_absoluteCacheCssDir, 0777,
                        true)) || !@is_writable($this->_absoluteCacheCssDir)
            ) {
                $this->_addErrorHeader(\Tollwerk\Squeezr\Exception::INVALID_TARGET_CACHE_DIRECTORY_MSG,
                    \Tollwerk\Squeezr\Exception::INVALID_TARGET_CACHE_DIRECTORY);

                // If the squeezr screen cookie is not available or invalid
            } elseif (empty($_COOKIE['squeezr_css']) || !preg_match("%^(\d+)x(\d+)\@(\d+(?:\.\d+)?)$%",
                    $_COOKIE['squeezr_css'], $squeezr)
            ) {
                $this->_addErrorHeader(\Tollwerk\Squeezr\Exception::MISSING_METRICS_COOKIE_MSG,
                    \Tollwerk\Squeezr\Exception::MISSING_METRICS_COOKIE);

                // Else: Compile and send the breakpoint specific CSS
            } else {

                // If there's already a PHP cache file of the requested CSS
                if (@is_file($this->_absoluteCachePhpPath)) {
                    $cacheInstance = include $this->_absoluteCachePhpPath;

                    // Else: Create a PHP cache file of the requested CSS
                } else {

                    // Compile the cacheable CSS file PHP class
                    $cacheClassCode = trim($this->_compileCacheClassCode());

                    // If the file should be cached: Write the PHP cache class file to disk
                    if ($cache && !@file_put_contents($this->_absoluteCachePhpPath, $cacheClassCode)) {
                        $this->_addErrorHeader(sprintf(\Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE_STR,
                            $this->_absoluteCachePhpPath), \Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE);

                        // Disable caching alltogether
                        $cache = false;
                    }

                    // Instanciate the cache class
                    $cacheInstance = eval(substr($cacheClassCode, 5));
                }

                // If the PHP cache class could be instanciated ...
                if (is_object($cacheInstance)) {
                    $returnCss = strval($cacheInstance);

                    // Render the breakpoint specific CSS (if not available yet) and create a request specific symlink
                    $breakpointsCachePath = $this->_absoluteCachePathBase.$cacheInstance->getMatchingBreakpoints().'.css';

                    // If caching is enabled ...
                    if ($cache) {

                        // If the breakpoint specific CSS cannot be created: Caching error
                        if (!@is_file($breakpointsCachePath) && !@file_put_contents($breakpointsCachePath,
                                $returnCss)
                        ) {
                            $this->_addErrorHeader(sprintf(\Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE_STR,
                                $breakpointsCachePath), \Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE);

                            // Else if the breakpoint specific CSS cannot be symlinked: Caching error
                        } elseif (!@symlink($breakpointsCachePath, $this->_absoluteCacheCssPath)) {
                            $this->_addErrorHeader(sprintf(\Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE_STR,
                                $this->_absoluteCacheCssPath), \Tollwerk\Squeezr\Exception::FAILED_WRITING_CACHE_FILE);

                            // Else: Return the cached file
                        } else {
                            $returnCssFile = $this->_absoluteCacheCssPath;
                        }
                    }
                }
            }

            // On errors
        } catch (\Tollwerk\Squeezr\Exception $e) {
            $this->_addErrorHeader($e->getMessage(), $e->getCode());
            $returnCssFile = $this->_absoluteCssPath;
        }

        // If the CSS has been cached to a file
        if ($returnCssFile) {
            $this->_sendFile($returnCssFile, 'text/css', true);
            exit;

            // Else: Just send the CSS code along with some appropriate headers
        } else {
            header('Content-Type: text/css');
            header('Content-Length: '.strlen($returnCss));
            header('Cache-Control: no-cache, must-revalidate');
            header('Expires: '.gmdate('D, d M Y H:i:s', time() - SQUEEZR_CACHE_LIFETIME).' GMT');

            die($returnCss);
        }
    }
998605
public function execute($cache = true) {
        // @todo Execute sql here
        if (strlen($this->_sql_query)) {
            // Get cache key
            $cache_key = sha1($this->_sql_query);
            
            // If cache exists and cache is enable
            $config = Config::get('db');
            $cache_enable = isset($config->cache) ? $config->cache : false;
            $cache_time = isset($config->cache_time) ? $config->cache_time : 1440;
            
            if ($cache_enable) {
                if (Cache::exists($cache_key) && $cache) {
                    return Cache::get($cache_key);
                }
            }
            
            // Return contents
            $results = [];

            // Open connection
            if (is_null($this->db) ||
                ($this->db instanceof \mysqli && !$this->db->ping())) {
                $this->__connect();
            }

            // Execute command
            $return = $this->db->query($this->_sql_query);
            
            // Close connection
            $thread = $this->db->thread_id;
            $this->db->close();
            $this->db->kill($thread);
            
            // Log executed query
            array_push(self::$_last_commands, $this->_sql_query);
        
            
            if (is_object($return) && isset($return->num_rows)) {
                while ($row = $return->fetch_array()) {
                    array_push($results, $row);
                }
                
                // Save cache (overwrites existing)
                if ($cache) {
                    Cache::save($cache_key, $results, true, $cache_time);
                }
                
                return $results;
            }
            
            return $return;
        }
    }
1002036
public static function dirSize(string $directory, bool $includeDirAllocSize = false): int
    {
        $size = 0;
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
            /**
             * @var \SplFileInfo $file
             */
            if ($file->isFile()) {
                $size += filesize($file->getRealPath());
            } else {
                if ($includeDirAllocSize) {
                    $size += $file->getSize();
                }
            }
        }

        return $size;
    }
855979
protected function getColumn($col)
    {
        if (isset($this->instance[$col])) {
            return $this->instance[$col];
        } elseif (isset($this->columns[$col]) && isset($this->columns[$col]['default'])) {
            return $this->columns[$col]['default'];
        } else {
            return null;
        }
    }
1158534
protected function getColumnWidth(array $commands)
    {
        $width = 0;
        foreach ($commands as $command) {
            $aliasesString = $this->formatAliases($command->getAliases());
            $commandWidth = strlen($command->getName()) + strlen($aliasesString);
            $width = $commandWidth > $width ? $commandWidth : $width;
        }

        // Limit to a maximum.
        $terminalWidth = (new Terminal())->getWidth();
        if ($width / $terminalWidth > 0.4) {
            $width = floor($terminalWidth * 0.4);
        }

        // Start at a minimum.
        if ($width < 20) {
            $width = 20;
        }

        // Add the indent.
        $width += 2;

        // Accommodate tags.
        $width += strlen('<info></info>');

        return $width;
    }
161858
public function getTableCellSize()
    {
        if ($this->column_size===0 && $this->line_size===0 && $this->cell_size===0) {
            $this->_parseTableSizes();
        }
        return $this->cell_size;
    }
361868
public function cacheSize( $type = self::PERSISTED )
    {
        switch( $type ) {
            case self::PERSISTED:
                return count( $this->instancesPersisted );
            case self::UNPERSISTED:
                return count( $this->instancesUnpersisted );
            case self::ALL:
                return $this->cacheSize( self::PERSISTED ) + $this->cacheSize( self::UNPERSISTED );
        }
        throw new \InvalidArgumentException("Bad source `{$source}` passed to " . __FUNCTION__);
    }
86653
static public function columns() {
		static $columns;

		if ( getenv( 'PHP_CLI_TOOLS_TEST_SHELL_COLUMNS_RESET' ) ) {
			$columns = null;
		}
		if ( null === $columns ) {
			if ( function_exists( 'exec' ) ) {
				if ( self::is_windows() ) {
					// Cater for shells such as Cygwin and Git bash where `mode CON` returns an incorrect value for columns.
					if ( ( $shell = getenv( 'SHELL' ) ) && preg_match( '/(?:bash|zsh)(?:\.exe)?$/', $shell ) && getenv( 'TERM' ) ) {
						$columns = (int) exec( 'tput cols' );
					}
					if ( ! $columns ) {
						$return_var = -1;
						$output = array();
						exec( 'mode CON', $output, $return_var );
						if ( 0 === $return_var && $output ) {
							// Look for second line ending in ": <number>" (searching for "Columns:" will fail on non-English locales).
							if ( preg_match( '/:\s*[0-9]+\n[^:]+:\s*([0-9]+)\n/', implode( "\n", $output ), $matches ) ) {
								$columns = (int) $matches[1];
							}
						}
					}
				} else {
					if ( ! ( $columns = (int) getenv( 'COLUMNS' ) ) ) {
						$size = exec( '/usr/bin/env stty size 2>/dev/null' );
						if ( '' !== $size && preg_match( '/[0-9]+ ([0-9]+)/', $size, $matches ) ) {
							$columns = (int) $matches[1];
						}
						if ( ! $columns ) {
							if ( getenv( 'TERM' ) ) {
								$columns = (int) exec( '/usr/bin/env tput cols 2>/dev/null' );
							}
						}
					}
				}
			}

			if ( ! $columns ) {
				$columns = 80; // default width of cmd window on Windows OS
			}
		}

		return $columns;
	}
729310
private function getColumnWidth(array $headings)
    {
        $width = 0;
        foreach ($headings as $heading) {
            $width = strlen($heading) > $width ? strlen($heading) : $width;
        }

        return $width + 5;
    }
659229
public function getColumnSize($name, $caseInsensitive = false)
    {
        if ($caseInsensitive) {
            foreach ($this->columnsSize as $forName => $size) {
                if (0 === strcasecmp($forName, $name)) {
                    return $size;
                }
            }
            return null;
        }
        return isset($this->columnsSize[$name]) ? $this->columnsSize[$name] : null;
    }
346337
def size(self):
        ''''''
        if self.cache.cache is None:
            return self.read_backend_structure().size()
        else:
            return len(self.cache.cache)
185164
private final void resizeCache() {
    final ResizeFactor rf = getResizeFactor();
    final int lgTgtLongs = lgNomLongs_ + 1;
    final int lgDeltaLongs = lgTgtLongs - lgArrLongs_;
    final int lgResizeFactor = max(min(rf.lg(), lgDeltaLongs), 1); //rf_.lg() could be 0
    lgArrLongs_ += lgResizeFactor; // new tgt size

    final long[] tgtArr = new long[1 << lgArrLongs_];
    final int newCount = HashOperations.hashArrayInsert(cache_, tgtArr, lgArrLongs_, thetaLong_);

    assert newCount == curCount_;  //Assumes no dirty values.
    curCount_ = newCount;

    cache_ = tgtArr;
    hashTableThreshold_ = setHashTableThreshold(lgNomLongs_, lgArrLongs_);
  }