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
#!/bin/bash | |
psmgr=/tmp/waiting-fifo | |
rm -f $psmgr | |
mkfifo $psmgr | |
pids=( $$ ) | |
( | |
echo one-start |
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 LazyCollectionMixin(object): | |
__len__ = new_method_proxy(len) | |
__contains__ = new_method_proxy(operator.contains) | |
def __iter__(self): | |
# Don't define this as | |
# __iter__ = new_method_proxy(iter) | |
# because that creates a method which doesn't call yield, | |
# so it executes setup immediately. | |
if self._wrapped is empty: |
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 hashlib | |
import hmac | |
def verify_weebly_install_params(params, secret): | |
""" | |
Verifies the hmac of params on the Weebly install URL. | |
""" | |
# https://dev.weebly.com/oauth2.html |
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 isplit(patt, s, flags=None): | |
"""Return a generator that behaves similarly to re.split, with the | |
following differences: | |
1. It's a generator, not a list. | |
2. Zero-width separators work properly | |
(see http://bugs.python.org/issue3262) | |
3. The sequence always includes the separators, similar to calling |
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 bar.models import Bar | |
>>> b=Bar() | |
>>> b.pk='abcdef' | |
>>> b.save() | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/home/aron/.virtualenvs/pp/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save | |
self.save_base(using=using, force_insert=force_insert, force_update=force_update) | |
File "/home/aron/.virtualenvs/pp/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base | |
result = manager._insert(values, return_id=update_pk, using=using) |
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 operator, os, re, urllib | |
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp import template | |
__all__ = ['PySearch'] | |
anchors, lower_anchors = None, None | |
def get_anchors(): | |
global anchors, lower_anchors | |
if anchors is None: |
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
#!/bin/bash | |
hdmi=HDMI-1 | |
dvi=DVI-D-1 | |
case /$0 in | |
*/sitdown) xrandr --output $hdmi --auto ; xrandr --output $dvi --off ;; | |
*/standup) xrandr --output $dvi --auto ; xrandr --output $hdmi --off ;; | |
esac |
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
#!/bin/bash | |
if glxinfo | grep -q 'NVIDIA Corporation'; then | |
case /$0 in | |
*/sitdown) xrandr -s 1 ;; | |
*/standup) xrandr -s 0 ;; | |
esac | |
else | |
hdmi=HDMI-1 | |
dvi=DVI-D-1 |
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 walk_url_tree(urls): | |
""" | |
Generator to walk a tree consisting of RegexURLPattern (with callback) | |
and RegexURLResolver (with nested url_patterns). | |
Recursive depth-first. | |
""" | |
for u in urls: | |
if hasattr(u, 'url_patterns'): | |
for u2 in walk_url_tree(u.url_patterns): |
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 walk_url_tree(urls): | |
""" | |
Generator to walk a tree consisting of RegexURLPattern (with callback) | |
and RegexURLResolver (with nested url_patterns). | |
""" | |
for u in urls: | |
if hasattr(u, 'url_patterns'): | |
for u2 in walk_url_tree(u.url_patterns): | |
yield u2 | |
else: |
OlderNewer