Skip to content

Instantly share code, notes, and snippets.

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

#!/bin/bash
#This is free and unencumbered software released into the public domain.
#Because this script needs root to do some things, excessive amounts of
#checking have been done to terminate the script if anything fails.
#Read all instructions very carefully. When it asks to type "yes", it must be
#all uppercase or it will fail.
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
# Add multimedia source
echo "deb http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
echo "deb-src http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
apt-get update
apt-get install deb-multimedia-keyring # if this aborts, try again
apt-get update
# Go to local source directory
cd /usr/local/src
#!/bin/bash
echo "file name"
read name
#both the 'start' and 'end' variables should be time stamps of the format hh:mm:ss
echo "start of clip"
read start
echo "end of clip"
@jadedgnome
jadedgnome / clbin
Last active August 29, 2015 14:09 — forked from makefu/clbin
#!/usr/bin/env bash
# Upload text/images to clbin.com from the command line
# License: ISC http://www.isc.org/downloads/software-support-policy/isc-license/
clip() {
if command -v xclip &> /dev/null; then
xclip -selection clip <<< "$@"
elif command -v xsel &> /dev/null; then
xsel -b -i <<< "$@"
fi
}
alias cp='rsync -p --progress'
# copy with progressbar
@jadedgnome
jadedgnome / .zshrc
Last active August 29, 2015 14:11 — forked from xhacker/.zshrc
alias cp="rsync -avrP --progress"
alias aria2c="aria2c -s 16 -x 16 -k 1M"
alias nl="sudo lsof -i | grep -i listen"
ffmpeg -i some.mkv -acodec copy -vcodec copy some.mp4 #copy mkv to mp4 container - may not be compliant
ffmpeg -t 30 -i some.mkv -acodec copy -vcodec copy some.mp4 #create sample
ffmpeg -i some.mkv -acodec libfaac -ac 2 -vcodec copy some.mp4 #mp4 with downmixed audio (AAC @ 128kbit)
aria2c --bt-min-crypto-level=arc4 --bt-require-crypto=true --dht-listen-port=34450-34459 --listen-port=34460-34469
#!/bin/bash
if [[ $1 == "" ]]; then
echo "Usage: $0 <downloadurl>"; exit
fi
aria2c -v 2>&1 >/dev/null || (echo "aria2 is not installed"; exit)
url=`echo $1 | cut -f1 -d"?"`
cmd="aria2c"
for mirror in `echo "kent freefr garr switch netcologne surfnet heanet iweb superb-dca3 superb-dca2 jaist tenet ufpt internode" | tr ' ' '\n'` ; do
cmd="${cmd} \"${url}?use_mirror=${mirror}\""
done