Skip to content

Instantly share code, notes, and snippets.

View lsloan's full-sized avatar

Mr. Lance E Sloan «UMich» lsloan

  • Teaching and Learning (@tl-its-umich-edu) at University of Michigan: Information and Technology Services
  • Ann Arbor, Michigan, USA
  • 01:15 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / Postman current timestamp for UTC as ISO 8601.md
Last active September 4, 2023 11:44
Postman current timestamp for UTC as ISO 8601

I wanted to know: How can I get the current timestamp for UTC in ISO 8601 format to appear in the body data of a Postman request?

After reading some of the Postman documentation and online comments, this is the solution (using Postman v5.0.1 for Chrome 58.0.3029.110 on macOS 10.12.5) I used:

  1. In the Builder, while editing a request, click the "Pre-request Script" heading below the URL field.

  2. In the editor field that appears, enter this single line of JavaScript:

    postman.setGlobalVariable('timestampUtcIso8601', (new Date()).toISOString());
@lsloan
lsloan / extra_functions.py
Created June 22, 2017 18:11 — forked from pythonanywhere/extra_functions.py
PythonAnywhere Gist DemoBot
import os
import subprocess
def get_google_news_homepage():
print("this will fetch the current google news home page as text.")
print("it will use the requests and lxml libaries")
print("press enter to continue")
input()
import requests
@lsloan
lsloan / Vim Notebook.md
Created July 13, 2017 15:42 — forked from sloanlance/Vim Notebook.md
vim: Notes about using the vim editor, especially useful regular expressions (regex, regexes).

Vim Notebook

Notes about using the vim editor, especially useful regular expressions (regex, regexes).

  • Run an external command on all matching lines

    :g/pattern/.!command

    It's important that the dot command (.) appear between the search pattern and the bang (!) beginning the external command.

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@lsloan
lsloan / jsonlSort.sh
Created July 13, 2017 17:47 — forked from sloanlance/jsonlSort.sh
jq, JSON: Sort JSONL by using jq's `--slurp` option to treat it as a JSON array
#!/bin/sh --
# Execute with an argument containing the name of the property to be
# used for sorting.
# Improved according to a suggestion from @pkoppstein in response to my
# support issue:
# https://github.com/stedolan/jq/issues/1447#issuecomment-314918635
jq --slurp --compact-output 'sort_by(.'${1}')[]'
@lsloan
lsloan / Depersonalize JSON.md
Created August 15, 2017 16:02 — forked from sloanlance/Depersonalize JSON.md
jq: Depersonalize JSON

Depersonalize JSON

Why

If JSON data is to be shared for analysis, it's often necessary to depersonalize the data first. Depersonalization is different than anonymization. If data is anonymized, all information about the user is removed. Depersonalization, however, changes the user information to values that can't be recognized as being related to the real user. This way, it's still possible to see relationships within the data.

@lsloan
lsloan / web_request_monitor_with_netcat_nc.md
Last active March 8, 2021 20:44 — forked from sloanlance/nc-netcat_web_request_monitor.md
BASH: Simple web request monitor using `nc` (AKA Netcat)

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 localhost 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.

@lsloan
lsloan / centered.md
Created September 15, 2017 19:42 — forked from ProjectCleverWeb/centered.md
Example of how to do centered text and images in Githb Flavored Markdown
@lsloan
lsloan / power.sh
Created September 26, 2017 22:25
When "sudo -s" just isn't enough, you need more power.
sudo /bin/env bash
@lsloan
lsloan / Markdown_wishlist.md
Last active October 31, 2017 17:53
Example of formatting I wish Markdown would use

I wish Markdown supported this formatting:

  • Italics: /fubar/fubar (not _fubar_ or *fubar*)
  • Bold: *tarfu*tarfu (not **tarfu** or __tarfu__)
  • Underline: _snafu_snafu (new feature, not allowed by GitHub)
  • Strikethrough: ~bohica~bohica (GitHub supports this)