This file contains hidden or 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
;;; python-pylint.el --- minor mode for running `pylint' | |
;; Copyright (c) 2009, 2010 Ian Eure <[email protected]> | |
;; Author: Ian Eure <[email protected]> | |
;; Keywords: languages python | |
;; Last edit: 2010-02-12 | |
;; Version: 1.01 |
This file contains hidden or 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
;;; python-pep8.el --- minor mode for running `pep8' | |
;; Copyright (c) 2009, 2010 Ian Eure <[email protected]> | |
;; Author: Ian Eure <[email protected]> | |
;; Keywords: languages python | |
;; Last edit: 2010-02-12 | |
;; Version: 1.01 |
This file contains hidden or 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
<?php | |
error_reporting(E_ALL | E_STRICT); | |
class Foo | |
{ | |
public static function test() | |
{ | |
echo "Hi!\n"; | |
} |
This file contains hidden or 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 contextlib import contextmanager | |
@contextmanager | |
def save(obj, attrs=None): | |
"""Save attributes of an object, then restore them. | |
Example: | |
import breakfast | |
with save(breakfast, ('eggs', 'bacon')): | |
breakfast.Eggs = lambda: "Eggs" |
This file contains hidden or 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 -*- | |
import threading | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker, scoped_session | |
def query(): | |
engine = create_engine("mysql://testing:[email protected]/testing", | |
pool_size=20, strategy="threadlocal") | |
Session = scoped_session(sessionmaker(bind=engine)) |
This file contains hidden or 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 -*- | |
import threading | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker, scoped_session | |
engine = create_engine("mysql://testing:[email protected]/testing", | |
pool_size=20, strategy="threadlocal") | |
Session = scoped_session(sessionmaker(bind=engine)) |
This file contains hidden or 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 -*- | |
# foo()'s a_value is unmodified. | |
def foo(): | |
a_value = "Hello" | |
def bar(): | |
a_value = "Goodbye" | |
bar() |
This file contains hidden or 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 functools import partial | |
from itertools import imap | |
from operator import or_ | |
def retry(ntimes=3, ignore=None, trap=None): | |
"""Retry an operation some number of times. | |
The ignore and trap arguments may be a sequence (or a single) | |
exception class. If the decorated function raises an exception | |
matching ignore, it will be raised. |
This file contains hidden or 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 -*- | |
# | |
# Author: Ian Eure <http://github.com/ieure>, <http://atomized.org> | |
# | |
"""Enter the debugger on exceptions. | |
example: | |
from __future__ import with_statement |
This file contains hidden or 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 -*- | |
# | |
# Author: Ian Eure <[email protected]> | |
# | |
"""Star function.""" | |
from functools import partial | |
import unittest |