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
  • 20:57 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@AppliedDataS
AppliedDataS / test.py
Last active July 13, 2018 20:28
Assignment 4 Q1 test code
import re
import pandas as pd
import numpy as np
# list of unique states
stateStr = """
Ohio, Kentucky, American Samoa, Nevada, Wyoming
,National, Alabama, Maryland, Alaska, Utah
,Oregon, Montana, Illinois, Tennessee, District of Columbia
,Vermont, Idaho, Arkansas, Maine, Washington
,Hawaii, Wisconsin, Michigan, Indiana, New Jersey
@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
@troyharvey
troyharvey / deployment.yml
Last active April 18, 2025 05:04
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@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)
@mort3za
mort3za / git-auto-sign-commits.sh
Last active February 5, 2025 18:58
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
@sloanlance
sloanlance / power.sh
Created September 26, 2017 22:26 — forked from lsloan/power.sh
When "sudo -s" just isn't enough, you need more power.
sudo /bin/env bash
@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
@cezarneaga
cezarneaga / filterArraysRamda.md
Last active April 26, 2023 07:52
Filter array of objects by nested values using ramda: Sometimes you dont have access to backend and you want to filter the response from an endpoint based on certain criteria. While trivial on flat arrays, this gets a bit tricky if the property you want to query is deeply nested. This is where Ramda shines.

Say we have a prop.users of the shape:

const users = [
    {username: 'bob', age: 30, tags: [{name: 'work', id: 1}, {name: 'boring', id: 2}]},
    {username: 'jim', age: 25, tags: [{name: 'home', id: 3}, {name: 'fun', id: 4}]},
    {username: 'jane', age: 30, tags: [{name: 'vacation', id: 5}, {name: 'fun', id: 4}]}
];
@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.