Thursday, May 24, 2012

apple in my eye

[UPDATE 2013-04-06]

I should have started this list ages ago.

Yes, you are so sleek, ouch you cost so much money, wow Facetime, but really, you can't copy an audio CD, or even a data CD for that matter, without jumping through hoops? Oh don't worry, apple's infinitely better by 50MMM in profits lossless format, which is only 50MB per song, so much smaller than the raw format, is what I should rip all of my music to so I can have like 6 songs on my, oh only works on Ipod or Ipad, Ihole. Point is, I have to go through 3 ridiculous steps to do something that should only take one step.

Number #1: Can't duplicate an audio CD.

P.S. It goes without saying that of course Ubuntu flavored Linux does this piece of cake - all I had to do was put it in my machine and Ubuntu asks, "Want to copy CD? Play it? Want a martini?" Why yes and all of the above, and yet you do this with zero profit? How so? I will love Linux til the day I die.

Brasero is the Linux app that does this, thanks to the thankless folks at GNOME.

P.P.S. Download Burn. It works. Now I'm lovin it.

Sunday, May 20, 2012

Precise pangolin updates

Something wicked was screwing up Ubuntu updates recently. Almost made me go back to apt. Just make sure you update your catalogue bwfore downloading and installing new udates. I know with apt this is a no-brainer, but I always assumed that update manager handled that automatically. First one update crashed on restart, the threw a bunch of errors. Then, updates would say there was a bad connection. Finally I had the sense to click check, and found more updates. That did the trick.

Saturday, May 19, 2012

spyderlib 2.1.9 on Python 2.7.3

[UPDATE 2013-06-15] This post is obsolete. Please see the spyderlib split, and download spyderlib-2.2. note on Ubuntu 13.04, spyderlib-2.1.13.1 is still available from software center.

Change isdir = os.path.isdir to a function, so it can be called with zero args.
def isdir
    return is.path.isdir(self)

msysgit bash for XP64

Ironically SysWoW64 is for x86 applications while system32 us for x64. You need to change the registry keys to use wscript from the windows/syswow64 folder.

Monday, May 7, 2012

virtualenvwrapper msys home

[UPDATED 2013-0207]

An indispensable piece of good Samaritan code is virtualenvwrapper by Doug Hellmann. It has some basic support for windows users using MSYS. In order to make it work though, you need to add an environmental variable to your ~/.bachrc file telling it where your MSYS files are located. If you're using msysgit, it's /c/Program\ Files/Git and user_scripts will append the "bin". And yes you will need mktemp, which you can acquire from MinGW* but you will need xz to unzip it and a compiler to build it. It is almost easier to download and install the mingw-get installer and then just add it to your mingw/msys folder by running the MinGW-MSYS bash and typing mingw-get install mktemp. Then I made a symbolic link, which in Windows looks like a copy, but is actually the same file, in my /home/bin folder which is always first in the bash $PATH.

*Since most MS Windows users have migrated to Win7 x64, I recommend using MSYS compiled by MinGW-w64 from their External binary packages (Win64 hosted) folder on SourceForge. You can simply unzip this either straight into your C:\ folder if you have admin rights, or the new and improved local virtual store which is at C:\Users\<username>\AppData\Local\VirtualStore\Program Files (x86) since MSYS is a 32-bit application. This will give you the POSIX environment and some of the MSYS GNU tools like mktemp, make and fmt, but you may need to copy over a few dll's too. The MSYS-dll is the same as msysgit's so, that's no issue. In particular make requires iconv and intl libraries.

Also you need a few other binaries to run the latest version of virtualenvwrapper. Namely make and fmt, make and the intl and iconv libraries as I said above.

Sunday, May 6, 2012

Update is checkout

I've got to find a git:hg conversion key.

Python flavored regex

Don't expect all flavors of regular expressions to be the same. For example, one difference between Java and Python, Java allows "unions" of character class by nesting.

    [0-4[6-8]]

is the same as

    [0-46-8]

but Python's re module will only interpret the latter.

There is an alternative module on pypi called regex that may replace re, which handles nested sets.

Thursday, May 3, 2012

IPythonQt on Windows


[UPDATE 2013-08-30] Distribute and Setuptools have merged. See Setuptools scandal derails distribute with wheels.

