Skip to content

Instantly share code, notes, and snippets.

jadedgnome

Block or report user

Report or block jadedgnome

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9005569

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

View gifboom-dl
#!/bin/bash
# USAGE: ./gifboom-dl.sh <URL>
URL=$1
curl -s $URL |grep -o 'data-video-url=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/data-video-url=["'"'"']//' -e 's/["'"'"']$//' |cut -d '"' -f 2 | xargs wget
View show imgur album links
@jadedgnome
jadedgnome / feh bashrc bash function
Last active Aug 29, 2015
feh bash function/alias , It will search current dir and subfolders for .jpg,.jpeg & .png files and write them to a file in /tmp/ (e.g /tmp/filelist-4Gf) the last 3 characters are random. feh will then load the filelist and sort the files by modified time, display filename, auto-zoom and 800x600 resolution.
View feh bashrc bash function
fehl() {
randomfile=filelist-$(< /dev/urandom tr -dc A-Za-z0-9 |head -c 3).txt
find . -type f \( -iname "*.jpg*" -or -iname "*.jpeg*" -or -iname "*.png*" \) -printf "%p\n" | grep -v /thumbs/ >> /tmp/$randomfile ; feh -d -S mtime -Z -g 800x600 -f /tmp/$randomfile &
}
View makeagif.com dl
#!/bin/bash
# makeagif.com dl
# USAGE: ./makegif-dl.sh <URL>
URL=$1
curl -s $URL |grep -o '<img src=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/<img src=["'"'"']//' -e 's/["'"'"']$//' |grep .cdn | xargs curl --retry 3 -O -J
@jadedgnome
jadedgnome / list sshfs mounts bash function
Created Jul 13, 2014
list sshfs mounts from 'ps aux' output , formatted with awk.
View list sshfs mounts bash function
lsshfs() {
#list sshfs mounts
ps aux | grep sshfs | grep @ | grep -v "\-p" |awk '{print $2" = "$12" = "$13}'
ps aux | grep sshfs | grep @ | grep "\-p" | awk '{print $2" = "$12" "$13" "$14" = "$15}'
}
View lsshfs.sh
#!/bin/bash
#list sshfs mounts
ps aux | grep sshfs | grep @ | grep -v "\-p" |awk '{print $2" = "$12" = "$13}'
ps aux | grep sshfs | grep @ | grep "\-p" | awk '{print $2" = "$12" "$13" "$14" = "$15}'
View retry bash function
retry(){
# FROM http://redd.it/25tgqg
local delay=1 n
if ! [[ $1 = *[^0-9]* ]]; then
if (($1 > 0)); then
delay=$1
fi
shift
fi
View install_ffmpeg_ubuntu.sh
#!/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
View full-ffmpeg.sh
# 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
You can’t perform that action at this time.