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
#!/usr/bin/env python | |
# | |
# Copyright 2009 Chris Van Horne | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
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 django.contrib import admin | |
from foobar import models | |
class CommonSearchCriteria(admin.ModelAdmin): | |
search_fields = ('title',) | |
class AdvancedOptions(admin.ModelAdmin): | |
fieldsets = ( | |
('Advanced options', { | |
'classes': ('collapse',), |
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
(setq frame-title-format (concat "%b - emacs@" system-name)) | |
(setq inhibit-startup-screen t) | |
(setq make-backup-files nil) | |
(setq require-final-newline t) | |
(global-font-lock-mode t) | |
(setq font-lock-maximum-decoration t) | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(setq-default indent-tabs-mode nil) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
/* IEEE-754 values taken from page 2 of: | |
* "Introduction to Floating point calculations and IEEE 754 standard" | |
* Jamil Khatib, August 10, 2000 | |
*/ | |
typedef uint32_t uint; |
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
# -*- coding: utf-8 -*- | |
# Copyright (c) 2010, Almar Klein, Ant1, Marius van Voorden | |
# | |
# This code is subject to the (new) BSD license: | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above copyright |
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
## Making kick-ass global objects for fun-and-profit DSLs. | |
module ScopeLifting | |
class Application | |
attr_accessor :options | |
def initialize | |
@options = Hash.new | |
end | |
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
"""`namedmatch` mimics `re.match` but also creates attributes based on the | |
values of the named captures. | |
Example | |
>>> string = 'foo bar baz' | |
>>> match = namedmatch(r'(?P<start>\w+) (?P<end>\w+)', string) | |
>>> print match.start | |
"foo" | |
>>> print match.end |
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 mm import multimethod, symmultimethod | |
class Ship(object): | |
def __init__(self, name): | |
self.name = name | |
def __str__(self): | |
return self.name | |
class Asteroid(object): | |
def __init__(self, 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
def hashfn(item): | |
h = hash(item) | |
return (1 << (h%64)) | (1 << (h/64%64)) | |
def mask(val): | |
return bin(hashfn(val))[2:] | |
class CountingBloom(object): | |
def __init__(self): | |
self.items = [0] * 64 |
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 os | |
import re | |
class Env(object): | |
"""Maintains the environment variables for local and global scope.""" | |
def __init__(self, env={}, parent=os.environ): | |
self.env = env.copy() | |
self.parent = parent.copy() |
OlderNewer