Skip to content

Instantly share code, notes, and snippets.

View mrob11's full-sized avatar
🎸

Mike Robinson mrob11

🎸
View GitHub Profile
@mrob11
mrob11 / docker-compose.yml
Created December 16, 2016 13:40
My multi-process node.js project setup
# I run the other services I need (database, redis, etc.) using Docker
# and I orchestrate them with this docker-compose.yml file.
version: '2'
services:
data:
image: busybox
volumes:
@mrob11
mrob11 / models.py
Last active October 27, 2020 11:22
Simple follower/following relationship in Django
$ ./manage.py shell
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from followers.models import *
>>> john = User.objects.create_user('john', 'lennon@thebeatles.com', 'password')
>>> paul = User.objects.create_user('paul', 'mccartney@thebeatles.com', 'password')
>>> george = User.objects.create_user('george', 'harrison@thebeatles.com', 'password')
>>> ringo = User.objects.create_user('ringo', 'starr@thebeatles.com', 'password')
@mrob11
mrob11 / serializers.py
Created January 7, 2014 14:52
A quick example explaining multiple nested serializers in Django Rest Framework.
from rest_framework import serializers
from myapp import models
class ProfileSerializer(serializers.ModelSerializer):
class Meta:
model = models.Profile
class UserSerializer(serializers.ModelSerializer):
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world!")