All Posts

Reason #4 on why Django is great

Tweet Middleware! I can’t tell you how great middleware is in Django. It makes life so easy! Here is a good example. Django doesn’t handle ajax errors very good. It prints them to the client. Sure I can use firebug but I mainly use chrome now and don’t like to touch firefox anymore. So I wrote a bit of middleware to only print out errors in all ajax requests if the app was in DEBUG mode.

Reason #3 on why Django is great

Tweet Making custom model fields are a great thing to save a lot of time. If you need a lot of custom validation around your modelforms and don’t want to do a lot of copy and pasting then create a custom model field. For example, I have the need for a user to input a lot of hostnames and domains and got sick of doing custom validation in each model form I created.

Install all needed RPMS for a rpmbuild

Tweet Ever had this happen? [mzupan@laptop SPECS]$ rpmbuild -ba php.spec cat: /usr/include/httpd/.mmn: No such file or directory error: Failed build dependencies: curl-devel >= 7.9 is needed by php-5.2.11-2.fc12.src db4-devel is needed by php-5.2.11-2.fc12.src gmp-devel is needed by php-5.2.11-2.fc12.src expat-devel is needed by php-5.2.11-2.fc12.src httpd-devel >= 2.0.46-1 is needed by php-5.2.11-2.fc12.src sqlite-devel >= 3.0.0 is needed by php-5.2.11-2.fc12.src readline-devel is needed by php-5.2.11-2.fc12.src libc-client-devel is needed by php-5.2.11-2.fc12.src postgresql-devel is needed by php-5.

A better Jira init.d script for Redhat/CentOS

Tweet I wrote a bit better init.d script for Jira for Redhat/CentOS The first thing you want to do is create a sysconfig file. Below is the filename /etc/sysconfig/jira The file has the following contents in it # # The user Jira runs as # JIRA_USER=jira # # The home directory of Jira # JIRA_HOME=/opt/jira/current Now create the init.d script /etc/init.d/jira It has the following contents in it.

Init.d script for puppet-dashboard

Tweet In the #puppet IRC channel on freenode a user was asking if anyone knew of a init.d script for redhat/fedora for puppet-dashboard. I have a blog post about installing puppet-dashboard on Redhat/CentOS and I don’t think there is any init.d script out there. So time to write one The first thing you will create is the following file /etc/sysconfig/puppet-dashboard This is a simple file with the following in it

SSH Trick

Tweet To start off with.. I know you can do this in DNS using a search parameter but I don’t want to do that in my envirnoment. Sometimes you are working with a hostname that is long due to the domain name. This is the case where I am currently working, the domain is theopenskyproject.com. So I did the following and added into my ~/.bashrc function ssh() { /usr/bin/ssh $1.

Google Apps List Shared Contacts

Tweet I’ll be the first to call out Google that their gdata python library for connecting into the Google Apps API is the worst. I wanted to grab all the shared contacts from our domain and it was a giant in the ass. Here is the code I ended up with import gdata.contacts.client contact_list = gdata.contacts.client.ContactsClient() contact_list.client_login(email="user@domain.com", password="password", source='comany-app-1', account_type='HOSTED') feed_url = contact_list.GetFeedUri(contact_list="domain.com", projection='full') while True: feed = contact_list.get_feed( uri=feed_url, auth_token=None, desired_class=gdata.

Django: Custom Decorator with an Argument

Tweet Sometimes you want to be able to create a decorator for functions in Django but have the ability to pass in an argument into the decorator. I came across this when I wanted to switch from the require_login decorator to check if a user was in a certain group to see the function. So the first thing I did was create a new directory in my project root called decorators and put a blank __init__.

Reason #2 on why Django is great

Tweet The decorators that Django has are a great time saver. There are a lot of methods in your views where you only want logged in users to see. So you can use a decorator before the function to check if they are logged in or not. from django.contrib.auth.decorators import login_required @login_required def my_view(request): .... So learn to use these time savers in your project.

Nginx proxy timeout fix

Tweet This is something that is an easy fix. Nginx is a great web server not only for your primary site but for a proxy as well since it is made to serve a lot of requests very fast. So it is as simple as this  location / { proxy_pass https://staging; proxy_read_timeout 500; proxy_next_upstream error; break; } The key lines are proxy_read_timeout and proxy_next_upstream.