Permalink
Browse files

.functions: Add `gz` function to get gzipped file size

  • Loading branch information...
1 parent 9d618ba commit a9942ac635f1f55c2c585e9d256419a48c2ba5ee @paulirish paulirish committed with May 31, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 .functions
View
@@ -25,6 +25,14 @@ function server() {
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
+# Get gzipped file size
+function gz() {
+ echo "orig size (bytes): "
+ cat "$1" | wc -c
@necolas

necolas Dec 4, 2012

Contributor

You should be able to simplify this line very slightly to: wc -c < "$1". wc won't return the filename in the output if you redirect the filename into wc.

It might also be handy to display the file size ratio as in: necolas/dotfiles@56ae0dd

@mathiasbynens

mathiasbynens Dec 8, 2012

Owner

Done in 1a68b1e. Thanks!

@necolas

necolas Dec 8, 2012

Contributor

:)

+ echo "gzipped size (bytes): "
+ gzip -c "$1" | wc -c
+}
+
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
# Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!)
function httpcompression() {

0 comments on commit a9942ac

Please sign in to comment.