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
  • 21:37 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / Copy Bitbucket repo to GitHub.md
Last active April 12, 2025 15:56 — forked from mandiwise/Update remote repo
Copy Bitbucket repo to GitHub

Copy Bitbucket repo to GitHub

Whenever possible, use GH's "Import repository" feature.

The import feature doesn't always work, though. In my experience, I tried to import a repo and it failed with a generic message. I had to contact GH support to ask for help. They told me my repo had a large file (>100MB), which couldn't be added to GH directly. I had to either remove the file or store it in GH LFS. In this case, one of the CLI methods below are needed:

CLI: Copy the master branch only (OK)

Git 1.6:
git ls-files --others -i --exclude-standard
Git 1.4, 1.5:
git ls-files --others -i \
--exclude-from="`git rev-parse --git-dir`/info/exclude" \
--exclude-per-directory=.gitignore
from: http://wtanaka.com/node/7875
@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 / 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 / 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 / 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}')[]'

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

@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 / list_vagrant_port_forwardings.rb
Last active March 22, 2017 21:16 — forked from andre1810/list_vagrant_port_forwardings.rb
List Port Forwardings of vagrant machines
vm_infos = `vboxmanage list vms`
puts 'Port Forwardings:'
puts '---------------------------------'
vm_infos.each_line do |vm_info|
vm_name = vm_info.scan(/\"(.*)\"/)
vm_id = vm_info.scan(/.*{(.*)}/).join('')
vm_detail_info = `vboxmanage showvminfo #{vm_id}`