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
  • 03:50 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / vagrant_host.md
Last active September 21, 2022 13:53
Vagrant: host IP address from guest perspective

Unless specified otherwise in Vagrantfile, the IP address of the host (the computer running Vagrant) from the perspective of the guest (the VM being run by Vagrant) is: 10.0.2.2

If that IP address doesn't work, then examination of Vagrantfile should reveal directives that changed it from its default value.

If an IP address can't be found in Vagrantfile, then the following command will probably reveal it:

route -A inet
@sloanlance
sloanlance / nc-netcat_web_request_monitor.md
Last active May 17, 2021 16:46
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 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.

@arwhyte
arwhyte / caliper-event-basic_message_posted.json
Created December 20, 2016 19:08
Caliper MessageEvent sans learning context (i.e., minus optional Event properties).
{
"@context": "http://purl.imsglobal.org/ctx/caliper/v1p1",
"type": "MessageEvent",
"actor": {
"id": "https://example.edu/users/554433",
"type": "Person"
},
"action": "Posted",
"object": {
"id": "https://example.edu/sections/1/forums/2/topics/1/messages/2",
@arwhyte
arwhyte / caliper-event-message_posted.json
Created December 14, 2016 18:59
Example Caliper MessageEvent.
{
"@context": "http://purl.imsglobal.org/ctx/caliper/v1p1",
"type": "MessageEvent",
"actor": {
"id": "https://example.edu/users/554433",
"type": "Person"
},
"action": "Posted",
"object": {
"id": "https://example.edu/sections/1/forums/2/topics/1/messages/2",
@sloanlance
sloanlance / Vim Notebook.md
Last active July 13, 2017 15:42
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.

@briankung
briankung / youtube2srt.rb
Last active June 7, 2018 22:31 — forked from lsloan/ Convert video subtitles from YouTube XML format to SubRip (.srt)
Convert XML Youtube subtitles to SubRip (srt) from YouTube ID or XML file
# Convert XML Youtube subtitles to SubRip (srt) format
# To download the subtitle in XML, put the code of the Youtube video
# at the end of the next url:
# http://video.google.com/timedtext?hl=en&lang=en&v=
# Usage:
#
# $ ruby youtube2srt.rb [input_filename] [output_filename]
#
# Where input_filename can be either the name of your xml file
@lsloan
lsloan / Markdown and reStructuredText: A Comparison
Last active December 13, 2016 22:26 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText
Gist title: "Markdown and reStructuredText: A Comparison"
Summary: A comparison of formatting features in Markdown and reStructuredText documents. See the " README.md" file for details.
@sloanlance
sloanlance / Auto Text Expander preferences ℹ️👍😃
Last active January 11, 2017 15:54
Emoji: Emoji and other things that I like Auto Text Expander to fill in for me.
Preferences for Auto Text Expander ℹ️👍😃
@ivanalejandro0
ivanalejandro0 / clipboard.sh
Last active March 19, 2017 22:30
Multi platform clipboard helper
#!/bin/bash
# Credit:
# original idea from https://github.com/rfairburn
clipboard() {
case "${OSTYPE}" in
linux*)
if which xsel &>/dev/null; then
xsel --input --clipboard

Here are my attempts to script an IntelliJ-based IDE.

IDE Scripting Console is backed by JSR-223 (javax.script.*) API.

Groovy, Clojure, JavaScript and other scripting languages may be used.

Open IDE Scripting Console, type a statement, hit Ctrl-Enter to execute the current line or selection.

.profile.language-extension file in the same directory will be executed along with it if present.