IPython is a very commonly used shell instead of the default Python interpreter. One of its advantages is its Qt console which can show plots like MATLAB. Building this for Windows is pretty painless, since windows installers are provided for each dependency, however their installation documentation for Windows is not crystal clear.
  • download and install the latest version of Python-2.7 - obviously you must have Python, make sure the executable matches your system, e.g. win32 for 32-bit Windows versions
  • See the great documentation on getting pip and setuptools.
  • download ez-setup from the setuptools documentation and run it using python from a command line (you must have python on your path).
  • python ez_setup.py
    • If you are using Git Bash you can also use curl and pipe it to Python like this.
    curl -k https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python
  • get the pip-installer from pip and then run it using Python in any command shell:
  • python get-pip.py
    • If you are using Git Bash you can also use curl and pipe it to Python like this.
    curl -k https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
  • download and install the latest version of IPython - this will install the IPython interpreter, make sure the executable matches your system, e.g. win32 for 32-bit Windows versions
  • download and install the latest version of pyreadline - this is required for the IPython, make sure the executable matches your Python version and your system, e.g. win32 for 32-bit Windows versions and Python 2.7
  • download and install the latest build of PyWin32 from sourceforge.net - this is not required but is strongly encouraged, make sure the executable matches your Python version and your system, e.g. win32 for 32-bit Windows versions and Python 2.7
  • download and install the latest version of pyzmq - this is required for the Qt console, make sure the executable matches your Python version and your system, e.g. win32 for 32-bit Windows versions and Python 2.7
  • download and install the latest version of matplotlib from sourceforge.net - this is required to make plots in the Qt console., make sure the executable matches your Python version and your system, e.g. win32 for 32-bit Windows versions and Python 2.7
  • download and install the latest version of PyQt - this is also required for the Qt console, make sure the executable matches your Python version and your system, e.g. win32 for 32-bit Windows versions and Python 2.7
now you can run IPython Qt console! Happy Hacking!

Wednesday, May 2, 2012

Dueling desktops

Update 2012-07-04. Happy Independence Day! I have posted a screenshot of PC-BSD's build of FreeBSD 9.0 - the Isotope edition below. Enjoy!

I've been playing around with virtual machines and different Linux distros and desktops. Pretty fun stuff. I know there are many websites out there that already cover this extensively. For example here's a discourse on the pros and cons of LXDE and Xfce, two popular "lightweight" desktops that are supported by almost every distro, and even BSD. My Geek Opinions - A Geek's Guide to Technology: LXDE vs Xfce. And here's a comparison of the two most popular heavyweights, GNOME (Ubuntu-Unity flavored) and KDE.

But this blog is realy just for me, and when I was deciding what distro to download and what desktop to use, I don't think the differences between distros and more so between desktops, were all that clear to me. So now that I understand it a little better, I don't want to forget it.

First of all I think it's super important to understand the difference between desktops and distros. I laugh a little about it now, but I actually thought Lubuntu, Kubuntu and Xubuntu were different distros. I didn't know that Linux and BSD could swap desktops. I'd only used machines with a terminal and a single desktop. I suppose in undergrad (1990's) I had the opportunity to use X Windows but that was just to display graphics like plots from MATLAB, and was not remotely like Windows 3.1 or the Macintosh OS the most popular graphic desktops at the time.

Suffice it to say that Linux and BSD unlike Windows and Mac, offer a choice of desktops. By far the most popular desktop is by GNOME, and by default the major Linux distribution all default to GNOME. However alternate desktops, such as KDE, LXDE and Xfce, will run on almost any Linux or BSD distribution. In fact, if you're so inclined, you could just use the command line and X Windows to run graphics programs like an internet browser. Wikipedia has a comparison of desktop environments. Wow, that's a pretty cool list - must check out Qt-Razor; there's a Fedora Spin in the works.

So I installed what I think are the most popular Linux distros as VMs: Fedora16, OpenSUSE12 and Ubuntu 12.04LTS (aka Precise Pangolin). I also installed FreeBSD a direct descendant of Unix. Of course there are other Unix-like systems, but I have a a 2-year old and a full time job so there are limits to how much time I can waste. On each system I chose a different desktop - Fedora got LXDE, OpenSUSE got GNOME, Ubuntu got Xfce and FreeBSD got KDE.

