Friday, May 31, 2013

How to disable the 'comments' box on a Wordpress static page

Problem: I want to disable the comments box on a static page I have put up on my Wordpress website, but I can't find any option to do this

Solution: (From the thread here) The option is a little hidden. 'Edit' your page, go to the top right hand corner where it says 'Screen options' and click to open the drag down menu. Check the 'discussion' section. This will make a new options box visible (found below your page text edit area). Uncheck 'Allow comments'.

Wednesday, May 29, 2013

A little funkyness with Pandas index

Problem:

I made a Pandas DataFrame
df
with a float index. Everything worked fine, including
df.plot()
But when I tried to do
pylab.exp(df.index.values)
I got the mysterious error
AttributeError: exp

Explanation:

It turns out that Pandas' index is restricted to int64 and 'object' and so
df.index.values
returns an
'object'
type array with exp can't interpret. We need to explicitly cast it as
'float'
to get things to work :
pylab.exp(df.index.values.astype('float'))

Tuesday, May 28, 2013

Blogger and Google sites vs wordpress

I've had this blog now for some years. I also recently put up my professional site on google sites. Very recently I've started to set up a blog/site on Wordpress.com

One thing I've noticed for both blogger and sites is that the pages are just not that pretty. I dislike fancy gadgets and tend towards minimal themes. Compared to blogger/sites Wordpress somehow gets the typography and layout just right. Wordpress sites are prettier, for reasons I can not explain.

This is a bit of a pity. Blogger lets you customize EVERYTHING. This is awesome. But no matter how I (an complete amateur in design) tweak, I can not get a pretty enough blog. Sites is horrendous. Everything looks very dull and drab.

Wordpress charges for some themes, and will charge you a bunch to have access to customizing the CSS and layout. It's not as great as free, but in a way I think the fact that Wordpress charges is a good sign. It means that this is a source of income for them. Which, in turn, means that they have an incentive to make things pretty and easy to use and cater to a wide variety of visual tastes.

In terms of usability, Blogger is really easy to use, though the interface can be a bit clunky. Wordpress is as easy to blog on and the interface is pretty.

Google sites, though free, not only looks bad, is very clunky to setup. Wordpress allows static pages as part of a blog (which you can easily turn into the main feature of your site) and this allows you to make very pretty sites.

This whole experience with blogger and wordpress has been interesting and informative. Blogger is a free service given away by google. It is technically very good, but visually not so polished and the interface is passable. Google sites is technically good, but visually unappealing and its usability is horrendous.

Wordpress (the site) offers a basic free version that is good enough visually. It makes money off sites that are willing to pay for more control over appearance. I think since wordpress generates revenue through selling the service/product itself they have paid more attention to visual polish and usability.

Sunday, May 26, 2013

The anti-Google crowd has a point

I'm looking at this backlash against Google and other SV tech co.s and surprisingly find myself on the side of the 'backlasher's. The news articles emphasize the SF hippies, but I think the deep root of it all is the basic social contract these companies are breaking. There is an idea, and it works well. You start a business on the street. You probably hire people who are local, you serve people who are local. You pay taxes to the local government. The government fixes the roads and sets up bus service and educates your kids. Your customers increase in number and their ability to pay. Your business lasts longer. Google and co seem to believe they can get away with creating their own parallel universe of buses and other infrastructure. But they would do much better to pay more taxes, especially local taxes, so that EVERYONE had a better bus service. Yes, their customers are more from outside SV than not, but their workers live here. If SF becomes a shitty place to live they will start to lose workers. Workers will not feel safe/happy in SF. When they go somewhere else, they might start out working remotely for google, but they might develop more ties to a different local business where they work. They might start working for them. These companies might be competing with Google. Wouldn't it just be better for Google and Co. to simply pay a little extra in taxes and make SF a much better place to live in?

Saturday, May 25, 2013

Ubuntu apt-get can not remove package due to configuration script

I once installed a package (pypy) through apt-get but then recklessly decided to delete the pypy directory (/usr/lib/pypy). When I tried to next do the right thing (sudo apt-get remove pypy) I kept getting funny errors from dpkg. It turned out that there was a script (/var/lib/dpkg/info/pypy.prerm) that dpky was using that was confusing it. Removing this script enabled me to clean out the package and then reinstall it properly.

Wednesday, May 22, 2013

Setting up Python/Pylab environment on machine with no root access

No pip? Bootstrapping ourselves
cd /tmp (We have write access here)
curl -O https://pypi.python.org/packages/source/p/pip/pip-1.3.tar.gz
tar -xzf pip-1.3.tar.gz
cd pip-1.3/
python setup.py install --user
Python informs us pip is now installed under
~/.local/
cd back to our directory. Add this path to .bash_profile
PATH=$PATH:$HOME/.local/bin
Let's try this out:
pip install matplotlib --user
pip install ipython --user
pip install --upgrade nose --user (The server had an older version of nose)

Tuesday, May 7, 2013

Git push to production machine

Application: I have code on my development machine that is under git. I would like to be able to send this code to my production machine when I'm ready. One way is to have a repository, say on github or bitbucket, and push from my devel machine and then pull from my prod machine. But sometimes the code is very specific and I'm not sharing it publicly. And, this is a kind of cumbersome two step process. Can we automate this process?

Solution (From discussions here and here): 


The basic idea is to set up a git repository in the production machine (wm.git) and indicate that as a remote. When you push, wm.git gets updated with the code that you push. The magic happens in the hook/post-receive script which gets executed on the production machine after a push, so you do not have to manually checkout the latest push.

Friday, May 3, 2013

Multi-indexing with Pandas DataFrame

One of the features of the Pandas library that I like the most is hierarchical indexing. The use of hierarchical indexing is illustrated by the following examples:


Inserting code snippets in blogger using github gists

From a hint on stackoverflow, a very convenient way of typing in code examples into blogger is to first enter the code as a gist on github and then find the 'embed' code and paste that into the 'html' tab of your post, like so:

Wednesday, May 1, 2013

Exploring Digital Filter Design with Python

If you analyze data chances are you need to use digital filters. The theory and practice of filter design and filter characteristics is well developed and requires some math background. If you do not have the patience to go through all the math the second best thing is to look at filter designs to get an intuition of how filter type and order translate into filter characteristics.

I've written a simple Python script using the Pylab and Scipy packages that allows you to interactively 'draw' a filter characteristic and see the filter design results from various algorithms.

The amplitude and phase characteristics, and the filter order are plotted and the coefficients are shown in the command window.

To play with this educational tool go to the neurapy repository on git hub and grab this script. Run in from ipython and explore the world of digital filter design.