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 fakeGlobal(object): | |
def __init__(self, f): | |
self.f = f | |
self.__name__ = f.__name__ | |
def __call__(self, *args): | |
global derpadil | |
derpadil = "blarg" | |
retval = self.f(*args) | |
del derpadil |
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 tater.models import FakeGlobal | |
class needsScriptingQueue(object): | |
def __init__(self, f): | |
self.f = f | |
self.__name__ = f.__name__ | |
def __call__(self, *args): | |
global scriptingQueue | |
sq_db = FakeGlobal.objects.get(name='scriptingQueue') | |
scriptingQueue = json.loads(sq_db.value) |
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
# | |
# Credit for finding this one goes to Brian Goldman | |
# | |
broken = 'broken' | |
works = 'works' | |
def test(): | |
print 'In Test', works |
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 python | |
# Grab the Astronomical Picture of the Day from NASA's site. | |
# Make it the desktop background, if it's a jpg | |
# | |
# Matthew Nuckolls | |
import urllib2 | |
import re | |
import subprocess | |
base_url = "http://apod.nasa.gov/apod/" |
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
# option 1 | |
if request.POST['modify'] == 'public': | |
assign_perm('modify', anon, rs) | |
else: | |
remove_perm('modify', anon, rs) | |
if request.POST['view'] == 'public': | |
assign_perm('view', anon, rs) | |
else: | |
remove_perm('view', anon, rs) | |
if request.POST['execute'] == 'public': |
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
# option 3 (ternary) | |
for perm in ['modify', 'view', 'execute']: | |
fn = assign_perm if request.POST[perm] == "public" else remove_perm | |
fn(perm, anon, rs) | |
# option 3.1 (switch/case-in-a-dict) | |
fn_selector = {"public" : assign_perm, | |
"private" : remove_perm } | |
for perm in ['modify', 'view', 'execute']: | |
fn_selector[request.POST[perm]](perm, anon, rs) |