Skip to content

Instantly share code, notes, and snippets.

View pmourelle's full-sized avatar

Pedro Mourelle pmourelle

View GitHub Profile
@ObserverOfTime
ObserverOfTime / svgimagefield.py
Last active October 28, 2020 16:55 — forked from ambivalentno/svgimagefield.py
A form field to handle validation of image + svg.
from xml.etree import cElementTree as et
from django.core.exceptions import ValidationError
from django.forms import ImageField
class SVGImageField(ImageField):
"""A Django ImageField that accepts SVG images."""
def to_python(self, data):
"""
@haircut
haircut / Install PIP to user site on macOS.md
Created August 29, 2017 21:50
How to install and use pip without sudo or admin on macOS

Install and use pip on macOS without sudo / admin access

Most recently tested on macOS Sierra (10.12.6)

  1. Download the installation script; curl https://bootstrap.pypa.io/get-pip.py -o ~/Downloads/get-pip.py
  2. Run the installation, appending the --user flag; python ~/Downloads/get-pip.py --user. pip will be installed to ~/Library/Python/2.7/bin/pip
  3. Make sure ~/Library/Python/2.7/bin is in your $PATH. For bash users, edit the PATH= line in ~/.bashrc to append the local Python path; ie. PATH=$PATH:~/Library/Python/2.7/bin. Apply the changes, source ~/.bashrc.
  4. Use pip! Remember to append --user when installing modules; ie. pip install <package_name> --user

Note

@davemackintosh
davemackintosh / .htaccess
Last active May 2, 2024 15:52
Working .htaccess for Single Page Apps
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [QSA,L]
</ifModule>
@kblum
kblum / gist:1591459
Created January 10, 2012 22:00
Django cache page decorator for class-based view
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
def CachePage(cls=None, **cache_kwargs):
"""
Apply the ``cache_page`` decorator to all the handlers in a class-based
view that delegate to the ``dispatch`` method.
Optional arguments
``timeout`` -- Cache timeout, in seconds.``