Skip to content

Instantly share code, notes, and snippets.

View ojii's full-sized avatar

Jonas Obrist ojii

View GitHub Profile
@ojii
ojii / test.html
Created January 18, 2012 10:55
rickshaw
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="rickshaw.min.css">
</head>
<body>
<div id="chartcontainer-31992208">
<div id="chartyaxis-31992208"></div>
<div id="chart-31992208"></div>
</div>
@ojii
ojii / floppyform_tags.py
Created January 3, 2012 13:54
not proud of that code, but it seems to work
# -*- coding: utf-8 -*-
from classytags.arguments import Argument
from classytags.core import Options
from classytags.helpers import InclusionTag
from django import template
from django.utils.encoding import force_unicode
from floppyforms.widgets import Select
from itertools import chain
@ojii
ojii / gist:1510632
Created December 22, 2011 15:11 — forked from crooksey/gist:1510607
from django.db import models
from polymorphic.polymorphic_model import PolymorphicModel
from cms.models.fields import PlaceholderField
from django.db.models.signals import pre_save
from django.template.defaultfilters import slugify
class Slugifier(object):
def __init__(self, model, target, source):
self.model = product
self.target = slug
@ojii
ojii / slugifier.py
Created December 22, 2011 14:27
auto-slug class decorator
# -*- coding: utf-8 -*-
from django.db.models.signals import pre_save
from django.template.defaultfilters import slugify
class Slugifier(object):
def __init__(self, model, target, source):
self.model = model
self.target = target
self.source = source
field = self.model._meta.get_field_by_name(self.target)[0]
@ojii
ojii / gist:1447997
Created December 8, 2011 18:45
my stylebot style for facebook
#blueBarHolder {
position: fixed;
top: 0;
}
#globalContainer {
padding-top: 38px;
}
#leftCol {
@ojii
ojii / jquery.doubleoptin.js
Created November 8, 2011 15:54
double-opt-in buttons
$.fn.doubleOptIn = function(){
return this.each(function(){
var ele = $(this);
ele.bind('click', function(event){
event.preventDefault();
if (ele.attr('type') == 'submit'){
ele.val(ele.attr('x-opt-in-text'));
} else {
ele.text(ele.attr('x-opt-in-text'));
}
@ojii
ojii / managers.py
Created November 3, 2011 10:59
Django Model Managers
# -*- coding: utf-8 -*-
from django.db import models
from django.db.models.query import QuerySet
class ChainableManager(models.Manager):
"""
A manager that allows chaining of all methods defined on it.
Example:
@ojii
ojii / base.py
Created November 1, 2011 10:36
My scripts
# -*- coding: utf-8 -*-
# IS IN FOLDER ./src/ (github doesn't allow slashes in filenames on gists)
import os
import re
DEBUG = False
TEMPLATE_DEBUG = DEBUG
DEBUG_PROPAGATE_EXCEPTIONS = False
IS_DEV_SERVER = False
PREPEND_WWW = False
@ojii
ojii / gist:1328081
Created October 31, 2011 17:29 — forked from evildmp/gist:1328038
Attempt to understand the menu system
=========================
How the menu system works
=========================
Basic concepts
==============
Registration
------------
"""
Dummy code for my thoughts described in https://groups.google.com/forum/#!topic/django-cms-developers/bFbhE1a-rTs
Note that this pseudo-implementation has problems where between `cache.get(...)`
in `get_cached` and `cache.set(...)` the value *could* have changed in the cache,
so some kind of better way to prevent overwriting changes done by others should
be implemented.
"""
# the local python in-memory cache
LOCAL_CACHE = {}