Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# don't forget each model needs
# class Meta:
# app_label = 'app_name' # or whatever the app name is
PACKAGE = 'project_name.app_name.models' # <--- SET YOUR PACKAGE NAME
import os
@EyePulp
EyePulp / gist:4962327
Last active December 13, 2015 19:28
django templated e-mail using markdown/html -- supports attaching files or streaming file attachments
from django.conf import settings
def email_template(
template_name = None,
template_context = None,
subject = '',
recipients = None,
sender = settings.DEFAULT_FROM_EMAIL,
fail_silently = False,
use_markdown = False,
def get_or_none(model, *args, **kwargs):
"""
look for a model instance, return None if it doesn't exists
"""
try:
return model.objects.get(*args,**kwargs)
except model.DoesNotExist:
return None
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@EyePulp
EyePulp / found .extend() in node.js
Created January 12, 2011 17:26
adding .extend()
Object.defineProperty(Object.prototype, "extend", {
enumerable: false,
value: function(from) {
var props = Object.getOwnPropertyNames(from);
var dest = this;
props.forEach(function(name) {
if (name in dest) {
var destination = Object.getOwnPropertyDescriptor(from, name);
Object.defineProperty(dest, name, destination);
}