#!/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 "${@}" |
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.
#!/bin/bash | |
# This is a draft but it works | |
# FIRST (I don't even know if it works but we'll assume yes) | |
# sudo launchctl list | |
# sudo launchctl disable system/netbiosd | |
# sudo launchctl disable system/parsecd | |
# sudo launchctl disable system/parentalcontrols.check | |
# sudo launchctl disable system/airportd |
Gist title: XSLT for JSON | |
Summary: In response to a Stack Overflow question about an XSLT equivalent for processing JSON, | |
I posted an answer (http://stackoverflow.com/a/34910682/543738) suggesting DefiantJS. Also, a | |
JSFiddle version (https://jsfiddle.net/lsloan/8dt9egjf/). |
Many websites attempt to validate email addresses based on formatting rules alone. Often, they use regular expressions which may turn out to be wrong, which is difficult to notice due to their complexity. Attempting to do very much validation of email addresses is usually a mistake and should be avoided.
The most common problem I've seen personally, from the perspective of a website user, is that email addresses containing a plus-sign (+
) are considered invalid. For example, an email address like [email protected]
is often rejected as invalid. However, that conclusion is incorrect.
- According to RFC 3696 from the IETF,
+
is a valid character for the "local part" (the part before the@
sign). - According to RFC 5233, the
[email protected]
address is valid and the receiving mail server will deliver messages for that address to the user with the address
Gist title: "BASH: ISO 8601 Timestamp with Milliseconds" | |
Summary: How to get an ISO 8601 timestamp with milliseconds in BASH |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# From http://nedbatchelder.com/blog/200712/human_sorting.html | |
import re | |
def tryint(s): | |
try: | |
return int(s) |
Example of GitHub's geoJSON support |