This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun flatten (lst) | |
(cond ((atom lst) lst) | |
((listp (car lst)) | |
(append (flatten (car lst)) (flatten (cdr lst))) | |
) | |
(t (append (list (car lst)) (flatten (cdr lst)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import tempfile | |
import doctest | |
def test_open(fn): | |
r""" | |
Test codecs.open to see if it actually opens a file | |
with an implicit binary mode and does not mess up the | |
newlines on Win32. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from one_file import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function alternate(id){ | |
if(document.getElementsByTagName){ | |
var table = document.getElementById(id); | |
var rows = table.getElementsByTagName("tr"); | |
for(i = 0; i < rows.length; i++){ | |
if(i % 2 == 0){ | |
rows[i].className = "even"; | |
}else{ | |
rows[i].className = "odd"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FacesContext context = FacesContext.getCurrentInstance(); | |
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse(); | |
response.sendRedirect("URL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%inherit file="_templates/site.mako" /> | |
These are all the categories: | |
<ul> | |
% for category, link in category_link_map.items(): | |
<li><a href="${link}">${category}</a></li> | |
% endfor | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%inherit file="_templates/site.mako" /> | |
<% | |
# Generate a map of categories to posts | |
category_post_map = {} | |
for p in bf.posts: | |
for c in p.categories: | |
try: | |
category_post_map[c.name].add(p) | |
except KeyError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import blogofile_bf as bf | |
import math | |
# A Blogofile based tag cloud with linear distribution. | |
# This works for either tags or categories. | |
# Ryan McGuire - www.blogofile.com | |
# Usage: | |
# In your template, add the following: | |
# ${bf.filter.run_chain("tag_cloud","categories")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A fixed @jsonify decorator for Pylons that allows for | |
# class implemented __json__ serializers | |
from decorator import decorator | |
from pylons.decorators.util import get_pylons | |
import warnings | |
import json | |
import logging | |
log = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import md5 | |
import sys | |
def sumfile(fobj): | |
'''Returns an md5 hash for an object with read() method.''' | |
m = md5.new() | |
while True: | |
d = fobj.read(8096) | |
if not d: | |
break |
OlderNewer