This file contains hidden or 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
# Open django shell and do following. | |
from django.urls import get_resolver | |
def show_urls(urllist, depth=0): | |
for entry in urllist: | |
print(' ' * depth, entry.pattern) | |
if hasattr(entry, 'url_patterns'): | |
show_urls(entry.url_patterns, depth + 1) |
This file contains hidden or 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 water | |
if __name__ == "__main__": | |
water.auto_water() |
This file contains hidden or 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
LINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?).?(\s+|$)/gi | |
EMOJI_DIRECTORY = "/path/to/assets/emoji/20x20" | |
# Handlebars is presumed, but you could swap out | |
ESCAPE_EXPRESSION_FUNCTION = Handlebars.Utils.escapeExpression | |
MARKSAFE_FUNCTION = (str) -> new Handlebars.SafeString(str) | |
# Emoji unicode chars become images. |
This file contains hidden or 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 selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
from unittest import TestCase, main | |
from functools import wraps | |
from os import environ | |
# ============================================================ | |
# Helper functions -- skip these and go to the tests... | |
# ============================================================ |
This file contains hidden or 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
var Complex = function(real, imag) { | |
if (!(this instanceof Complex)) { | |
return new Complex (real, imag); | |
} | |
if (typeof real === "string" && imag == null) { | |
return Complex.parse (real); | |
} | |
this.real = Number(real) || 0; |
This file contains hidden or 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 djangorestframework.renderers import JSONRenderer | |
from colorpicks.serializer import ColorSerializer | |
# NOTE: Resources are nominally much less present in the | |
# restframework2 branch. You use Serializers directly | |
# to achieve the same thing. | |
obj = ... | |
serializer = ColorSerializer(instance=obj) | |
data = serializer.data |