Skip to content

Instantly share code, notes, and snippets.

@sorl
sorl / view.py
Last active January 20, 2016 08:42
from django.http import HttpResponse
class ApiResource:
@classmethod
def dispatch(cls, request, *args, **kwargs):
if args or 'object_id' in kwargs:
if request.method == 'GET':
return cls.read(request, *args, **kwargs)
elif request.method == 'PUT':
{
"title": "the title",
"description": "the description",
"images": ["data:image/jpeg;base64,...", "data:image/png;base64,..."],
"price": 100
}
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
@sorl
sorl / watchrsync
Created July 1, 2016 13:23
rsync files from osx to docker host
#!/bin/bash
fswatch -r "$1" -0 | while read -d "" file
do
rsync -a "$1" "$2"
echo "$file synced"
done