Reproducing an existing model setup
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
javascript:(function() { | |
if(!window.your_bookmarklet) { | |
var doc = document, | |
js = doc.createElement('script'); | |
js.type = 'text/javascript'; | |
js.src = 'loader.js'; | |
js.async = true; |
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
{# use in combination with https://github.com/zyga/django-pagination #} | |
{# and http://twitter.github.com/bootstrap/ #} | |
{# project-dir/templates/pagination/pagination.html #} | |
{% if is_paginated %} | |
{% load i18n %} | |
<div class="pagination"> | |
<ul> | |
{% block previouslink %} | |
{% if page_obj.has_previous %} |
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
try: | |
from django.utils.deprecation import MiddlewareMixin | |
except ImportError: | |
MiddlewareMixin = object | |
class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
""" | |
Ignore Accept-Language HTTP headers | |
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
""" | |
jQuery templates use constructs like: | |
{{if condition}} print something{{/if}} | |
Or like: | |
{% if condition %} print {%=object.something %}{% endif %} | |
This, of course, completely screws up Django templates, |
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
# coding=utf8 | |
import PIL | |
from PIL import ImageFont | |
from PIL import Image | |
from PIL import ImageDraw | |
def text2png(text, fullpath, color = "#000", bgcolor = "#FFF", fontfullpath = None, fontsize = 13, leftpadding = 3, rightpadding = 3, width = 200): | |
REPLACEMENT_CHARACTER = u'\uFFFD' | |
NEWLINE_REPLACEMENT_STRING = ' ' + REPLACEMENT_CHARACTER + ' ' |
In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.
All the examples use demical types, except for the original value, which is automatically casted as a float.
To set the context of what we are working with, let's start with an original 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
''' | |
texture image path are relative to the blend file directory. run from command line like this: | |
texture=img/2012720989_c.jpg blender -b mug.blend --python texture_change.py -F PNG -s 1 -e 1 -j 1 -t 0 -a | |
'''' | |
import os | |
image_file = os.getenv('texture') | |
if not image_file: | |
image_file="img/2012720989_c.jpg" |
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 oscar.apps.catalogue.abstract_models import AbstractProduct, | |
from parler.models import TranslatableModel, TranslatedFields | |
class Product(AbstractProduct, TranslatableModel): | |
""" | |
Add translations to the product model. | |
""" | |
# Provide translated fields. |
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 sys | |
from PIL import Image | |
from math import pi,sin,cos,tan,atan2,hypot,floor | |
from numpy import clip | |
# get x,y,z coords from out image pixels coords | |
# i,j are pixel coords | |
# face is face number | |
# edge is edge length | |
def outImgToXYZ(i,j,face,edge): |
OlderNewer