In your models.py put:
from django.db import models
@classmethod
def model_field_exists(cls, field):
try:
cls._meta.get_field(field)
return True
"""Test of using graphviz's "dot" layout algorithm to arrange a Nuke node-graph | |
Example: http://i.imgur.com/f1mK7.png | |
Left is dot, right is Nuke's builtin nuke.autoplace | |
""" | |
import nuke | |
# http://code.google.com/p/pydot/ | |
import pydot |
/** | |
* Find the longest class names in Spring. | |
* Also find FactoryFactory classes. | |
* a goof-off project by @thom_nic | |
*/ | |
import java.util.jar.* | |
defaultTasks 'longest', 'factoryfactory' |
In your models.py put:
from django.db import models
@classmethod
def model_field_exists(cls, field):
try:
cls._meta.get_field(field)
return True
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
Should be work with 0.18
Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !
myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
#!/bin/sh | |
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON | |
# string. We can hack out the forwarded hostname by extracting the next | |
# `*.ngrok.io` string from the JSON | |
# | |
# Brittle as all get out--YMMV. If you're still reading, usage is: | |
# | |
# $ ./ngrok_hostname.sh <proto> <addr> | |
# |
# | |
# simpleBool.py | |
# | |
# Example of defining a boolean logic parser using | |
# the operatorGrammar helper method in pyparsing. | |
# | |
# In this example, parse actions associated with each | |
# operator expression will "compile" the expression | |
# into BoolXXX class instances, which can then | |
# later be evaluated for their boolean value. |
""" | |
Some table has two Date fields: expiredate and SALexpiredate | |
Both fields can be null | |
when SALexpiredate is not null, overrides expiredate | |
when ordering: | |
if SALexpiredate is not null, that field needs to be used | |
otherwise fallback to use expiredate | |
""" | |
from django.db.models import DateField, Case, When, F |
from tkinter import * | |
from tkinter.colorchooser import askcolor | |
class Paint(object): | |
DEFAULT_PEN_SIZE = 5.0 | |
DEFAULT_COLOR = 'black' | |
def __init__(self): |
#!/bin/sh | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
test_results=$(script -q /dev/null pipenv run python -m pytest ./test -v --tb=no) | |
if [ $? -eq 1 ]; then | |
printf "${RED}CANNOT COMMIT, PYTEST FAILED\n\nPYTEST RESULTS:\n" | |
echo "$test_results" | |
exit 1 | |
fi |