Switching to pew from virtualenvwrapper

Wanted to try something new so I switched from using virtualenvwrapper to Python Env Wrapper, aka pew for my Python virtual environments.

The cleanup.

(This is an ArchLinux system.)

Remove the python entry from the .zpreztorc file (which setup the WORKON_HOME env variable).

Then, remove virtualenvwrapper from the system:

yaourt -Rns python-virtualenvwrapper

then rebooted to MAKE SURE the environment came up clean.

The install and setup.

Installed pew:

yaourt -S python-pew

Since I am using Nikola to create this website, I:

pew new valencering

This created the new virtualenv, launched a new sub-shell and added the text "valencering" to the left side of the prompt but it didn't set the project directory.

So I cd'd to the working directory and ran:

pip install --upgrade "Nikola[extras]"

and then ran nikola build.

And it worked.

I exited the sub-shell and the prompt changed back to "normal" and nikola was no longer a valid command.

I then ran

pew workon valencering

It set the virtualenv but didn't take me to the code. So again, I cd'd there manually.

With the virtualenv activated and in the "home" directory I ran:

pew setproject

Now, no matter where I am, if I run:

pew workon valencering

it will take me to the code and set the virtualenv just like virtualenvwrapper would do.

Additional Information.

Looking at the Command Reference, I could have done all this in one command:

cd to the working directory

pew new -a $PWD valencering

One other difference is that the default location for the virtual environments is now at ~/.local/share/virtualenvs, whereas before, both oh-my-zsh and prezto set it at ~/.virtualenvs but it could be overridden with environment settings.

Virtualenv fix - dyld: Library not loaded:

When a virtualenv is activated and it displays an error message similar to:

dyld: Library not loaded: @executable_path/../.Python

There is more information at wirtel.be and at stackoverflow.

But...

The symbolic links to the Python executable are broken.

So...

Pretend the virtualenv is located at ~/.virtualenv/myapp.

Go to the virtualenv directory, delete the links, re-link Python:

cd

cd .virtualenv/

find myapp/ -type l -delete

virtualenv myapp

Go to the directory of myapp and activate the virtualenv and it should work.

Clone a python virtualenv

Working offline (no internet), create a new virtualenv based on an existing virtualenv:

mkvirtualenv (and virtualenv) are installed

pip install virtualenv-clone

Then, to create a new virtualenv:

virtualenv-clone /path/old-virtualenv /path/new-virtualenv

Use workon to activate the new virtualenv
Create a directory for the new project and cd into that directory.

setvirtualenvproject

Setup Cordova and Android for App development

A quick checklist to setup Cordova (PhoneGap) and Android to create Mobile Apps on a MacBook Pro running Mavericks.

Read more…

Exclude your main IP address from Google Analytics

Go to a website like What's my IP to get your current IP address.

Log on to the Google Analytics site.

Click on the "Admin" button and then click on "All Filters" in the left sidebar.

Click on "Add a new Filter" and create a new filter.

/galleries/posts/ga-exclude-filter.jpg

Input the IP address you got from What's My IP Address and save the filter.

Setup new MacBook Pro running Mavericks

This is a "checklist" for setting up a MacBook Pro running Mavericks.

Start: Completely clean MBP with Mavericks installed.

Goal: Have a nice system that will be used for mostly development but some entertainment using mostly FOSS software.

Read more…

Oh-My-ZSH and Python Virtualenv

OMZ has both a virtualenv and a virtualenvwrapper plugin.

In the past, the .virtualenvs directory was located at $HOME/python/.virtualenvs and the instructions for installing virtualenvwrapper required the addition of some exports to the .bashrc file.

The plugins take care of the exports but the default location for virtual environments is now at $HOME/.virtualenvs.

Oh-My-ZSH, gitconfig and using vi as editor

One more "converting to zsh" issue:

When commiting a change using the "gc" command, git would report this error:

error: There was a problem with the editor 'vi'.

Change the editor = vi to editor = vim line in .gitconfig.

There was probably either an alias or a symbolic link to make "vi" = "vim" but that doesn't exist anymore.

Running TMUX and Oh-My-ZSH together

Recently switched over to running ZSH on a MacBook Pro and also installed Oh-My-ZSH.

Added the tmux plugin to .zshrc and it worked.

Tried to use the same .tmux.conf file from "Bash land" and the keys worked correctly but the shell changed back to Bash.

Had to make one change to the tmux.conf file:

OLD:

``set-option -g default-command "reattach-to-user-namespace -l bash"

NEW:

``set-option -g default-command "reattach-to-user-namespace -l $SHELL -l"

This allows the OMZ script to run properly and now displays the correct prompt.

Automatically push master branch code to demo server

I have two VPSs (Virtual Private Server).

One is used as a version control repository. It runs both Gitolite and Fossil.

The second is a "normal" LAMP server. I want to use that to demonstrate the code I have created and have pushed to the version control server. But I only want that code to get run on this server if it is in the master branch of the repository of the project I am working on.

This post will explain how setup the demo server to automate the creation and setup of a new website and then connect the version control server to the demo server so it will automatically update the code running on the demo server when code is checked into the master branch of the repository.

Read more…