Skip to content

Instantly share code, notes, and snippets.

@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')
@nkpart
nkpart / TestRiak.hs
Created May 17, 2011 23:01
Riak mapreduce with haskell problem
{-# LANGUAGE OverloadedStrings #-}
module TestRiak where
import qualified Network.Riak as R
import qualified Network.Riak.Protocol.MapReduce as R
import qualified Network.Riak.Types as R
import Data.Monoid
import Data.Aeson
import qualified Data.Vector as V
@badri
badri / oho.make
Created July 1, 2011 06:55
drushmake.me oho makefile
; ----------------
; Generated makefile from http://drushmake.me
; Permanent URL: http://drushmake.me/file.php?token=a597073754ce
; ----------------
;
; This is a working makefile - try it! Any line starting with a `;` is a comment.
; Core version
; ------------
; Each makefile should begin by declaring the core version of Drupal that all
@Quilted
Quilted / no_context_content_type.inc
Created July 5, 2011 01:25
CTools custom content pane example
<?php
/**
* @file
* "No context" sample content type. It operates with no context at all. It would
* be basically the same as a 'custom content' block, but it's not even that
* sophisticated.
*
*/
@voxpelli
voxpelli / vptest.info
Created July 5, 2011 20:01
OAuth.module 3.x example - a test I made to verify the D7 port of the module - should work well on D6 as well though
name = VoxPelli OAuth Test
core = 7.x
dependencies[] = oauth_common
dependencies[] = http_client
@ril3y
ril3y / create_x.509_cert.py
Created August 23, 2011 12:58
Python script that will generate a x.509 certificate
#!/usr/bin/python
from OpenSSL import crypto, SSL
from socket import gethostname
from pprint import pprint
from time import gmtime, mktime
from os.path import exists, join
CERT_FILE = "myapp.crt"
KEY_FILE = "myapp.key"
@cyberdelia
cyberdelia / mixin.py
Created September 21, 2011 08:26
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
@commix
commix / gist:1287276
Created October 14, 2011 14:30 — forked from mpezzi/gist:1287269
PHP: Validate - Human Name
/**
* Validate a Human Name
*
* @param $name
* A name as a string.
* @return
* TRUE or FALSE if name is a valid human name.
*/
function valid_human_name($name) {
return preg_match("/^[A-Z][a-zA-Z '&-]*[A-Za-z]$/", $name);
@dpwiz
dpwiz / scotty-auth.hs
Last active August 31, 2016 14:28
Check Basic HTTP Authentication in Scotty
main :: IO ()
main = scotty 3000 app
app :: ScottyM ()
app = do
rcon <- liftIO $ R.connect R.defaultConnectInfo {R.connectPort = R.UnixSocket "redis.sock"}
get "/favicon.ico" $ html "ಠ_ಠ"
get "/:method" $ do
@guerrerocarlos
guerrerocarlos / htpasswd.py
Created July 27, 2012 23:55
Python script for generating htaccess passwords
#!/usr/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find