Skip to content

Instantly share code, notes, and snippets.

@fredpalmer
fredpalmer / log4bash-example.sh
Created May 26, 2011 02:01
log4bash example
#!/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... ";
@fredpalmer
fredpalmer / bypass_decorator.py
Created November 16, 2010 23:24
How to bypass a decorator in Python
# Bypass a decorator
import types
class decorator_test(object):
def __init__(self, f):
self.f = f
def __call__(self):
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
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),
# 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 "