Skip to content

Instantly share code, notes, and snippets.

@rhardih
rhardih / out.sh
Created November 22, 2017 14:23
http-server vs. http.listenAndServe scale
# http-server
rene $ for i in 16 128; do ab -c $i -n $i http://127.0.0.1:8080/ | grep "Time per"; done
Time per request: 20.492 [ms] (mean)
Time per request: 1.281 [ms] (mean, across all concurrent requests)
Time per request: 138.750 [ms] (mean)
Time per request: 1.084 [ms] (mean, across all concurrent requests)
# serve
rene $ for i in 16 128; do ab -c $i -n $i http://127.0.0.1:8080/ | grep "Time per"; done
Time per request: 3.465 [ms] (mean)
@rhardih
rhardih / convert.sh
Created August 26, 2015 17:18
Recursively find and convert .epub to .mobi using calibres ebook-convert (in parallel)
find . -name "*.epub" -exec sh -c 'ebook-convert "{}" "$(dirname "{}")/$(basename -s .epub "{}").mobi" &' \;
@rhardih
rhardih / zip_file_names.rb
Last active April 25, 2021 23:21
Listing filenames of a remote ZIP archive without downloading entire file
require 'httparty'
require 'uri'
def get_file_names(zip_url)
# ZIP file format: https://en.wikipedia.org/wiki/ZIP_(file_format)
# 1. Do an initial head request to figure out how big the file is from the
# content size
response = HTTParty.head(zip_url)