This article covers the following topics:
- Introduction
- Installation
- Configuration
- Making your first call
- [Making API calls from the command line](#making-api-calls-from-the command-line)
- Parsing responses with
jq
| #!/usr/bin/env bash | |
| # vim: set filetype=ruby: | |
| # b - browse Chrome bookmarks with fzf | |
| [ $(uname) = Darwin ] || exit 1 | |
| which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1 | |
| /usr/bin/ruby -x "$0" | | |
| fzf-tmux -u 30% --ansi --multi --no-hscroll --tiebreak=begin | | |
| awk 'BEGIN { FS = "\t" } { print $2 }' | |
| // ======= Motivation ======== | |
| // http://www.theverge.com/2015/6/30/8871591/spotify-to-apple-music-migrate | |
| // http://i.giphy.com/1zTqgW6bS2jWU.gif | |
| // https://goo.gl/lMTvOj | |
| // All the delays in this script could be adapted | |
| // for your own needs… | |
| // Add this code to the Script Editor (OS X Only!) | |
| // and press Run… http://i.giphy.com/QfGMSZ25v3pGU.gif |
This article covers the following topics:
jqEver wanted to have random items put into the search results pulled from I18N Search?
It's actually not that difficult. The technique hinges on the return_i18n_search_results function, specifically designed for doing custom results rendering.
We call the function with the desired paramters to get the results. To ensure a properly random selection, we'll set the maximum number of results to a high number (e.g. 999).
$search = return_i18n_search_results($tags, $words, 0, 999, $order, $lang);| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # addnote.py by JP Mens (September 2015), inspired by Martin Schmitt | |
| # Usage: addnote subject "body (may be empty") [image ...] | |
| # Adds a Notes.app (OSX and iOS) compatible message to the "Notes" | |
| # IMAP folder. The IMAP store is configured from a file called | |
| # `creds': | |
| # | |
| # [imap] | |
| # hostname = |
| #!/usr/bin/env python | |
| # easyIMAP2Notes (C)2015 by Jan-Piet Mens | |
| # Connect to an IMAP mailbox, read messages, and convert them into | |
| # a format suitable for iOS/OSX Notes, then store them in Notes/ | |
| # | |
| # This uses two connections (consider that a feature b/c you can | |
| # slurp from one IMAP account into another). The real reason is I | |
| # couldn't be bothered to implement message decoding/attachment | |
| # extraction with imaplib, so I chose easyimap (pip install easyimap) | |
| # to do that. |
| tell application "Evernote" | |
| set _Notebooks to every notebook | |
| repeat with _NoteBook in _Notebooks | |
| set _NoteBookName to name of _NoteBook | |
| set _Notes to every note of _NoteBook | |
| local char_to_hex = function(c) | |
| return string.format("%%%02X", string.byte(c)) | |
| end | |
| local function urlencode(url) | |
| if url == nil then | |
| return | |
| end | |
| url = url:gsub("\n", "\r\n") | |
| url = url:gsub("([^%w ])", char_to_hex) |
| ... | |
| func faviconHandler(w http.ResponseWriter, r *http.Request) { | |
| http.ServeFile(w, r, "relative/path/to/favicon.ico") | |
| } | |
| ... | |
| func main() { | |
| http.HandleFunc("/favicon.ico", faviconHandler) | |
| } |