Skip to content

Instantly share code, notes, and snippets.

View jokull's full-sized avatar
☺️

Jökull Sólberg Auðunsson jokull

☺️
View GitHub Profile
@jokull
jokull / jquery.fungiform.js
Created April 28, 2011 11:34
Appends an `add` button to all `.multiple-items` rendered by fungiform for adding `Multiple` or `MultiChoiceField` in the DOM
(function(){
var resetLi = function($li, index){
$li.find(":input, label").each(function(i){
var $that = $(this);
$.each(['name', 'id', 'for'], function(i, attribute){
var value = $that.attr(attribute);
if(value){
$that.attr(attribute, value.replace(/\d+/, index))
}
});
from flaskext.fungiform import Form, widgets, TextField, FileField
class Admin(object):
module = Module(__name__, name='_admin', url_prefix='/_admin')
def __init__(self, app=None, editables=[]):
for editable in editables:
self.register_editable(editable)
@jokull
jokull / facebook_status.py
Created February 11, 2011 13:08
Fetch and cache Facebook status from feed
import datetime
import feedparser
import bleach
from flask import g, Markup
from kex.app import app
class Status(object):
ALLOWED_TAGS = []
/*!
* jQuery.dropload v0.1
*
* Copyright 2010, Jökull Sólberg Auðunsson
* FreeBSD License
* Description:
* For each drop of one or more files the client asynchronously
* sends the files to the server. The request is a multipart
* formencoded binary stream, making it easy to process on the
* server. Works in Chrome 7, maybe Safari.
# encoding=utf-8
"""
Author: Jökull Sólberg Auðunsson (solberg.is)
"""
from django.core.files.storage import get_storage_class
from django.db.models import ImageField
from uuid import uuid4
from django.conf import settings
from django.db.models import F, Q, Model, IntegerField, BooleanField
from django.db.models.query import QuerySet
from django.core.cache import cache
from django.utils.hashcompat import sha_constructor
from peopleproject.utils.models import BaseModel
class ModerateModel(BaseModel):
"""
SELECT (gatekeeper_moderatedobject.moderation_status) AS "_moderation_status",
(gatekeeper_moderatedobject.flagged) AS "_flagged",
(gatekeeper_moderatedobject.id) AS "_moderation_id",
"projects_project"."id",
"projects_project"."created",
"projects_project"."modified",
"projects_project"."title",
"projects_project"."mission_statement",
"projects_project"."extra_description",
"projects_project"."picture_id",