These learning resources primarily focus on programming using Good Design Principles and Design Patterns
- There is an emphasis on learning using PHP, although most patterns are universal to every object orientated language.
""" | |
Single Responsibility Principle | |
“…You had one job” — Loki to Skurge in Thor: Ragnarok | |
A class should have only one job. | |
If a class has more than one responsibility, it becomes coupled. | |
A change to one responsibility results to modification of the other responsibility. | |
""" | |
class Animal: | |
def __init__(self, name: str): |
// default exports
export default 42;
export default {};
export default [];
export default (1 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}
#Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels. | |
import PIL | |
from PIL import Image | |
mywidth = 300 | |
img = Image.open('someimage.jpg') | |
wpercent = (mywidth/float(img.size[0])) | |
hsize = int((float(img.size[1])*float(wpercent))) |
# Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/ | |
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join()) | |
class Image(Media): | |
image = models.ImageField( | |
upload_to=image_folder | |
) | |
thumbnail = models.ImageField( |