Last active
August 29, 2015 14:13
-
-
Save sboysel/e0c0c93f19611b016435 to your computer and use it in GitHub Desktop.
Simple commandlinefu.com API functions with Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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