Archive for the ‘Uncategorized’ Category

Install MySQL on Ubuntu Without Being Prompted for a Password

Sunday, January 8th, 2012

I’ve been doing quite a lot of development lately, on various projects, and have been making great use of Vagrant for isolated development. As such, I need to write provisioning scripts so that each machine can be built exactly as the production machine will be. I’ve tried Puppet once but it was far more than what I needed, so I just settled with using a shell script provisioner. Just a basic bash file with a bunch of apt-gets, pips and what not. Most of my projects require a database so MySQL it is. The issue I had was automatically installing MySQL without being asked for a password (as the provisioner is non-interactive). One amazing way I’ve found is issuing these commands before the apt-get (or tasksel) commands to install MySQL

echo "mysql-server mysql-server/root_password select (YOUR PASSWORD)" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again select (YOUR PASSWORD)" | sudo debconf-set-selections

Setting Up Local Mail Delivery on Ubuntu with Postfix and Mutt

Sunday, October 30th, 2011

I am getting pretty close to deploying m webap and am currently looking into ways to monitor exceptions once deployed. Django has the ability to email whenever it encounters a 500 error. I don’t really want any emails being sent out (yet) so I decided that I should probably just stick with local mail delivery until such time that I want to be notified right away of a problem.
(more…)

django-boilerplate-layout

Sunday, September 18th, 2011

Very quickly, I’d like to introduce to you my newest github project – django-boilerplate-layout. It is my hope that for each new version of django, you can check out this project layout and just start coding. More info on what this project is on the README.markdown

django-twitter-oauth on github

Thursday, June 16th, 2011

Just a quick post to link (one of my) works in progress – django-twitter-oauth that I forked on github. It is a work in progress as I am using it on another project I’m working on currently so, hopefully, this app can only get better over time. There are a few things I may want to change (caching the access token in the session instead of always going to the DB) and, really, this has not been tested on MySQL yet (I am using sqlite3 for dev), but it should work. Works well so far. Only a few problems I have yet to start working on (off the top of my head, random BadStatusLine exception every once in a while, mainly) .

I will try to update my blog whenever I update the app with what I changed, but we’ll see.

Separating Out Django Models into Different Files

Monday, June 6th, 2011

This will be a really quick post since, for whatever reason, I could not find this information out easy on the internet. The only reason I was able to find it is due to my great and good friend, Andres Buritica’s help. Starting a Django project, then an app gives you a models.py which Django expects to house all the models. This does not seem like the best of ideas, so obviously I want to split up the models into their own files in a specific model directory. To accomplish this, you must do two things:

  1. Create a meta class for the model with a field “app_label” being set to the name of your app
  2. In your __init__.py file, import that model.

For example, if you started an app by typing out ‘python manage.py startapp foo’, you can delete your models.py file, replace it with a directory named models (what I do), and inside have an __init__.py and Bar.py files.
in Bar.py:

from django.db import models
 
class Bar(models.Model):
    bar    = models.TextField(blank=False)
 
    class Meta:
        app_label = "foo"

then in __init__.py:

from Bar import Bar

This also goes for other things specified outside of the Django “norm” I guess?
If I wanted to associate Bar with the admin, I create a subdirectory inside my app named admin, and inside it I have
BarAdmin.py

from foo.models import Bar
from django.contrib import admin
 
admin.site.register(Bar)

Inside the __init__.py for the admin subdirectory, you’d have:

import BarAdmin

Now I could be doing this all wrong but this is the only way I managed to get everything working. If there is a better way to do this, I am all ears. To you Django/Python professionals out there, this may be common knowledge but I am noobing it up right now trying to better learn Python and Django.

Ease Switching Between OS X and Linux Environments for Development

Saturday, May 7th, 2011

As I may have pointed out in a previous post, I’ve switched all my non-server computers over to OSX. My desktop is OSX and dual boots Windows (for very few things). My latptop, my development machine, dual boots OSX and Linux. Each instance of OSX has Virtual Box and Windows XP as well as Linux, the mentality that for simple Windows and Linux things where OSX wouldn’t/couldn’t work, I can use a VM. For 99% of the time, that works. Ultimately I switch into the secondary OSes only when I need to access the hardware natively.

One issue I’d run into switching between OSX and Linux for development  - and one thing that really bothered me – is OSX’s home directory is /Users while any Linux box is /home. Call me lazy for not having a better way to manage configuration files but I didn’t want to manage configuration files. I finally decided that my OSX box should probably match my Linux box in terms of directory structure, at least superficially. I backed up the current /home directory on OSX and created a symlink to /Users so that /home -> /Users.

I don’t know if this is a bad thing or not, so try this at your own risk, but so far for me, I like it. I don’t know what’s taken me so long to do this.

These commands backup your current /home to /home_bkup, in case you ever need it again. Why? I don’t know.

cd /
 sudo mv home/ home_bkup

This creates the symlink.

 sudo ln -s /Users/ /home

Modernizing My Javascript Practices

Friday, May 6th, 2011

Few reasons why I haven’t updated this with any meaty updates:

  1. I’ve taken time off to do the life thing. Cliche but needed.
  2. Now that I’ve got back into developing software, I am trying new things out: Python/Django and Javascript

Now my Javascript experience has always been very poor but lately I’ve been finding videos that talk about Javascript and it is really getting me interested and excited about the language. The two so far I’ve found are:
JavaScript: The Good Parts talk by Doug Crockford

and the 10 Things I Learned from the jQuery Source by Paul Irish:

New Fangled Javascript Best Practices

Wednesday, April 13th, 2011

Subtitle: Or At Least, New Best Practices for Me

Now let me be honest: I’ve never been a fan of front end development. HTML sucked, Javascript wasn’t close to my favorite (I’d much rather code up some assembly than touch Javascript) and their interaction with each other was dirty, at best. With the dawn of HTML5, I’ve become interested in HTML again and viewing (or, trying to view) the Javascript source of the very prominent websites got me interested in Javascript. The real turning point for me was watching Paul Irish’s 10 Things I Learned from the jQuery Source. That video, really, has turned me around on the power of Javascript.

Here’s what I’ve got out of it so far:

test.html

<html>
    <head>
        <script src="test.js" type="text/javascript"></script>
        <script src="test.js" type="text/javascript"></script>
    </head>
    <body>
        <span>hi</span>
    </body>
</html>

test.js

1
2
3
4
5
6
7
(function(){
    var TEST = window.TEST || {test: 0};
 
    TEST.test++;
    alert(TEST.test);
    window['TEST'] = TEST;
}());

Now what am I going on about?

(more…)

Google Chrome is My Default Browser and Here’s Why

Monday, February 14th, 2011

I’ve always loved Google Chrome, since I first got my hands on it, but there were always so many things that I depended on in Firefox did but Chrome didnt – Live Bookmarks and Adblock mainly. Today marks the day that I’ve converted to using Chrome exclusively and here’s why.

(more…)