Thursday, January 29, 2015

Monday, January 26, 2015

Heroku: enable gzip compression

Add to your .htaccess file:

##################### GZIP COMPRESSION #####################

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-phpBrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary

Reference:
http://stackoverflow.com/questions/12367858/how-can-i-get-apache-gzip-compression-to-work

Wednesday, January 21, 2015

Monday, January 19, 2015

Python: ImportError: No module named mandrill

I installed mandrill using pip:

    (venv)Jhons-MacBook-Pro:venv jhonjairoroa87$ pip install mandrill

I got this result:

    Downloading/unpacking mandrill
    Downloading mandrill-1.0.57.tar.gz
    Running setup.py (path:/private/var/folders/x3/st96cn215h915kqwlcrmtspw0000gn/T/pip_build_jhonjairoroa87/mandrill/setup.py) egg_info for package mandrill
    Requirement already satisfied (use --upgrade to upgrade): requests>=0.13.2 in /usr/local/lib/python2.7/site-packages (from mandrill)
    Requirement already satisfied (use --upgrade to upgrade): docopt==0.4.0 in /usr/local/lib/python2.7/site-packages (from mandrill)
    Installing collected packages: mandrill
    Running setup.py install for mandrill
    changing mode of build/scripts-2.7/mandrill from 644 to 755
    changing mode of build/scripts-2.7/sendmail.mandrill from 644 to 755
    changing mode of /usr/local/bin/mandrill to 755
    changing mode of /usr/local/bin/sendmail.mandrill to 755
    Successfully installed mandrill
    Cleaning up...


But when I try to use it, fails:

    (venv)Jhons-MacBook-Pro:venv jhonjairoroa87$ python
    Python 2.7.6 (default, Sep  9 2014, 15:04:36)
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import mandrill
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named mandrill
    >>>
    >>> import sendmail.mandrill
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named sendmail.mandrill


I solved it by uninstalling it

     pip uninstall mandrill

and reinstalling it using the python -m option:

    sudo python -m pip install mandrill

Now it works perfectly.

    (venv)Jhons-MacBook-Pro:python_mandrill jhonjairoroa87$ python
    Python 2.7.6 (default, Sep  9 2014, 15:04:36)
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import mandrill
    >>>


Reference:
http://stackoverflow.com/questions/28032356/importerror-no-module-named-mandrill/28032480

Thursday, January 15, 2015

Codeship - heroku continous deployment: Push failed: could not store slug!

Trying to deploy automatically form codeship to heroku I was getting the error:

-----> Compressing... done, 72.0MB
-----> Launching...!     
Push failed: could not store slug!     
If the problem persists, see http://help.heroku.com and provide Request ID 

I solved the issue by adding the heroku url project and enable the "force push" flag in the option: Project settings > Deployment > Heroku Deployment > more options.

Reference:
http://stackoverflow.com/questions/9794413/failed-to-push-some-refs-to-githeroku-com

Wednesday, January 14, 2015

Python: "command python setup.py egg_info failed with error code 1" while trying to install psycopg2

Using MacOSX I was trying to install psycopg2 by using the command,

sudo pip install psycopg2

And I was getting this error:

command python setup.py egg_info failed with error code 1

I solved the issue by installing http://brew.sh/ and running following commands:

brew install python
brew install postgres

References:
http://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python