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 bash | |
#-------------------------------------------------------------------------------------------------- | |
# log4bash - Makes logging in Bash scripting suck less | |
# Copyright (c) Fred Palmer | |
# Licensed under the MIT license | |
# http://github.com/fredpalmer/log4bash | |
#-------------------------------------------------------------------------------------------------- | |
source ../log4bash.sh | |
log "This is regular log message... "; |
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
# Bypass a decorator | |
import types | |
class decorator_test(object): | |
def __init__(self, f): | |
self.f = f | |
def __call__(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
class SmartResource(Resource): | |
def form_validation_response(self, e): | |
""" | |
Overridden method from piston's Resource class to handle | |
form validation errors. | |
""" | |
# Create a 400 status_code response | |
resp = rc.BAD_REQUEST |
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
class rc_factory(object): | |
""" | |
Status codes. | |
""" | |
CODES = dict(ALL_OK = ('OK', 200), | |
CREATED = ('Created', 201), | |
DELETED = ('', 204), # 204 says "Don't send a body!" | |
BAD_REQUEST = ('Bad Request', 400), | |
FORBIDDEN = ('Forbidden', 401), | |
NOT_FOUND = ('Not Found', 404), |
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
# Alias to allow you to view what the files are being used on your system | |
# Simply type "wtf" and then your pattern to match for what files you care about | |
# Feel free to use regular expressions to match on | |
alias wtf="sudo fs_usage -e -f filesystem | grep -v CACHE_HIT | grep -v grep | grep --color -Ei " |