Simple Virtualenv Auto Activation With ZSH.

🔖 linux 

Since I moved from fish to zsh, one of the main things I missed was virtualfish. I’m not sure how any serious python developer lives without auto activation, as in automatically activating the virtualenv for your project when you open a terminal or cd to it.

Here is a script you can use to achieve auto activation. It doesn’t require virtualenvwrapper, pyenv, or anything like that. Just use python3’s built in python -m venv to create a virtualenv in ~/.virtualenvs/, use the provived venvconnect function to connect the activated env with the current directory, and you’re done.

#!/bin/zsh
#
# Auto activate a python virtualenv when entering the project directory.
# Installation:
#   source virtualenv-auto-activate.sh
#
# Usage:
#   Function `venvconnect`:
#       Connect the currently activated virtualenv to the current directory.
#
VENV_HOME=$HOME/.virtualenvs

function _virtualenv_auto_activate() {
    if [[ -f ".venv" ]]; then
        _VENV_PATH=$VENV_HOME/$(cat .venv)

        # Check to see if already activated to avoid redundant activating
        if [[ "$VIRTUAL_ENV" != $_VENV_PATH ]]; then
            source $_VENV_PATH/bin/activate
        fi
    fi
}

function venvconnect (){
    if [[ -n $VIRTUAL_ENV ]]; then
        echo $(basename $VIRTUAL_ENV) > .venv
    else
        echo "Activate a virtualenv first"
    fi
}

chpwd_functions+=(_virtualenv_auto_activate)
precmd_functions=(_virtualenv_auto_activate $precmd_functions)

Source the above script in your ~/.zshrc and you should get auto activation of python virtualenvs.

A Piece of Trash a Day

🔖 earth  other 

The lines we make in our day to day lives. Placed on a heatmap of all our motion, our daily routines show up in blazing hot purple. We ride down the same streets on our way to work, walk the same sidewalks to get the groceries, wander familiar shorelines on sunset strolls.

Read more...

Customizing grml-zsh-config

🔖 linux 

Ever heard of grml-zsh-config? Maybe not, but it’s possible you may have used it. It’s the zsh config for the Arch linux installer, as well as some Debian systems.

Grml is a nice alternative to heavy and bloated config frameworks like oh-my-zsh and pretzo (even on a modern machine I’ve seen zsh take over a second to load using oh-my-zsh with just a few plugins enabled).

Unfortunately, grml is not that easy to configure, and the available documentation is a little lacking. With a few tweaks though, I managed to get a proper shell out of grml.

Read more...

ArchLabs Linux Review (and tips)

🔖 linux 

Today I’m writing a review of the ArchLabs linux distro. Have you ever wanted a badass Arch linux install, complete with an openbox window manager, conky, and dark gtk themes, worthy of the top spot on /r/unixporn? Of course you do, but if you’re anything like me, you’re a busier person than you were when you were 15, and you no longer have the time, or the inclination.

Enter ArchLabs, elite Arch Linux for the lazy:

Desktop

Read more...

A Not so Dramatiq Change: A Celery Alternative

🔖 code  astronomy 
Both Celery and Dramatiq are asynchronous task processing libraries. You’d use them when you want to be able to parallelize Python code, and you need more than the multiprocess module offers, like persistent distributes queues, automatic retries, and result handling. I’ve been using Celery for almost my entire career, and it’s treated me well. Recently I’ve started to become frustrated with it. There have been numerous regressions that have broken my code, as well as some totally inexplicable issues in the last few months (that last one is the reason I started looking for alternatives). Read more...

Imaging the Space Tesla

🔖 astronomy 

Back in the beginning of February SpaceX launched their Falcon Heavy rocket to much fanfare and excitement. This test launch also had a test payload: Starman, a mannequin in a prototype SpaceX space suit behind the wheel of a cherry red Tesla Roadster. Spaceman was successfully inserted into a heliocentric orbit and there he’ll remain for millions of years.

For a few days Spaceman was close enough to earth to be visible by professional grade telescopes. As an employee of a company that builds and deploys a network of robotic telescopes I had to see if I could get an image of this guy.

Dr. Tim lister and I both set up observations, but of course Tim’s (who studies near earth objects) came back in better quality. I did some stacking and scaling and ended up with a .gif. Ladies and gentlemen, I present to you Starman in 9 parts:

Starman GIF

The image consists of 9x32 second exposures on one of our 1 Meter telescopes in Cerro Tololo, Chile. The images were captured around 2018-02-09 08:43 UTC.

See if you can find the faintly visible galaxy in the top left corner of the image.

Godspeed, Starman.

Line by Line Simple but Usable VIM Config

🔖 code 

VIM is a great editor, but it’s defaults are a little lacking. Fortunately it’s also extremely configurable. This leads many people (myself included), to scour the internet for lines of internet wisdom to copy in paste into their .vimrc files until they get something that works for them. Before you know it you have 300 lines of unintelligible gobblegook. In this post, (which I’ve started writing in vanilla vim) I’m going to go line by line through individual config items to construct a simple but usable .vimrc without too much magic or frills.

Read more...

GNOME Notifications for Remote Weechat

🔖 code 

I ❤ Weechat. It’s my IRC client of choice. But I also use it for gtalk and Slack. All my conversations in one convenient interface. Even better, I run it in a remote tmux session so I can pick up wherever I left off from anywhere.

The only annoying thing about this setup was the lack of real notifications for private messages or mentions. So I wrote Weelisten.

2017-07-27-gnome-notifications-for-remote-weechat.markdown

Weelisten is a small python script that leverages Weechat’s relay protocol, python 3 asyncio and libnotify so I can get awesome native notifications on my desktop.

Sounds useful? Get it on Github