Skip to content

Instantly share code, notes, and snippets.

View etianen's full-sized avatar

Dave Hall etianen

View GitHub Profile
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.sites.models import Site
>>> from reversion.models import Revision, Version
>>> from reversion import revision
>>> revision.register(Site)
>>> @revision.create_on_success
... def foo():
"""Thumbnail generation routines."""
import collections, os
from PIL import Image #@UnresolvedImport
from django.core.files.storage import default_storage
from django.utils import html
import qualified Data.Map as Map
{- Supported HTTP methods. -}
data HttpMethod = GET | POST deriving (Read, Show)
{- A parsed HTTP request. --}
import sys, itertools
# Supported HTTP methods.
GET = "GET"
POST = "POST"
# A parsed HTTP request.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'1234', // order ID - required
'Acme Clothing', // affiliation or store name
'11.99', // total - required
'1.29', // tax
'5', // shipping
'San Jose', // city
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'<?php echo $orderId; ?>', // order ID - required
'<?php echo $storeName; ?>', // affiliation or store name
'<?php echo $total; ?>', // total - required
'<?php echo $tax; ?>', // tax
'<?php echo $shipping; ?>', // shipping
'<?php echo $city; ?>', // city
-- Quick and dirty solution
sum [n | n <- [1..999], n `mod` 3 == 0 || n `mod` 5 == 0]
-- Better, more efficient solution
sum [1,3..999] + sum [1,5..999] + sum[1,15..999]
let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in sum $ takeWhile (<4000000) $ filter (even) fibs
foldr1 (max) $ filter (\p -> let s = show p in s == reverse s) [ n * m | n <- [1..999], m <- [1..999]]
foldr1 (+) $ map (\d -> read [d]) $ show $ foldr1 (*) [1..100]