Skip to content

Instantly share code, notes, and snippets.

@sboysel
Last active August 29, 2015 14:13
Show Gist options
  • Save sboysel/e0c0c93f19611b016435 to your computer and use it in GitHub Desktop.
Save sboysel/e0c0c93f19611b016435 to your computer and use it in GitHub Desktop.
Simple commandlinefu.com API functions with Julia
# Quick wrapper for the awesome commandlinefu.com API
# http://www.commandlinefu.com/site/api
using Requests
using JSON
BASE_URL = "http://www.commandlinefu.com/commands/"
function bestfu()
q = BASE_URL * "browse/sort-by-votes/json"
return JSON.parse(IOBuffer(Requests.get(q).data))
end
function searchfu(query::String)
query_base64 = base64encode(query)
query = replace(query, " ", "%20")
q = BASE_URL * "matching/" * query * "/" * query_base64 * "/json"
return JSON.parse(IOBuffer(Requests.get(q).data))
end
## Examples
searchfu("grep")
searchfu("sort files by size")
bestfu()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment