how to quote for command line usage - library support in python
- shlex — Simple lexical analysis — Python 3.8.3 documentation Link
how to quote for command line usage - library support in python
Sorting Lists of Dictionaries
Frequently you want to sort a list of dictionaries, based on some particular key.
Source: SortingListsOfDictionaries - Python Wiki Link
| // javascript examples - select based on xpath and extract text value | |
| var getXPath = '//div[contains(@class, "CopyToClipBoardInput")]/input'; | |
| var nodes = document.evaluate(getXPath, document, null, XPathResult.ANY_TYPE, null); | |
| var getElem = nodes.iterateNext(); | |
| getElem.value // or is it getElem.valueOf | |
| var getXPath = "//div[contains(@class, 'ContactInfoCallModal-phone')]//div"; |
| # applescript script to delete variables | |
| tell application "Keyboard Maestro Engine" | |
| set to_delete to {"my_email", "first_name", "last_name", "my_mobile"} | |
| repeat with my_var in to_delete | |
| setvariable (my_var as text) to "%Delete%" | |
| end repeat | |
| # set value of variables whose name starts with "minst" to "%Delete%" | |
| end tell |
| # sourced from: https://alvinalexander.com/unix/edu/examples/find.shtml | |
| find . -type f -maxdepth 2 -name "*.py" -exec grep -l richxerox {} \; | |
| -maxdepth 1 # searches only in the directory specified | |
| basic 'find file' commands | |
| -------------------------- | |
| find / -name foo.txt -type f -print # full command | |
| find / -name foo.txt -type f # -print isn't necessary |
| # ideas from New Finder windows - Questions & Suggestions - Keyboard Maestro Discourse | |
| # https://forum.keyboardmaestro.com/t/new-finder-windows/3048/2 | |
| # to merge current windows | |
| (* what is being done here | |
| Check if Finder windows exist. | |
| If two windows exist, then set them to be in bound1 and bound2. | |
| If more than one window exists, then merge them all. Copy the active tab. Close the active tab. Set bounds to bound1. | |
| Then open a new window with active tab path. Set bounds to bound2. |
| def get_date_s_from_string(s): | |
| """extract YYYY-MM-DD from string formatted YYYY-MM-DD_... | |
| Returns: | |
| [type] -- [description] | |
| """ | |
| re_pattern = '\d{4}-\d{2}-\d{2}' | |
| return re.search(re_pattern,s)[0] |
| tell application "Keyboard Maestro Engine" | |
| make variable with properties {name:"TaskNote", value:task_note} | |
| make variable with properties {name:"TaskName", value:task_name} | |
| end tell |