Installation
All four systems are a snap to install. All downloads are about 600MB. Fedora and OpenSUSE come as live ISO's that you start, and then have a app to install to the hard drive. Both also have a downloadable DVD image (about 3GB to 5GB) that can be used to install the system directly. Ubuntu on the other hand has a CD ISO that gives you the choice to install Ubuntu or run live. FreeBSD only has ISO for hard disk installation. I did not love having to run the live versions of Fedora and OpenSUSE to start the installation process, since I already knew I would install, so that was annoying. Also, since they run as live CDs, they require at least 512MB of RAM, which was an issue since I was installing them as VMs on pretty old machines, so RAM for me was scarce. VirtualBox couldn't handle it, but an older version of VMware Player was up to the challenge. Fedora and Ubuntu installations were a breeze, but there were some glitches in the graphics for Open SUSE, which may have been hardware related. I have a separate post on FreeBSD, but essentially it uses terminal style graphics, and installs as root, instead of an administrator, who can obtain root privileges.

Software Repository Packages
I installed some of my favorite tools: Numpy/SciPy, pip, virtualenv, virtualenvwrapper, Requests, Meld and Geany. Almost all were supported on every platform directly from the package repository, but at different releases. You can search Fedora, OpenSUSE and Ubuntu repositories online.

Screenshots
You can download and install Xubuntu, which is Ubuntu with the Xfce desktop.

Fedora has a spin for LXDE that you can download and install.

Open SUSE 12 only comes with GNOME or KDE, but there are older version that have LXDE and Xfce.

PC-BSD with FreeBSD 9.0

(Updated 2012-07-04) So far PC-BSD is like FreeBSD but with a nice desktop. The default is LXDE, but you can download XFCE, and others too, I think. I was too lazy to configure X11 correctly, and PC-BSD is a much easier. I was very impressed with the install procedure. One other nice feature is the edition of PBI's, which is like Ubuntu Software Center.

Conclusion
My favorite is still Ubuntu with Unity (GNOME3), but I don't have enough experience to discriminate between the other Linux distros. As far as desktops, I did not like KDE, even on FreeBSD. If I was going to re-install Ubuntu on my oldest laptop, I would use Xcfe, but Unity 2D seems to work just fine.

Tuesday, May 1, 2012

bugs-everywhere with msysgit

[UPDATED 2013-05-30] Read about how I installed BE in a virtualenv.

Bugs-everywhere (BE) is kind of neat idea - keep the bugs in your repo.

On MS Windows to get the editor to work for BE comments you need to add a Windows path to an editor since it calls Python's os.system, and not a shell command. If you are using msysgit this can conflict with git since it will read $EDITOR and execute it as a shell command.

To circumvent this, add $GIT_EDITOR which is read by git before $EDITOR. See git-var.

This is easily done if you've set up BE in a virtualenv and especially easy if you have virtualenvwrapper. Either way add to the script file.

postactivate/activate for virtualenvwrapper/virtualenv

# reset git var to vi, GIT_EDITOR is read before EDITOR
export GIT_EDITOR=vi
# set bugs-everywhere EDITOR to vim
# must use windows path since it calls os.system
export EDITOR=\"\"%PROGRAMFILES%\\Git\\share\\vim\\vim73\\vim.exe\"\"
predeactivate/deactivate for virtualenvwrapper/virtualenv

# remove bugs-everywhere EDITOR
unset EDITOR
# remove git var GIT_EDITOR
unset GIT_EDITOR
note that you need double quotes around the Windows path because it get's expanded twice.

django integration in pydev with virtualenv

[UPDATE 2013-01-16] This is no longer an issue. PyDev will use the Django version (and django-admin.py) that you have in your Python interpreter and that you selected during set up of the "New Project."

Django integration in the PyDev Eclipse plugin is pretty cool. You can run most of the Django commands, like "django-admin startproject", "syncdb" and even start a Django shell all from Eclipse. But it can be a tiny itsy-bit tricky if you are using virtualenv or virtualenvwrapper. The trick is to use --no-site-packages option, which is default on virtualenv 1.7.2. The reason is that if you include site or global packages, and you have different version of Django installed in your virtualenv and your global Python installation, then you will have two /bin/django-admin.py scripts, and so most likely, PyDev will run the global script, which is probably not what you want. Another trick is to select all when setting up your virtualenv Python interpreter in PyDev. The last trick is to use virtualenvwrapper, and/or keep all of your virtualenvs in a single location. If you are on Windows, make this path is close to the "root" of your C-drive and without any spaces. This will save you heartache as spaces don't expand well in shell scripts. For example, use C:\.virtualenvs. The dot is optional, but it's the recommendation by virtualenvwrapper. If you are on Linux, the default, ~/.virtualenvs is probably fine.s
Fork me on GitHub