Skip to content

Instantly share code, notes, and snippets.

View mjkrause's full-sized avatar
🎯
Focusing

Michael Krause mjkrause

🎯
Focusing
  • Santa Cruz, CA
View GitHub Profile

Simple Rebase

The situation (1), the problem (2, 3) and the solution (4)

  1. Originally, you branched off of develop:
a -- b                           develop
       \
 f -- g your_branch
@mjkrause
mjkrause / jupyter_in_virtualenv.md
Last active August 2, 2019 16:11
Sourcing a virtual environment inside a Jupyter Notebook

Running Jupyter Notebook inside the virtual environment

You want to activate a virtual environment when running a Jupyter notebook using Python. In a terminal create a virtual environment, e.g., virtualenv --python=python3.6 .venv, then source that environment. Besides installing any required package and Jupyter (pip install --upgrade jupter) you need to install ipykernel, the IPython backend:

pip install ipykernel
python -m ipykernel install --user --name=.venv
@mjkrause
mjkrause / gist:9ff5da87a198dd8ed3742a7d397ef597
Last active December 18, 2019 21:39
JavaScript, Node.js, and TypeScript

JavaScript, Node.js, and TypeScript

Developing inside a running Docker container

This set of instructions is specific to developing an app created with Strongloop's Loopback.

Suppose you have a Docker container or a Docker-compose script which launches multiple containers, and you would like to develop the code-base while your code is running inside the container (and the container(s) could run on localhost or remotely). This can be done with VS Code.

  1. Open VS Code (code .) inside the directory that contains the code-base opens the IDE). Install the Remote Explorer extension.
  2. Navigate to the directory containing the code-base, including the Dockerfile or the docker-compose file. Launch the container(s).
@mjkrause
mjkrause / typescript_simplesetup.md
Last active March 27, 2020 17:18
Setting up typescript

Using Typescript

We need Node.js (and NPM for convenience) - see below on how to install it. First run sudo apt update (e.g., on Ubuntu).

Next create a new directory, and in it run npm init, followed by npm -g typescript to install TypeScript globally. Create a file script.ts in the project root, and add the line <script src="script.js" defer></script> to index.html (e.g., to head). (use html:5 in VS Code to set up a skeleton in a new index file).

lite-server

@mjkrause
mjkrause / README.md
Last active February 24, 2020 20:46
HMAC Base 64 encoded key to authenticate HTTP calls

Create a base-64-encrypted HMAC from message and secret key, using SHA256

API Key authentication based on UNIX epoch (an integer). Copy get_hmac_sha256.py and username_host.json into the same directory. Set ACCESSKEY and SECRETKEY as environment variables in the shell from which this script is run.

Then running the following in a shell

export ACCESS=1234
export SECRETKEY=abc123
python3 get_hmac_sha256.py

Set up Vagrant (Ubuntu 18.04)

  1. Download and install Virtualbox

  2. Download and install Vagrant

curl -O https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb