Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@paulsmith
paulsmith / verbatim_templatetag.py
Created October 25, 2011 19:03 — forked from ericflo/verbatim_templatetag.py
verbatim Django template tag
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@lerouxb
lerouxb / gist:1234843
Created September 22, 2011 14:02
Django Redis JSON Sessions
# originally from https://github.com/martinrusev/django-redis-sessions
# but use json, not pickle
import json
import pickle
import time
from redis import Redis
from django.utils.encoding import force_unicode
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
@zmsmith
zmsmith / jpegfield.py
Created June 20, 2011 21:54
Implementation of a Django ImageField that converts all images to JPEG
import Image
import cStringIO
from django.core.files.base import ContentFile
from django.db.models import ImageField
from django.db.models.fields.files import ImageFieldFile
class JPEGImageFieldFile(ImageFieldFile):
@olov
olov / references.rb
Last active September 25, 2015 17:58
Jekyll markdown references plugin by Olov Lassus: Keep all your markdown reference-style link definitions in one file (_references.md)
# references.rb has moved to https://github.com/olov/jekyll-references
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
#!/usr/bin/env python
"""
fabfile.py
Copyright (c) 2011 Giovanni Collazo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
anonymous
anonymous / Javascript flow
Created January 13, 2011 23:16
Use these functions to be able to express yourself beautifully in javascript
/**
* Binds a method to an object, so "this" inside the method
* refers to that object when it is called.
* @param method
* A reference to the function to call
* @param obj
* The object to bind to
* @param options
* Optional. If supplied, binds these options and passes
* them during invocation.
@elmarx
elmarx / django_gunicorn
Created December 23, 2010 14:35
init.d script for Debian GNU/Linux to run multiple Django instances, each in it's own virtualenv, with gunicorn.
#! /bin/sh
### BEGIN INIT INFO
# Provides: gunicorn_django
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Gunicorn WSGI server for django
# Description: This script starts a gunicorn instance for each django instance
### END INIT INFO
@coderanger
coderanger / db_server.rb
Created October 20, 2010 23:29
Create postgres users and databases from Chef
#
# Cookbook Name:: atari
# Recipe:: db_server
#
# Copyright 2010, Atari
#
# All rights reserved
#
include_recipe "postgresql::server"