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 importlib | |
func_text = """ | |
def add(a,b): | |
return a + b | |
""" | |
with open('func.py', 'w') as f: | |
f.writelines(func_text) | |
try: |
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 functools import wraps | |
def _exec_hook(hook_name, self): | |
if hasattr(self, hook_name): | |
getattr(self, hook_name)() | |
def hooks(fn): | |
@wraps(fn) | |
def hooked(self): |
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
// serialNumInfo() | |
// | |
// Evaluates a mobile device serial number, determines its type (ESN, IMEI, MEID) and attempts | |
// to check for validity if possible. | |
// | |
// When the passed purported serial number, the serialNumInfo() function returns a boolean flag | |
// ('isValid') indicating the validity of the number along with 'numType' indicating the type of | |
// serial number passed. The function expects the passed serialNumber to be not contain any | |
// spaces and for hexadecimal values to be passed without a leading "0x" or "0h" prefix. | |
// |
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
package main | |
import ( | |
"fmt" | |
"github.com/gomodule/redigo/redis" | |
"time" | |
) | |
//redis bitmap | |
// getbit setbit bitfield |
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
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
type Position struct{ | |
X int | |
Y int |
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 sqlalchemy.engine import Engine | |
from sqlalchemy import event | |
import time | |
import logging | |
logging.basicConfig() |
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
When running "pip install m2crypto" in a virtualenv, I got the following error: | |
Downloading/unpacking m2crypto | |
Running setup.py egg_info for package m2crypto | |
Installing collected packages: m2crypto | |
Running setup.py install for m2crypto | |
building 'M2Crypto.__m2crypto' extension | |
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c | |
swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i |
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 sys | |
# This code exists for backwards compatibility reasons. | |
# I don't like it either. Just look the other way. :) | |
for package in ('urllib3', 'idna', 'chardet'): | |
locals()[package] = __import__(package) | |
# This traversal is apparently necessary such that the identities are | |
# preserved (requests.packages.urllib3.* is urllib3.*) | |
for mod in list(sys.modules): |
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 validate(self): | |
""" | |
Validates the form by calling `validate` on each field, passing any | |
extra `Form.validate_<fieldname>` validators to the field validator. | |
""" | |
extra = {} | |
for name in self._fields: | |
inline = getattr(self.__class__, 'validate_%s' % name, None) | |
if inline is not None: | |
extra[name] = [inline] |
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
opts = new_class._meta = ModelFormOptions(getattr(new_class, 'Meta', None)) |
NewerOlder