List of command line accessible tools built into the Python standard library.
Base64 en/decoding:
python -m base64 -d [file]
python -m base64 -e [file]
#!/bin/sh -- | |
# This script is easier to use when in a file named "quopri" without the extension. | |
# The ".sh" extension is helpful for syntax highlighting in GitHub and editors. | |
# For use, it's recommended to either remove the ".sh" from the filename or make a | |
# symbolic link to it named "quopri". | |
# For more information about quopri, see: https://docs.python.org/library/quopri.html | |
python -mquopri "${@}" |
The robot.py
program from the original gist can be run by requesting:
https://www.pythonanywhere.com/gists/5502596/robot.py/ipython3/
_BUCKET_NAME="foo.example.com" | |
_POLICY=$(cat <<EOT | |
{ | |
"Version":"2012-10-17", | |
"Statement":[{ | |
"Sid":"PublicReadForGetBucketObjects", | |
"Effect":"Allow", | |
"Principal": "*", | |
"Action":["s3:GetObject"], |
Copied from: https://github.com/IMSGlobal/caliper-php/issues/126#issuecomment-226624750
I've recently learned that Guzzle is a popular HTTP client library for PHP: http://guzzlephp.org/
This package has a lot of nice features, including:
/* | |
* Formatted source of The Deletionist bookmarklet from: http://thedeletionist.com/ | |
* See examples of the output at: https://twitter.com/TheDeletionist | |
*/ | |
// javascript: | |
(function () { | |
console.log('*****************'); | |
console.log('The Deletionist, by Amaranth Borsuk, Jesper Juul, and Nick Montfort. 2013-07-09. http://thedeletionist.com'); | |
var Rule = function (name, regex, target) { |
While working on a project that produces JSON and sends it to a server using an HTTP POST request, I found it sometimes inconvenient to start the server every time I needed it. Most of the time, unless I was working on the server code itself, I just wanted to see the raw request data. I learned that the nc
utility (AKA netcat
) could do just that.
However, using nc
the way others explained it didn't work well for my purposes. It turns out that it shouldn't be run in the background, as was suggested, and it should give a proper HTTP response to satisfy the client. I came up with this solution:
while [[ 1 ]]; do printf 'HTTP/1.1 200 OK\n\n' | nc -l 127.0.0.1 8000; printf '\n\n= = = = = %s = = = = =\n\n' "$(date)"; done
It's helpful to run this in a shell in a separate window. As new requests are received, they will be seen scrolling up the display.
In older versions of iOS, a Pythonista program run from the application extension (iOS sharing mechanism) could open other applications using code like:
import webbrowser
webbrowser.open('googlechrome://example.com/')
Where googlechrome
(and googlechromes
for secure connections) is a special URL scheme registered by the Google Chrome application. Some other applications have their own schemes.
However, that doesn't work in more recent versions of iOS (at least version 9.3.5 and newer; older versions may be affected, too). That code will open Google Chrome if the program is run from the Pythonista UI, but not if it's run from a sharing request.
I'd recently expected the clear
-like command from a commandline PHP program to clear the screen and scrollback buffer, like Command-K does in iTerm. It didn't clear the scrollback, though. So I tried the ANSI or DEC vt100 escape sequence Esc[2J
. That didn't help either. The clearing wasn't important, though, searching for it was taking too much time, so I gave up on it. (Looking back, I probably could have found some iTerm documentation on the codes.)
I recently came across a solution for something else entirely, and it used the sequence Esc[3J
. It cleared the scrollback, too. I wanted to know which other parameters could be used in the Esc[ₓJ
sequence (which is called "erase in display" or "ED"), so I found these resources:
A
From: https://discussions.apple.com/message/31068162#message31068162
clear; printf '\e[3J' && log show --predicate 'subsystem == "com.apple.TimeMachine"' --info --last 48h | grep -F 'eMac' | grep -Fv 'etat' | awk -F']' '{print substr($0,1,19), $NF}'
My response to another thread: https://discussions.apple.com/message/31371971#message31371971