Skip to content

Instantly share code, notes, and snippets.

@mihasya
mihasya / after
Created January 2, 2013 19:32
Debug info about SecurityException when using mvn exec:java
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:compile
...
[INFO] +- com.yammer.dropwizard:dropwizard-core:jar:0.6.1:compile
[INFO] | +- com.sun.jersey:jersey-core:jar:1.15:compile
[INFO] | +- com.sun.jersey:jersey-server:jar:1.15:compile
[INFO] | | \- asm:asm:jar:3.1:compile
[INFO] | +- com.sun.jersey:jersey-servlet:jar:1.15:compile
[INFO] | +- com.yammer.metrics:metrics-core:jar:2.2.0:compile
[INFO] | +- com.yammer.metrics:metrics-servlet:jar:2.2.0:compile
[INFO] | +- com.yammer.metrics:metrics-jetty:jar:2.2.0:compile
#make some settings accessible via settings.FOO from within templates
from django.conf import settings
def exposed_settings(request):
context_settings = dict()
for x in settings.TEMPLATE_CONTEXT_SETTINGS:
context_settings[x] = getattr(settings, x)
return { 'settings': context_settings }
#Copyright (c) 2009 Mikhail Panchenko
#MIT License http://www.opensource.org/licenses/mit-license.php
class AddBmarkForm(forms.Form):
name = forms.CharField(max_length=50, required=False)
description = forms.CharField(max_length=255, required=True)
def clean_description(self):
desc = self.cleaned_data['description']
name = slugify(desc).decode()
#Copyright (c) 2009 Mikhail Panchenko
#MIT License http://www.opensource.org/licenses/mit-license.php
def userRequired(fn):
"""decorator for forcing a login"""
def new(*args, **kws):
user = users.get_current_user()
if not (user):
r = args[0]
return HttpResponseRedirect(users.create_login_url(
<?php
$argsToPass = array();
$args = ReflectionMethod->getParams();
/*you got an array of param names in the order they appear in the method signature */
foreach ($args as $arg) {
if (!isset($_REQUEST[$arg])) { //check if the arg is optional and fail if not }
$argsToPass[] = $_REQUEST[$arg];
}
$ReflectionMethod->invoke($argsToPass);
?>