3 ms·
Better HN search with bash
The interface for Algolia search is horrible for picking date ranges so I made this little bash function to fix it (noting that "open" is an alias to "xdg-open" for me on Linux).
Might work in other shells too.
function hn() {
if test $# -lt 1 || test $# -gt 3; then
echo "Usage: $0 <query> [start=1970] [end=now]"
echo "start and end are ISO dates like 2014-03-23."
return 1
fi
query=$1
start=$(test $# -gt 1 && date --date "$2" +%s || date --date @0 +%s)
end=$(test $# -gt 2 && date --date "$3" +%s || date +%s)
url="https://hn.algolia.com/?sort=byPopularity&prefix=false&page=0&type=story&query=${query}&dateRange=custom&dateStart=${start}&dateEnd=${end}"
echo $url
open "$url"
}
- redox_ 12y agoIndeed, we never took the time to plug a date parser. Any chance you've time for a pull-request? https://github.com/algolia/hn-search/blob/master/app/assets/javascripts/controllers.js#L26 https://github.com/algolia/hn-search/blob/master/app/assets/... and https://github.com/algolia/hn-search/blob/master/app/controllers/api/v1/base_controller.rb#L7 https://github.com/algolia/hn-search/blob/master/app/control... :) That would be cool!