Skip to content

Instantly share code, notes, and snippets.

View blackrobot's full-sized avatar
🖖
coffee

Damon Jablons blackrobot

🖖
coffee
View GitHub Profile
<div class="registration_form">
<p> <h4>New Customer (Register for an Account) </h4></p>
{% if register_state %}
<div class="state">
*{{ register_state }}
</div>
{% endif %}
<form action="" method="post" class="form-horizontal" name="registerform">{% csrf_token %}
{{ registerform.non_field_errors }}
@blackrobot
blackrobot / grunt.js
Created December 14, 2012 18:54
Simple grunt setup
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
/* Handlebars Templates */
handlebars: {
whatever: {
options: {
wrapped: true,
(function() {
var jQuery = window.jQuery,
frag = document.createDocumentFragment(),
js = document.createElement('script'),
css = document.createElement('link'),
head = document.getElementsByTagName('head');
if (jQuery === undefined || jQuery.fn.jquery !== '1.8.2') {
jq = document.createElement('script');
jq.href = "//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";
from django.db.models import Q
from apps.research.models import Product
"""
`codes` is a list of remaining (str) barcodes from the file.
`excludes` is a list of primary keys which i've already found
"""
minimum_digits = 5
qset = Q()
from django.contrib import admin
from example.admin_actions import export_csv_action
class ExampleModelAdmin(admin.ModelAdmin):
raw_id_fields = ('field1',)
list_display = ('field1', 'field2', 'field3',)
actions = [
export_csv_action("Export Sepecial Report",
class CitedBooksFilter(SimpleListFilter):
title = _('cited book')
parameter_name = 'book_title'
def lookups(self, request, model_admin):
return Citation.objects.exclude(cited_book_id=None).values_list('id', 'title').distinct()
def queryset(self, request, queryset):
if self.value():
queryset = queryset.filter(cited_book_id=self.value())
(function($) {
var $groups, $empty;
function init() {
var $el = $("#id_number");
$empty = $el.find('option:first');
$groups = $el.find('optgroup');
$('#id_letter').change(update);
update();
import os
# All of your normal settings...
# Utility function to join paths
def get_path(*args):
return os.path.realpath(os.path.join(*args))
from django import template
register = template.Library()
@register.simple_tag
def date_range(start, end):
""" Takes a start date, and end date, then formats them as a range. """
if end - start >= 365: # More than a year
from django.conf import settings
from django.core import cache
from micawber.providers import bootstrap_embedly as _bootstrap_embedly
def bootstrap_embedly():
""" This bootstraps micawber with the embedly bootstrapper, but uses a
specific cache.
"""