Skip to content

Instantly share code, notes, and snippets.

View alexcabrera's full-sized avatar

Alex Cabrera alexcabrera

View GitHub Profile
@alexcabrera
alexcabrera / development_settings.py
Created November 23, 2010 04:43
Template from django project setup
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
class StockItemAttribute(models.Model):
name = models.CharField(max_length=80)
slug = models.SlugField(unique=True)
help_text = models.TextField(null=True, blank=True)
def __unicode__(self):
return _(self.name)
class StockItemAttributeValue(models.Model):
stock_item = models.ForeignKey('StockItem', related_name='attribute_values')
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{% block html_title %}{% endblock %}</title>
<meta name="description" content="">
<meta name="author" content="">
</head>
@alexcabrera
alexcabrera / gist:935259
Created April 21, 2011 19:05
Sweet nginx-based setup for local Django development
We couldn’t find that file to show.
# run compile-jammit to jump out of the compile jsts in our proj structure
compile-jammit () {
export ACTIVE_DJANGO_PROJECT=$PWD
echo "Entering ui directory"
cd ../ui
echo "Compiling JSTs"
jammit
echo "Returning you back to django project"
@alexcabrera
alexcabrera / hack-ia_writer.markdown
Created June 25, 2011 19:50
Easily style HTML output from iA Writer
  1. Right-click on iA Writer.app in your Applications folder, select "Show Package Contents"
  2. Open up Resources/English.lproj/htmlTemplate.html in your favorite text editor
  3. Add a link to a CSS file in your home directory (and anything else you might want). I put mine in ~/Library/Application Support/iA Writer/themes/policus/css/styles.css and decided to load a couple of web fonts from Google. See hacked-htmlTemplate.html later this gist.
  4. Save, exit
  5. Create the CSS file, override default Writer styles

Now when you export to HTML from inside of Writer, your HTML file will be styled according to your your overrides. Want to share your pretty docs? Print to PDF.

Next steps: Link to a locally-hosted jQuery and write a little JS app for switching themes in browser.

@alexcabrera
alexcabrera / _grid.sass
Created October 7, 2011 16:06
Simple responsive grid mixins in indented sass (boiled down from Susy)
// settings
$std-n-cols: 12
$std-col-width: 54
$std-gutter-width: 30
// calculated constants
$std-page-width: ($std-n-cols * $std-col-width) + (($std-n-cols - 1) * $std-gutter-width)
@function column-width($n-cols, $col-width:$std-col-width, $gutter-width:$std-col-gutter)
$column-widths: $n-cols * $col-width
@alexcabrera
alexcabrera / gist:1309395
Created October 24, 2011 16:07
nginx configuration for local development
server {
listen 80;
server_name active.lo;
access_log logs/active_lo_80.log;
client_max_body_size 200M;
location /static {
root /usr/local/www/active.lo;
}
@alexcabrera
alexcabrera / link-nginx-django-static.sh
Created October 24, 2011 16:10
link django's static and media directories for use with nginx during development
@alexcabrera
alexcabrera / gist:1461646
Created December 11, 2011 17:20
/etc/supervisor/conf.d/<project_name>.conf
[program:<project_name>]
command=/home/deploy/.virtualenvs/<project_name>/bin/gunicorn_django -c deploy/gunicorn.conf.py
directory=/home/deploy/<project_name>/<project_name>
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/<project_name>.log