×

Filter by tag

Python Dependency Management

2024-07-05

Python package management has long been a struggle. In January 2017, the PipEnv project was started, and by 2018 it became the officially recommended package manager.

It brought a fantastic npm-like experience to Python, with easy configuration via a YAML Pipfile and a straightforward CLI. But then it went dead, not seeing any releases between November 2018 and April 2020. People moved on to Poetry, and I ended up using Conda quite a bit, especially when numpy/scipy was required.

While it does look like PipEnv has seen regular releases since April 2020, I’m seeing more people just use the built in pip+virtualenv tools. Here is how to do that…


From the Python docs.

Create and activate a virtual environment

python3 -m venv .venv
source .venv/bin/activate

Install dependencies

python3 -m pip install --upgrade requests
python3 -m pip install -r requirements.txt
python3 -m pip freeze

Deactivate environment

deactivate

Base64 Conversion

2023-01-04

Here is how to convert a string to and from base64 from the terminal.

echo "abcdef" | base64
YWJjZGVmCg==

echo YWJjZGVmCg== | base64 -d
abcdef

Delete local and remote git tag

2022-05-23

I can never remember how to delete a remote tag in git. Here is how to do it:

First delete local tag:

git tag -d 12345

Then delete remote tag:

git push origin :refs/tags/12345

Generate SSH Keys Locally

2022-03-30

It’s often necessary to generate a SSH key. Here is how to do it from the terminal.


Just run:

ssh-keygen -t ed25519 -C “your_email@example.com”

On a Mac, this will store the newly generated public and private keys in ~/.ssh.

You can copy the public key to the clipboard using:

cat ~/.ssh/id_rsa.pub|pbcopy

See here for more info.

Add SSH key to GitHub account Adding a new SSH key to your GitHub account

CSS Flexbox

2020-08-17

These two videos contain a good intro to Flexbox. Worth running through whenever you need a Flexbox refresher.

Here are some code snippets to remember…


Align items inside container

<style>
    h1 {
        text-transform: uppercase;
        font-size: 3em;
        font-weight: 100;
        width: 200px;
    }
    .parent {
        display: flex;
        border: 1px solid blue;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 800px;
        height: 800px;
    }

    .el {
        width: 200px;
        border: 1px solid red;
        text-align: center;
    }
</style>

<main>
    <div class="parent">
        <h1>Svelte Min</h1>
        <p>Here is some text</p>
        <div class="el">One</div>
        <div class="el">Two</div>
    </div>
</main>
  • main-axis: The main axis of a flex container is the primary axis along which flex items are laid out. The direction is based on the flex-direction property.
  • Layout is set using (for example) justify-content: center;.
  • cross axis: The axis perpendicular to the main axis is called the cross axis. Its direction depends on the main axis direction.
  • Layout on this axis is set using (for example) align-items: center;.

https://www.freecodecamp.org/news/flexbox-the-ultimate-css-flex-cheatsheet/

When we set flex-direction: column we are setting the main axis to be vertical. Then, if we want to align items along the horizontal axis, we need to use align-items.

Git Merging

2019-11-06

A quick refresher on some common git commands we use at EyeSpace.


merge

The merge command is used to integrate changes from another branch. The target of this integration (i.e. the branch that receives changes) is always the currently checked out HEAD branch.

git merge xxx

delete tag

Delete local and remote tag:

From here

git tag -d 12345
git push origin :refs/tags/12345

rebase

git rebase -i &lt;after-this-commit&gt;

and replace “pick” on the second and subsequent commits with “squash” or “fixup”, as described in the manual.

In this example, <after-this-commit> is either the SHA1 hash or the relative location from the HEAD of the current branch from which commits are analyzed for the rebase command.

For example, if the user wishes to view 5 commits from the current HEAD in the past the command is git rebase -I HEAD~5

checkout only file/directory from branch

git checkout feature-branch -- src/js/some-file.js